Skip to content

Instantly share code, notes, and snippets.

View jtrain's full-sized avatar
🏠
Working from home

jtrain

🏠
Working from home
View GitHub Profile
@jtrain
jtrain / taggit-on-zinnia-example.py
Created July 7, 2011 03:54
Using django-taggit on django-zinnia instead of django-tagging
"""
Example of installing django-taggit onto a Zinnia Entry model
(django-blog-zinnia) which traditionally uses django-tagging.
The django-taggit manager is installed on the tagged_as attribute because
tagged is already taken by the existing django-tagging installation (which we don't remove).
"""
from django.contrib import admin
@jtrain
jtrain / external_psse_setup_original.py
Created July 31, 2011 05:16
External Interpreter Environment setup for PSSE
import os,sys
sys.path.append(r"C:\Program Files\PTI\PSSE32\PSSBIN")
os.environ['PATH'] = (r"C:\Program Files\PTI\PSSE32\PSSBIN;"
+ os.environ['PATH'])
os.chdir(r"C:\work_dir")
import psspy
import redirect
_i=psspy.getdefaultint()
_f=psspy.getdefaultreal()
_s=psspy.getdefaultchar()
@jtrain
jtrain / external_psse_setup.py
Created July 31, 2011 05:21
External Interpreter Environment setup for PSSE minimum
import os,sys
PSSE_LOCATION = r"C:\Program Files\PTI\PSSE32\PSSBIN"
sys.path.append(PSSE_LOCATION)
os.environ['PATH'] = os.environ['PATH'] + ';' + PSSE_LOCATION
import psspy
import redirect
redirect.psse2py()
@jtrain
jtrain / example_external_psse.py
Created July 31, 2011 05:47
External Interpreter Environment setup for PSSE Example
"""
featured on our blog all about PSSE and Python:
blog.whit.com.au
"""
import os,sys
PSSE_LOCATION = r"C:\Program Files\PTI\PSSE32\PSSBIN"
@jtrain
jtrain / subsystem_info.py
Created August 20, 2011 01:54
An easy method for getting attribute information from the PSSE subsystem data retrieval api
from itertools import groupby
from operator import itemgetter
attr_type = itemgetter(0)
import psspy
def subsystem_info(name, attributes, sid=-1, inservice=True):
"""
Returns requested attributes from the PSS(r)E subsystem API
for the given subsystem id and subsystem element name.
@jtrain
jtrain / transactions.py
Created September 26, 2011 07:10
Transaction based Python script for PSSE
"""
Transaction
-----------
Wrap your PSSe Python code in this transaction and watch it rollback
when the case blows up.
"""
from __future__ import with_statement
import contextlib
import os
@jtrain
jtrain / example_transaction.py
Created September 26, 2011 07:29
Example code running in a Python for PSSE transaction
from __future__ import with_statement
import os
from transactions import transaction, psspy, PSSE_EXAMPLES
psspy.throwPsseExceptions = False
def validate_solved():
"""
Return true if the last psse case has solved.
@jtrain
jtrain / addgens_fromcsv.py
Created October 5, 2011 23:55
add generators to PSSE case from csv file
from __future__ import with_statement
import os
import sys
import csv
# Location of libraries
sys.path.append("C:\\Code\\trunk\\libs\\psselib") # psse_utilities
sys.path.append("C:\\Code\\trunk\\libs\\filelib") # file utils
sys.path.append("C:\\program files\\pti\\psse32\\pssbin") # psspy
@jtrain
jtrain / addgens_fromcsv.py
Created October 5, 2011 23:57
Add generators to PSSE case from csv file: Restructured version
"""
Add machines (gens and svcs) to the working case from a CSV file named:
``genslist.csv ``
This csv file **must** exist in the current directory. For
gens we add all to the case with status off. ECDI will take care of status.
For SVCs we only want them to be in service in and after the year specified in
the CSV. (Neither ECDI nor OPF [since fict SVCs control their own bus] will
control status of fict SVCs) NOTE: Script only works correctly IF case name
@jtrain
jtrain / boostrap-tables.html
Created January 4, 2012 09:42
Tables styles from bootstrap
<style>
table {
width: 100%;
margin-bottom: 18px;
padding: 0;
font-size: 13px;
border-collapse: collapse;
}
table th, table td {
padding: 10px 10px 9px;