This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var simplifyPath = function( points, tolerance ) { | |
// helper classes | |
var Vector = function( x, y ) { | |
this.x = x; | |
this.y = y; | |
}; | |
var Line = function( p1, p2 ) { | |
this.p1 = p1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import win32com.client as client # get win32com from Python package pywin32 | |
# See WEAP API at https://www.weap21.org/WebHelp/WEAPApplication.htm | |
WEAP = client.Dispatch('WEAP.WEAPApplication') # create WEAP object | |
# Open the area | |
WEAP.Areas("my area").Open() | |
# Set the expression |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
import json | |
class Hydra(object): | |
""" | |
Example: | |
# Set up the class | |
hydra = Hydra('https://www.openagua.org/hydra', api_key=os.environ['OPENAGUA_SECRET_KEY']) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def simplify_network(m, delete_gauges=False): | |
# simplify the network | |
mission_complete = False | |
obsolete_gauges = [] | |
while not mission_complete: | |
mission_complete = True | |
up_nodes = [] | |
down_nodes = [] | |
up_edges = {} | |
down_edges = {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from graphviz import Digraph | |
import json | |
with open('./pywr_model.json') as f: | |
model = json.load(f) | |
dot = Digraph(comment='System') | |
dot.edges(model['edges']) | |
dot.render('system.gv', view=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
from itertools import product | |
import win32com.client as client # get win32com from Python package pywin32 | |
# See WEAP API at https://www.weap21.org/WebHelp/WEAPApplication.htm | |
WEAP = client.Dispatch('WEAP.WEAPApplication') # create WEAP object | |
WEAP.Areas("Shire_ZAMCOM_v27_AB_ROR").Open() # open the model | |
realizations = [1,2,3] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import win32com.client as client | |
weap = client.Dispatch('WEAP.WEAPApplication') | |
print weap.ActiveArea.Name |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# script to run the HHLSM model | |
import os, os.path | |
import win32com.client | |
# install win32com with "pip install pywin32" | |
HHLSM = "HHSM_2008_v3.1_PEIR_BD_VULNERABILITY.xlsm" | |
MACRO = "{}!HHSM_2008_v2.HHSM_2008_v2".format(HHLSM) | |
scenarios = [1,2,3] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
from pypxlib import Table | |
def db(dir, name): | |
filelist = os.listdir(dir) | |
dbname = '{}.db'.format(name) | |
dbname = dbname if dbname in filelist else dbname.replace('.db', '.DB') | |
if dbname not in filelist: | |
return | |
mbname = dbname.replace('.db', '.MB').replace('.DB', '.MB') | |
if mbname not in filelist: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
from math import ceil | |
for region in ['CherryEleanor', 'DonPedro', 'Hetchy']: | |
# define input and output paths | |
inpath = 'baserun/{}/statvar.csv'.format(region) | |
outpath = 'baserun/{}/10day.csv'.format(region) | |
# read in the original csv | |
df = pd.read_csv(inpath, index_col=0, parse_dates=True) |
NewerOlder