Skip to content

Instantly share code, notes, and snippets.

@cwebber314
cwebber314 / find_bad_inservice.py
Created March 23, 2012 00:35
Find not Inservice buses attached to InService branches
"""
Find not Inservice buses attached to InService branches
"""
try:
import pssepath #Daniel Hiller's awesome PSSE environment setup module
pssepath.add_pssepath()
import psspy
except:
# Until i get this solved the right way this will have to do
PSSE_LOCATION = r"C:\Program Files\PTI\PSSE32\PSSBIN"
@cwebber314
cwebber314 / IEEE738TemperatureRise.py
Last active November 14, 2020 21:42
IEEE738 Temperature Rise calculation
"""
Python implementation for Temperature Rise Calculation [1].
The end result of this calculation is a temperature waveform.
References
-------------
[1] matlab implementation from Steven Blair.
https://github.com/stevenblair/ieee738matlab
"""
import numpy as np
@cwebber314
cwebber314 / mpl_wxpython_example.py
Last active May 20, 2019 21:39
Embed a matplotlib widget in wxpython. Control the figure using wxpython GUI elements.
import argparse
from numpy import arange, sin, pi
import matplotlib
matplotlib.use('WXAgg')
from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg as FigureCanvas
from matplotlib.backends.backend_wx import NavigationToolbar2Wx
from matplotlib.figure import Figure
@cwebber314
cwebber314 / pandas_mpl_wx.py
Last active January 10, 2018 13:08
wxpython with embbed matplotlib and pandas
import math
import argparse
import re
from numpy import arange, sin, pi
import matplotlib
import matplotlib.pyplot as plt
matplotlib.use('WXAgg')
from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg as FigureCanvas
"""
Show legend to left outside of plot area.
"""
import sys
import matplotlib.pyplot as plt
import numpy as np
from matplotlib.pyplot import show
from matplotlib.ticker import MaxNLocator
import matplotlib.gridspec as gridspec
from jinja2 import Template
f = open('template.html')
html = f.read()
f.close()
template = Template(html)
signals = {'s1': 0.0,
's2': 1.0,
's3': 'up',
@cwebber314
cwebber314 / ACCC_report.py
Created August 5, 2013 18:49
ACCC_report.py
#Created by knucklehead on 07-20-2013
#Developed with Python 2.7.3, EXCEL 2013, and PSSE 33.4
#This Module Creates an Excel Spreadsheet Comparing Results of Up to Eight(8) PSSE ACCC Solution Files
#Prompts for Contingency Low Bus Voltage Threshold to Report
#Option to Enable High Bus Voltage Reporting (GetHighV)
#Prompts for Contingency High Bus Voltage Threshold to Report (if GetHighV enabled)
#Prompts for Contingency High Branch Flow Threshold to Report
#Will Ask for How Many ACCC Files to Compare
#Prompts to Input the ACCC Files (Choose Files in the order Desired)
#Has Options to Report All Violations, Worst Violations, or Both on EXCEL Sheets
@cwebber314
cwebber314 / build_pandas_hdf5
Last active December 24, 2015 01:29
Build a pandas hdf store up a little at a time. This is useful for large data sets which do not fit in memory.
"""
References
--------------
[1] http://stackoverflow.com/questions/16997048/how-does-one-append-large-amounts-of-data-to-a-pandas-hdfstore-and-get-a-natural/16999397#16999397
[2] http://stackoverflow.com/questions/19036380/filtering-a-pytables-table-on-pandas-import
[4] http://pandas.pydata.org/pandas-docs/dev/cookbook.html#hdfstore
"""
# Build pandas dataframe on disk
/ -------------------------------------------------
// Setup run folders
// -------------------------------------------------
def getRunFoldersFromRootDir(): List[String] = {
val rootDir = new File(getSingleInput(Option("Path to the run folder root dir")))
require(rootDir.isDirectory(), rootDir + " was not a directory.")
rootDir.listFiles().toList.map(f => f.getAbsolutePath())
}
@cwebber314
cwebber314 / wxpython_tree_contextmenu.py
Created November 5, 2013 06:56
wxpython context menu on tree control.
import wx
class PackageTree(wx.TreeCtrl):
def __init__(self, parent, *args, **kwargs):
super(PackageTree, self).__init__(parent, style=wx.TR_DEFAULT_STYLE|wx.TR_HIDE_ROOT)
self.Bind(wx.EVT_TREE_ITEM_RIGHT_CLICK, self.OnShowPopup)
self.root = self.AddRoot('')
self.SetItemHasChildren(self.root, True)