forked from dwr-psandhu/ann_calsim
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdssioutils_dcr_3_x2_30cm.py
40 lines (34 loc) · 1.26 KB
/
dssioutils_dcr_3_x2_30cm.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#
import pyhecdss
import pandas as pd
import numpy as np
def add_pathnames(dssfile, paths):
'''
add the pathnames in the given HEC-DSS file and return the resulting dataframe
'''
sum = 0
for path in paths:
df = list(pyhecdss.get_ts(dssfile, path))[0][0]
# resample to daily, if daily this is no op
df = df.resample('D').ffill()
# then convert to time stamp
if isinstance(df.index, pd.PeriodIndex):
df.index = df.index.to_timestamp()
sum = sum+df.iloc[:, 0]
return sum
def collate_calsim_inputs_for_ann(dssfile):
'''
read inputs from given HEC-DSS File and has hardwired definitions of pathnames that have to be added to yield inputs
Parameters
----------
input HEC-DSS file with pathnames
Returns
------
returns a dataframe with named feature columns
'''
NDOI = add_pathnames(dssfile, ['/CALSIM-SMOOTH/NDOI/FLOW//1DAY/L2020A_DCP_PA6k_2040SLR10/'])
smscg = add_pathnames(dssfile, ['/CALSIM/SMSCG_OP/GATE-OP-RATIO//1MON/L2020A_DCP_PA6k_2040SLR10/'])
tide = add_pathnames(dssfile, ['/DWR/SAN_FRANCISCO/STAGE-MAX-MIN//1DAY/ASTRO_NAVD_20170607/'])
df=pd.concat([NDOI,smscg,tide],axis=1,join='inner')
df.columns=['NDOI','smscg','tide']
return df