hspf 2.1.0__tar.gz → 2.1.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- hspf-2.1.1/BigFork.py +711 -0
- {hspf-2.1.0 → hspf-2.1.1}/PKG-INFO +1 -1
- {hspf-2.1.0 → hspf-2.1.1}/pyproject.toml +1 -1
- hspf-2.1.1/setup.py +30 -0
- hspf-2.1.1/src/hspf/Masslink_Timeseries.csv +240 -0
- hspf-2.1.1/src/hspf/build_warehouse.py +545 -0
- hspf-2.1.1/src/hspf/data/HSPFParameterRanges.csv +492 -0
- hspf-2.1.1/src/hspf/data/LandUseNames_Mappings.csv +3330 -0
- {hspf-2.1.0 → hspf-2.1.1}/src/hspf/hbn.py +17 -4
- hspf-2.1.1/src/hspf/hbn2.py +316 -0
- hspf-2.1.1/src/hspf/hbn_cy.c +14450 -0
- hspf-2.1.1/src/hspf/hbn_cy.html +1540 -0
- hspf-2.1.1/src/hspf/hbn_cy.pyx +107 -0
- {hspf-2.1.0 → hspf-2.1.1}/src/hspf/helpers.py +8 -7
- {hspf-2.1.0 → hspf-2.1.1}/src/hspf/parser/graph.py +17 -2
- {hspf-2.1.0 → hspf-2.1.1}/src/hspf/reports.py +264 -459
- hspf-2.1.1/src/hspf/validations.py +211 -0
- hspf-2.1.1/src/hspf/warehouse.py +275 -0
- {hspf-2.1.0 → hspf-2.1.1}/tests/test_graph.py +21 -5
- hspf-2.1.1/tests/test_uci.py +35 -0
- hspf-2.1.0/tests/test_uci.py +0 -11
- {hspf-2.1.0 → hspf-2.1.1}/.gitattributes +0 -0
- {hspf-2.1.0 → hspf-2.1.1}/.gitignore +0 -0
- {hspf-2.1.0 → hspf-2.1.1}/MANIFEST.in +0 -0
- {hspf-2.1.0 → hspf-2.1.1}/src/hspf/__init__.py +0 -0
- {hspf-2.1.0 → hspf-2.1.1}/src/hspf/bin/WinHSPFLt/WinHspfLt.exe +0 -0
- {hspf-2.1.0 → hspf-2.1.1}/src/hspf/data/ParseTable.csv +0 -0
- {hspf-2.1.0 → hspf-2.1.1}/src/hspf/data/Timeseries Catalog/IMPLND/IQUAL.txt +0 -0
- {hspf-2.1.0 → hspf-2.1.1}/src/hspf/data/Timeseries Catalog/IMPLND/IWATER.txt +0 -0
- {hspf-2.1.0 → hspf-2.1.1}/src/hspf/data/Timeseries Catalog/IMPLND/IWTGAS.txt +0 -0
- {hspf-2.1.0 → hspf-2.1.1}/src/hspf/data/Timeseries Catalog/IMPLND/SOLIDS.txt +0 -0
- {hspf-2.1.0 → hspf-2.1.1}/src/hspf/data/Timeseries Catalog/PERLND/MSTLAY.txt +0 -0
- {hspf-2.1.0 → hspf-2.1.1}/src/hspf/data/Timeseries Catalog/PERLND/PQUAL.txt +0 -0
- {hspf-2.1.0 → hspf-2.1.1}/src/hspf/data/Timeseries Catalog/PERLND/PSTEMP.txt +0 -0
- {hspf-2.1.0 → hspf-2.1.1}/src/hspf/data/Timeseries Catalog/PERLND/PWATER.txt +0 -0
- {hspf-2.1.0 → hspf-2.1.1}/src/hspf/data/Timeseries Catalog/PERLND/PWATGAS.txt +0 -0
- {hspf-2.1.0 → hspf-2.1.1}/src/hspf/data/Timeseries Catalog/PERLND/SEDMNT.txt +0 -0
- {hspf-2.1.0 → hspf-2.1.1}/src/hspf/data/Timeseries Catalog/PERLND/SNOW.txt +0 -0
- {hspf-2.1.0 → hspf-2.1.1}/src/hspf/data/Timeseries Catalog/RCHRES/CONS.txt +0 -0
- {hspf-2.1.0 → hspf-2.1.1}/src/hspf/data/Timeseries Catalog/RCHRES/GQUAL.txt +0 -0
- {hspf-2.1.0 → hspf-2.1.1}/src/hspf/data/Timeseries Catalog/RCHRES/HTRCH.txt +0 -0
- {hspf-2.1.0 → hspf-2.1.1}/src/hspf/data/Timeseries Catalog/RCHRES/HYDR.txt +0 -0
- {hspf-2.1.0 → hspf-2.1.1}/src/hspf/data/Timeseries Catalog/RCHRES/NUTRX.txt +0 -0
- {hspf-2.1.0 → hspf-2.1.1}/src/hspf/data/Timeseries Catalog/RCHRES/OXRX.txt +0 -0
- {hspf-2.1.0 → hspf-2.1.1}/src/hspf/data/Timeseries Catalog/RCHRES/PLANK.txt +0 -0
- {hspf-2.1.0 → hspf-2.1.1}/src/hspf/data/Timeseries Catalog/RCHRES/SEDTRN.txt +0 -0
- {hspf-2.1.0 → hspf-2.1.1}/src/hspf/hspfModel.py +0 -0
- {hspf-2.1.0 → hspf-2.1.1}/src/hspf/parser/__init__.py +0 -0
- {hspf-2.1.0 → hspf-2.1.1}/src/hspf/parser/parsers.py +0 -0
- {hspf-2.1.0 → hspf-2.1.1}/src/hspf/uci.py +0 -0
- {hspf-2.1.0 → hspf-2.1.1}/src/hspf/wdm.py +0 -0
- {hspf-2.1.0 → hspf-2.1.1}/src/hspf/wdmReader.py +0 -0
- {hspf-2.1.0 → hspf-2.1.1}/tests/__init__.py +0 -0
- {hspf-2.1.0 → hspf-2.1.1}/tests/data/Clearwater.tpl +0 -0
- {hspf-2.1.0 → hspf-2.1.1}/tests/data/Clearwater.uci +0 -0
hspf-2.1.1/BigFork.py
ADDED
|
@@ -0,0 +1,711 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
"""
|
|
3
|
+
Created on Tue Apr 2 14:08:26 2024
|
|
4
|
+
|
|
5
|
+
@author: mfratki
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from hspf.hspfModel import hspfModel
|
|
9
|
+
import duckdb
|
|
10
|
+
from hspf import warehouse
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
model_name = 'BigFork'
|
|
14
|
+
db_path = 'C:/Users/mfratki/Documents/Calibrations/BigFork/model/HSPF_models.duckdb'
|
|
15
|
+
|
|
16
|
+
warehouse.init_hspf_db(db_path, reset = True)
|
|
17
|
+
with warehouse.connect(db_path) as con:
|
|
18
|
+
warehouse.create_
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
model = hspfModel('C:/Users/mfratki/Documents/Calibrations/BigFork/model/BigFork_0.uci')
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
from pyhcal.calibrators import calibrator
|
|
27
|
+
|
|
28
|
+
cal = calibrator('C:\\Users\\mfratki\\Documents\\Calibrations\\Nemadji')
|
|
29
|
+
cal = calibrator('C:/Users/mfratki/Documents/Calibrations/BigFork')
|
|
30
|
+
cal = calibrator('C:/Users/mfratki/Documents/Calibrations/BigFork/past')
|
|
31
|
+
cal.load_model('BigFork_WQ')
|
|
32
|
+
|
|
33
|
+
#%%
|
|
34
|
+
df = equis.download(['S007-352'])
|
|
35
|
+
df = equis.replace_nondetects(df)
|
|
36
|
+
df = equis.normalize_timezone(df)
|
|
37
|
+
df = equis.convert_units(df)
|
|
38
|
+
df = equis.map_constituents(df)
|
|
39
|
+
df = equis.normalize_columns(df)
|
|
40
|
+
|
|
41
|
+
[modl_db.get_outlets_by_reach(reach_id,'BigFork')['reach_id'].to_list() for reach_id in cal.uci.network._upstream(70)]
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
# lbs/acr/yr TP from each landcover
|
|
45
|
+
reach_ids = cal.uci.network._upstream(70) + cal.uci.network._upstream(132)
|
|
46
|
+
reach_names = cal.uci.table('RCHRES','GEN-INFO')['RCHID'].loc[reach_ids].reset_index()
|
|
47
|
+
df = reports.subwatershed_total_phosphorous_loading(cal.uci,cal.model.hbns,as_load=False,group_landcover = False).mean(axis=0).reset_index()
|
|
48
|
+
df = df.loc[df['reach_id'].isin(reach_ids)]
|
|
49
|
+
df.columns = ['perlnd_id','hspf_landcover','acres','reach_id','TP (lb/acr/yr)']
|
|
50
|
+
#df_q = cal.model.reports.ann_avg_subwatershed_loading('Q').reset_index()
|
|
51
|
+
#df_q = df_q.loc[df_q['TVOLNO'].isin(reach_ids)][['TVOLNO','weighted_mean_Q']]
|
|
52
|
+
df_q = cal.model.hbns.get_multiple_timeseries('PERLND',5,'PERO').mean().reset_index()
|
|
53
|
+
df_q.columns = ['perlnd_id','Q (in/acr/yr)']
|
|
54
|
+
df = pd.merge(df, df_q, right_on = 'perlnd_id', left_on='perlnd_id', how='left')
|
|
55
|
+
df = pd.merge(df, reach_names, right_on = 'OPNID', left_on='reach_id', how='left')
|
|
56
|
+
df.drop(columns = 'OPNID',inplace=True)
|
|
57
|
+
df.rename(columns = {'RCHID':'Reach Name'},inplace=True)
|
|
58
|
+
df.to_csv(cal.output_path.joinpath('Landscape_Loading.csv'),index=False)
|
|
59
|
+
|
|
60
|
+
# lbs/yr outflow of each reach
|
|
61
|
+
drainage_areas = [cal.uci.network.drainage_area([reach_id]) for reach_id in reach_ids]
|
|
62
|
+
df = cal.model.hbns.get_rchres_data('TP',reach_ids,'lb','yearly').mean()
|
|
63
|
+
df2 = cal.model.hbns.get_multiple_timeseries('RCHRES',5,'PTOTIN',reach_ids).mean()
|
|
64
|
+
df_q = cal.model.hbns.get_rchres_data('Q',reach_ids,'acrft','yearly').mean()
|
|
65
|
+
df_q2 = cal.model.hbns.get_multiple_timeseries('RCHRES',5,'IVOL',reach_ids).mean()
|
|
66
|
+
df = pd.concat([df,df2,df_q,df_q2],axis=1).reset_index()
|
|
67
|
+
df.columns = ['reach_id','TP Outflow (lb/yr)','TP Inflow (lb/yr)','Q Outflow (acrft/yr)','Q Inflow (acrft/yr)']
|
|
68
|
+
df = pd.merge(df, reach_names, right_on = 'OPNID', left_on='reach_id', how='left')
|
|
69
|
+
df.drop(columns = 'OPNID',inplace=True)
|
|
70
|
+
df.rename(columns = {'RCHID':'Reach Name'},inplace=True)
|
|
71
|
+
df['Drainage Area (acres)'] = drainage_areas
|
|
72
|
+
df.to_csv(cal.output_path.joinpath('Channel_Loads.csv'),index=False)
|
|
73
|
+
|
|
74
|
+
reach_ids = cal.uci.network._upstream(70) + cal.uci.network._upstream(132)
|
|
75
|
+
df = reports.subwatershed_total_phosphorous_loading(cal.uci,cal.model.hbns,as_load=False,group_landcover = False).mean(axis=0).reset_index()
|
|
76
|
+
df = df.loc[df['reach_id'].isin(reach_ids)]
|
|
77
|
+
df.columns = ['perlnd_id','hspf_landcover','acres','reach_id','TP (lb/acr/yr)']
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
dfs = []
|
|
84
|
+
for reach_id in cal.uci.network._upstream(70):
|
|
85
|
+
outlet = modl_db.get_outlets_by_reach(reach_id,'BigFork')
|
|
86
|
+
outlet = outlet.loc[outlet['station_origin']=='equis']
|
|
87
|
+
if not outlet.empty:
|
|
88
|
+
reach_ids = [int(num) for num in set(outlet['reach_id'].to_list())]
|
|
89
|
+
station_ids = outlet['station_id'].to_list()
|
|
90
|
+
|
|
91
|
+
df= cal.compare_simulated_observed(station_ids,reach_ids,'TP','YE')
|
|
92
|
+
df['outlet_id'] = outlet['outlet_id'].values[0]
|
|
93
|
+
dfs.append(df)
|
|
94
|
+
|
|
95
|
+
{'H57008001':{'station_name': 'Whisky Creek',
|
|
96
|
+
'opnids': [203,205,207]}}
|
|
97
|
+
|
|
98
|
+
#%% Reach 470
|
|
99
|
+
'''
|
|
100
|
+
- Model only
|
|
101
|
+
avg_ann_outflow()
|
|
102
|
+
avg_monthly_outflow()
|
|
103
|
+
avg_ann_watershed_loading()
|
|
104
|
+
avg_ann_subwatershed_loading()
|
|
105
|
+
avg_monthly_watershed_loading()
|
|
106
|
+
avg_monthly_subwatershed_loading()
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
avg_ann_stats()
|
|
110
|
+
avg_monthly_stts()
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
'''
|
|
114
|
+
|
|
115
|
+
constituent = 'TP'
|
|
116
|
+
units = 'mg/l'
|
|
117
|
+
sample_flag = True
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
station_ids = ['S001-235','S005-115']
|
|
121
|
+
flow_station_ids = ['E05011002']
|
|
122
|
+
reach_ids = [103]
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
#station_ids = ['S004-000']
|
|
126
|
+
station_ids = ['S005-369']
|
|
127
|
+
#station_ids = ['E77069001']
|
|
128
|
+
flow_station_ids = ['E77069001']
|
|
129
|
+
reach_ids = [470]
|
|
130
|
+
|
|
131
|
+
station_ids = ['H77031001']
|
|
132
|
+
flow_station_id = ['H77031001']
|
|
133
|
+
reach_ids = [210]
|
|
134
|
+
|
|
135
|
+
station_ids = ['H77107001']
|
|
136
|
+
flow_station_id = ['H77107001']
|
|
137
|
+
reach_ids = [350]
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
drng_area = cal.uci.network.drainage_area(reach_ids) #923540.16
|
|
141
|
+
df = cal.compare_simulated_observed(station_ids,reach_ids,constituent,'D')
|
|
142
|
+
|
|
143
|
+
df = cal.compare_wplmn(station_ids,reach_ids,constituent,units)
|
|
144
|
+
metrics.hydro_stats(df.dropna(),drng_area)
|
|
145
|
+
metrics.stats(df.dropna(),units)
|
|
146
|
+
metrics.aggregate(df.dropna(),units)
|
|
147
|
+
|
|
148
|
+
ff.contTimeseries(df,station_ids,constituent,units)
|
|
149
|
+
ff.timeseries(df,station_ids,constituent,units)
|
|
150
|
+
|
|
151
|
+
ff.FDCexceed(df.dropna(),station_ids,constituent,units)
|
|
152
|
+
df_exceed = ff._exceedence(df.dropna())
|
|
153
|
+
for month in df.index.month.unique():
|
|
154
|
+
dfsub = df.loc[df.index.month == month]
|
|
155
|
+
ff._FDCexceed(dfsub.dropna(),station_ids,constituent,units)
|
|
156
|
+
plt.title(month)
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
ff.FDCexceed(dfsub.dropna(),station_ids,constituent,units)
|
|
161
|
+
plt.title(month)
|
|
162
|
+
|
|
163
|
+
def replace_table(uci1,uci2,operation,table_name,table_id):
|
|
164
|
+
table = uci2.table(operation,table_name,table_id,False)
|
|
165
|
+
uci1.replace_table(table,operation,table_name,table_id)
|
|
166
|
+
|
|
167
|
+
for table in ['PWAT-PARM1','PWAT-PARM2','PWAT-PARM3','PWAT-PARM4','MON-UZSN','MON-LZETPARM']:
|
|
168
|
+
replace_table(cal2.uci,cal.uci,'PERLND',table,0)
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
#%%
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
# cal.update_table(.03, 'PERLND','PWAT-PARM3',0,columns = 'BASETP',operator = 'set')
|
|
176
|
+
# cal.update_table(.2, 'PERLND','PWAT-PARM3',0,columns = 'BASETP',opnids = wetland_perlnds,operator = 'set')
|
|
177
|
+
# cal.update_table(.2, 'PERLND','PWAT-PARM3',0,columns = 'BASETP',opnids = forest_perlnds,operator = 'set')
|
|
178
|
+
# cal.update_table(.15, 'PERLND','PWAT-PARM3',0,columns = 'BASETP',opnids = ag_perlnds,operator = 'set')
|
|
179
|
+
|
|
180
|
+
cal.update_table(.8,'PERLND','MON-LZETPARM',0,operator = 'set')
|
|
181
|
+
cal.update_table(.1,'PERLND','MON-LZETPARM',0,columns = ['LZEMAR','LZEJAN','LZEFEB','LZEAPR','LZEMAY','LZEOCT','LZENOV'],operator = 'set')
|
|
182
|
+
|
|
183
|
+
cal.update_table(.1,'PERLND','MON-LZETPARM',0,wetland_perlnds,operator = 'set')
|
|
184
|
+
cal.update_table(.4,'PERLND','MON-LZETPARM',0,wetland_perlnds,operator = 'set',columns = ['LZEMAR','LZEAPR','LZEMAY'])
|
|
185
|
+
cal.update_table(.9,'PERLND','MON-LZETPARM',0,wetland_perlnds,operator = 'set',columns = ['LZEJUN','LZEJUL','LZEAUG'])
|
|
186
|
+
cal.update_table(.4,'PERLND','MON-LZETPARM',0,wetland_perlnds,operator = 'set',columns = ['LZESEP','LZEOCT','LZEDEC'])
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+
cal.update_table(.1,'PERLND','MON-LZETPARM',0,forest_perlnds,operator = 'set')
|
|
190
|
+
cal.update_table(.6,'PERLND','MON-LZETPARM',0,forest_perlnds,operator = 'set',columns = ['LZEMAR','LZEAPR','LZEMAY'])
|
|
191
|
+
cal.update_table(.9,'PERLND','MON-LZETPARM',0,forest_perlnds,operator = 'set',columns = ['LZEJUN','LZEJUL','LZEAUG'])
|
|
192
|
+
cal.update_table(.6,'PERLND','MON-LZETPARM',0,forest_perlnds,operator = 'set',columns = ['LZESEP','LZEOCT','LZEDEC'])
|
|
193
|
+
|
|
194
|
+
|
|
195
|
+
cal.update_table(.1,'PERLND','MON-LZETPARM',0,ag_perlnds,operator = 'set')
|
|
196
|
+
cal.update_table(.4,'PERLND','MON-LZETPARM',0,ag_perlnds,operator = 'set',columns = ['LZEMAR','LZEAPR','LZEMAY'])
|
|
197
|
+
cal.update_table(.9,'PERLND','MON-LZETPARM',0,ag_perlnds,operator = 'set',columns = ['LZEJUN','LZEJUL','LZEAUG'])
|
|
198
|
+
cal.update_table(.4,'PERLND','MON-LZETPARM',0,ag_perlnds,operator = 'set',columns = ['LZESEP','LZEOCT','LZEDEC'])
|
|
199
|
+
|
|
200
|
+
|
|
201
|
+
|
|
202
|
+
cal.update_table(.5,'PERLND','MON-UZSN',0,operator = 'set')
|
|
203
|
+
|
|
204
|
+
cal.update_table(2,'PERLND','MON-UZSN',0,wetland_perlnds,operator = 'set')
|
|
205
|
+
cal.update_table(1,'PERLND','MON-UZSN',0,wetland_perlnds,operator = 'set',columns = ['UZSMAR','UZSAPR','UZSMAY'])
|
|
206
|
+
cal.update_table(1.5,'PERLND','MON-UZSN',0,wetland_perlnds,operator = 'set',columns = ['UZSJUN','UZSJUL','UZSAUG'])
|
|
207
|
+
cal.update_table(1,'PERLND','MON-UZSN',0,wetland_perlnds,operator = 'set',columns = ['UZSSEP','UZSOCT','UZSDEC'])
|
|
208
|
+
|
|
209
|
+
|
|
210
|
+
# cal.update_table(1,'PERLND','MON-UZSN',0,forest_perlnds,operator = 'set')
|
|
211
|
+
# cal.update_table(2,'PERLND','MON-UZSN',0,forest_perlnds,operator = 'set',columns = ['UZSMAR','UZSAPR','UZSMAY'])
|
|
212
|
+
# cal.update_table(4,'PERLND','MON-UZSN',0,forest_perlnds,operator = 'set',columns = ['UZSJUN','UZSJUL','UZSAUG'])
|
|
213
|
+
# cal.update_table(2,'PERLND','MON-UZSN',0,forest_perlnds,operator = 'set',columns = ['UZSSEP','UZSOCT','UZSNOV'])
|
|
214
|
+
|
|
215
|
+
|
|
216
|
+
# cal.update_table(1,'PERLND','MON-UZSN',0,ag_perlnds,operator = 'set')
|
|
217
|
+
# cal.update_table(2,'PERLND','MON-UZSN',0,ag_perlnds,operator = 'set',columns = ['UZSMAR','UZSAPR','UZSMAY'])
|
|
218
|
+
# cal.update_table(4,'PERLND','MON-UZSN',0,ag_perlnds,operator = 'set',columns = ['UZSJUN','UZSJUL','UZSAUG'])
|
|
219
|
+
# cal.update_table(2,'PERLND','MON-UZSN',0,ag_perlnds,operator = 'set',columns = ['UZSSEP','UZSOCT','UZSNOV'])
|
|
220
|
+
|
|
221
|
+
# cal.update_table(1,'PERLND','MON-COVER',0,operator = 'set')
|
|
222
|
+
|
|
223
|
+
# cal.update_table(2,'PERLND','MON-COVER',0,wetland_perlnds,operator = 'set')
|
|
224
|
+
# cal.update_table(.6,'PERLND','MON-COVER',0,wetland_perlnds,operator = 'set',columns = ['COVMAR','COVAPR','COVMAY'])
|
|
225
|
+
# cal.update_table(.9,'PERLND','MON-COVER',0,wetland_perlnds,operator = 'set',columns = ['COVJUN','COVJUL','COVAUG'])
|
|
226
|
+
# cal.update_table(.9,'PERLND','MON-COVER',0,wetland_perlnds,operator = 'set',columns = ['COVSEP','COVOCT','COVDEC'])
|
|
227
|
+
|
|
228
|
+
|
|
229
|
+
# cal.update_table(1,'PERLND','MON-COVER',0,forest_perlnds,operator = 'set')
|
|
230
|
+
# cal.update_table(1,'PERLND','MON-COVER',0,forest_perlnds,operator = 'set',columns = ['COVMAR','COVAPR','COVMAY'])
|
|
231
|
+
# cal.update_table(.9,'PERLND','MON-COVER',0,forest_perlnds,operator = 'set',columns = ['COVJUN','COVJUL','COVAUG'])
|
|
232
|
+
# cal.update_table(2,'PERLND','MON-COVER',0,forest_perlnds,operator = 'set',columns = ['COVSEP','COVOCT','COVEROV'])
|
|
233
|
+
|
|
234
|
+
|
|
235
|
+
# cal.update_table(1,'PERLND','MON-COVER',0,ag_perlnds,operator = 'set')
|
|
236
|
+
# cal.update_table(1,'PERLND','MON-COVER',0,ag_perlnds,operator = 'set',columns = ['COVMAR','COVAPR','COVMAY'])
|
|
237
|
+
# cal.update_table(.9,'PERLND','MON-COVER',0,ag_perlnds,operator = 'set',columns = ['COVJUN','COVJUL','COVAUG'])
|
|
238
|
+
# cal.update_table(.75,'PERLND','MON-COVER',0,ag_perlnds,operator = 'set',columns = ['COVJUN'])
|
|
239
|
+
|
|
240
|
+
|
|
241
|
+
|
|
242
|
+
|
|
243
|
+
|
|
244
|
+
|
|
245
|
+
|
|
246
|
+
|
|
247
|
+
# cal.update_table(.2,'PERLND','MON-INTERCEP',0,operator = 'set')
|
|
248
|
+
|
|
249
|
+
|
|
250
|
+
cal.update_table(.03,'PERLND','MON-INTERCEP',0,wetland_perlnds,operator = 'set')
|
|
251
|
+
cal.update_table(.1,'PERLND','MON-INTERCEP',0,wetland_perlnds,operator = 'set',columns = ['INTMAR','INTAPR','INTMAY'])
|
|
252
|
+
cal.update_table(.3,'PERLND','MON-INTERCEP',0,wetland_perlnds,operator = 'set',columns = ['INTJUN','INTJUL','INTAUG'])
|
|
253
|
+
cal.update_table(.1,'PERLND','MON-INTERCEP',0,wetland_perlnds,operator = 'set',columns = ['INTSEP','INTOCT','INTDEC'])
|
|
254
|
+
|
|
255
|
+
cal.update_table(2,'PERLND','MON-INTERCEP',0,perlnds,operator = '*',columns = ['INTJUL','INTAUG','INTMAY'])
|
|
256
|
+
|
|
257
|
+
|
|
258
|
+
# cal.update_table(.03,'PERLND','MON-INTERCEP',0,wetland_perlnds,operator = 'set')
|
|
259
|
+
# cal.update_table(.04,'PERLND','MON-INTERCEP',0,wetland_perlnds,operator = 'set',columns = ['INTMAR','INTAPR','INTMAY'])
|
|
260
|
+
# cal.update_table(.4,'PERLND','MON-INTERCEP',0,wetland_perlnds,operator = 'set',columns = ['INTJUN','INTJUL','INTAUG'])
|
|
261
|
+
# cal.update_table(.04,'PERLND','MON-INTERCEP',0,wetland_perlnds,operator = 'set',columns = ['INTSEP','INTOCT','INTDEC'])
|
|
262
|
+
|
|
263
|
+
|
|
264
|
+
|
|
265
|
+
# cal.update_table(.03,'PERLND','MON-INTERCEP',0,ag_perlnds,operator = 'set')
|
|
266
|
+
# cal.update_table(.1,'PERLND','MON-INTERCEP',0,ag_perlnds,operator = 'set',columns = ['INTMAR','INTAPR','INTMAY'])
|
|
267
|
+
# cal.update_table(.3,'PERLND','MON-INTERCEP',0,ag_perlnds,operator = 'set',columns = ['INTJUN','INTJUL','INTAUG'])
|
|
268
|
+
# cal.update_table(.1,'PERLND','MON-INTERCEP',0,ag_perlnds,operator = 'set',columns = ['INTSEP','INTOCT','INTDEC'])
|
|
269
|
+
|
|
270
|
+
#%%
|
|
271
|
+
#
|
|
272
|
+
|
|
273
|
+
# df = cal.get_observed_data(station_ids,'Q','cfs','D',sample_flag=False).to_frame()
|
|
274
|
+
# df_sta = pd.DataFrame(data=[[-93.8071635476731, 48.1966267253807, area]],
|
|
275
|
+
# index=df.columns, columns=['lon', 'lat', 'area'])
|
|
276
|
+
# dfs, df_kge = baseflow.separation(df, df_sta, return_kge=True)
|
|
277
|
+
# test = {k:df.resample('D').mean() for k,df in dfs.items()}
|
|
278
|
+
# df = df.resample('D').mean()
|
|
279
|
+
# def plot_baseflow(method):
|
|
280
|
+
# fig,ax = plt.subplots()
|
|
281
|
+
# df.plot(ax = ax)
|
|
282
|
+
# test[method].plot(ax = ax)
|
|
283
|
+
# ax.legend(['Observed Flow','Baseflow Filter'])
|
|
284
|
+
# plt.title(method)
|
|
285
|
+
|
|
286
|
+
#%%
|
|
287
|
+
|
|
288
|
+
station_ids = ['E77069001']
|
|
289
|
+
flow_station_id = ['E77069001']
|
|
290
|
+
reach_ids = [470]
|
|
291
|
+
drng_area = cal.uci.network.drainage_area(470) #923540.16
|
|
292
|
+
perlnds = cal.uci.network.get_opnids('PERLND',550,[210])
|
|
293
|
+
reaches = cal.uci.network.get_opnids('RCHRES',550,[210])
|
|
294
|
+
reaches = cal.uci.network.get_opnids('RCHRES',550)
|
|
295
|
+
|
|
296
|
+
wetland_perlnds = list(cal.uci.opnid_dict['PERLND'].index[cal.uci.opnid_dict['PERLND']['landcover'].isin([0])])
|
|
297
|
+
forest_perlnds = list(cal.uci.opnid_dict['PERLND'].index[cal.uci.opnid_dict['PERLND']['landcover'].isin([2,3,4,5,6,7])])
|
|
298
|
+
ag_perlnds = list(cal.uci.opnid_dict['PERLND'].index[cal.uci.opnid_dict['PERLND']['landcover'].isin([8,10])])
|
|
299
|
+
urban_perlnds = list(cal.uci.opnid_dict['PERLND'].index[cal.uci.opnid_dict['PERLND']['landcover'].isin([1])])
|
|
300
|
+
|
|
301
|
+
|
|
302
|
+
df = cal.compare_simulated_observed(station_ids,reach_ids,constituent,'D',unit = units,wplmn = False)
|
|
303
|
+
|
|
304
|
+
df = cal.compare_simulated_observed(station_ids,reach_ids,constituent,units,
|
|
305
|
+
time_step = 'D', agg_period = 'D',
|
|
306
|
+
flow_station_ids = flow_station_id, sample_flag = sample_flag,
|
|
307
|
+
dropna = False)
|
|
308
|
+
|
|
309
|
+
|
|
310
|
+
|
|
311
|
+
metrics.stats(df.dropna(),units)
|
|
312
|
+
|
|
313
|
+
metrics.hydro_stats(df.dropna(),drng_area)
|
|
314
|
+
cal.model.reports.avg_ann_outflow()
|
|
315
|
+
cal.model.reports.avg_monthly_outflow()
|
|
316
|
+
|
|
317
|
+
cal.save_output(constituent,station_ids,reach_ids,flow_station_id,drng_area)
|
|
318
|
+
|
|
319
|
+
|
|
320
|
+
ff.contTimeseries(df,station_ids,constituent,units)
|
|
321
|
+
|
|
322
|
+
ff.FDCexceed(df.dropna(),station_ids,constituent,units)
|
|
323
|
+
ff.LDC(df.dropna(),station_ids,constituent,units,time_step = 'D')
|
|
324
|
+
ff.timeseries(df,station_ids,constituent,units)
|
|
325
|
+
ff.rating(df.dropna(),station_ids,constituent,units)
|
|
326
|
+
ff.scatter(df.dropna(),station_ids,constituent,units)
|
|
327
|
+
|
|
328
|
+
|
|
329
|
+
#%% Calibratoin Log
|
|
330
|
+
#Run1
|
|
331
|
+
cal.load_model(1)
|
|
332
|
+
|
|
333
|
+
forest_perlnds = list(cal.uci.opnid_dict['PERLND'].index[cal.uci.opnid_dict['PERLND']['landcover'].isin([2,3,4,5,6,7])])
|
|
334
|
+
wetland_perlnds = list(cal.uci.opnid_dict['PERLND'].index[cal.uci.opnid_dict['PERLND']['landcover'].isin([0])])
|
|
335
|
+
|
|
336
|
+
cal.update_table(.5,'PERLND','PWAT-PARM2',0,forest_perlnds,'LZSN',operator = '*')
|
|
337
|
+
|
|
338
|
+
|
|
339
|
+
cal.update_table(.5,'PERLND','PWAT-PARM3',0,forest_perlnds,'BASETP',operator = '*')
|
|
340
|
+
cal.update_table(2,'PERLND','PWAT-PARM3',0,
|
|
341
|
+
opnids = wetland_perlnds,
|
|
342
|
+
columns = 'BASETP',
|
|
343
|
+
operator = '*')
|
|
344
|
+
|
|
345
|
+
|
|
346
|
+
#Run 2
|
|
347
|
+
cal.load_model(2)
|
|
348
|
+
|
|
349
|
+
|
|
350
|
+
#%% Reach 210
|
|
351
|
+
station_ids = ['H77031001']
|
|
352
|
+
flow_station_id = ['H77031001']
|
|
353
|
+
reach_ids = [210]
|
|
354
|
+
|
|
355
|
+
perlnds = list(cal.uci.network.get_opnids('PERLND',210))
|
|
356
|
+
forest_perlnds = cal.uci.opnid_dict['PERLND'].loc[perlnds]
|
|
357
|
+
forest_perlnds = list(forest_perlnds.index[forest_perlnds['landcover'].isin([2,3,4,5,6,7])])
|
|
358
|
+
wetland_perlnds = list(cal.uci.opnid_dict['PERLND'].index[cal.uci.opnid_dict['PERLND']['landcover'].isin([0])])
|
|
359
|
+
|
|
360
|
+
drng_area = cal.uci.network.drainage_area(210)
|
|
361
|
+
df = cal.compare_simulated_observed(station_ids,reach_ids,constituent,units,
|
|
362
|
+
time_step = 'D', agg_period = 'D',
|
|
363
|
+
flow_station_ids = flow_station_id, sample_flag = sample_flag,
|
|
364
|
+
dropna = False)
|
|
365
|
+
metrics.stats(df.dropna(),units)
|
|
366
|
+
#df = df.loc[df.index.year >= 2017]
|
|
367
|
+
metrics.hydro_stats(df.dropna(),drng_area)
|
|
368
|
+
ff.contTimeseries(df,station_ids,constituent,units)
|
|
369
|
+
ff.FDCexceed(df.dropna(),station_ids,constituent,units)
|
|
370
|
+
ff.scatter(df.dropna(),station_ids,constituent,units)
|
|
371
|
+
|
|
372
|
+
ff.timeseries(df,station_ids,constituent,units)
|
|
373
|
+
ff.rating(df.dropna(),station_ids,constituent,units)
|
|
374
|
+
|
|
375
|
+
|
|
376
|
+
cal.save_output(constituent,station_ids,reach_ids,flow_station_id,drng_area)
|
|
377
|
+
|
|
378
|
+
# Calibration
|
|
379
|
+
|
|
380
|
+
perlnds = list(cal.uci.network.get_opnids('PERLND',210))
|
|
381
|
+
#Run1
|
|
382
|
+
cal.update_table(2,'PERLND','MON-UZSN',0,
|
|
383
|
+
opnids = perlnds,
|
|
384
|
+
columns = ['UZSJUL','UZSAUG','UZSSEP'],
|
|
385
|
+
operator = '*')
|
|
386
|
+
cal.update_table(2,'PERLND','MON-UZSN',0,
|
|
387
|
+
opnids = perlnds,
|
|
388
|
+
columns = ['UZSJUL','UZSAUG','UZSSEP'],
|
|
389
|
+
operator = '*')
|
|
390
|
+
#Run2
|
|
391
|
+
cal.update_table(.4,'PERLND','MON-INTERCEP',0,
|
|
392
|
+
columns = ['INTJUL','INTAUG'],
|
|
393
|
+
opnids = forest_perlnds,
|
|
394
|
+
operator = 'set')
|
|
395
|
+
|
|
396
|
+
cal.update_table(.9,'PERLND','MON-LZETPARM',0,
|
|
397
|
+
columns = ['LZEAUG','LZESEP'],
|
|
398
|
+
opnids = forest_perlnds,
|
|
399
|
+
operator = 'set')
|
|
400
|
+
|
|
401
|
+
#Run3
|
|
402
|
+
cal.update_table(.75,'PERLND','PWAT-PARM2',0,
|
|
403
|
+
opnids = perlnds,
|
|
404
|
+
columns = 'LZSN',
|
|
405
|
+
operator = '*')
|
|
406
|
+
#Run4
|
|
407
|
+
cal.update_table(.8,'PERLND','PWAT-PARM4',0,columns = 'LZETP',operator = 'set')
|
|
408
|
+
#run 5
|
|
409
|
+
cal.update_table(.3,'PERLND','MON-INTERCEP',0,columns = ['INTJUL','INTAUG'],opnids = forest_perlnds,operator = 'set')
|
|
410
|
+
cal.update_table(.25,'PERLND','MON-INTERCEP',0,columns = ['INTJUL'],opnids = forest_perlnds,operator = 'set')
|
|
411
|
+
cal.update_table(.15,'PERLND','MON-INTERCEP',0,columns = ['INTMAY','INTSEP'],opnids = forest_perlnds,operator = 'set')
|
|
412
|
+
|
|
413
|
+
#run 6
|
|
414
|
+
cal.update_table(.99,'PERLND','PWAT-PARM4',0,
|
|
415
|
+
opnids = perlnds,
|
|
416
|
+
columns = 'AGWRC',
|
|
417
|
+
operator = 'set')
|
|
418
|
+
|
|
419
|
+
#%% Reach 350
|
|
420
|
+
station_ids = ['H77107001']
|
|
421
|
+
flow_station_id = ['H77107001']
|
|
422
|
+
reach_ids = [350]
|
|
423
|
+
drng_area = cal.uci.network.drainage_area(350)
|
|
424
|
+
perlnds = list(cal.uci.network.get_opnids('PERLND',350,[210]))
|
|
425
|
+
forest_perlnds = cal.uci.opnid_dict['PERLND'].loc[perlnds]
|
|
426
|
+
forest_perlnds = list(forest_perlnds.index[forest_perlnds['landcover'].isin([2,3,4,5,6,7])])
|
|
427
|
+
wetland_perlnds = list(cal.uci.opnid_dict['PERLND'].index[cal.uci.opnid_dict['PERLND']['landcover'].isin([0])])
|
|
428
|
+
|
|
429
|
+
|
|
430
|
+
|
|
431
|
+
df = cal.compare_simulated_observed(station_ids,reach_ids,constituent,units,
|
|
432
|
+
time_step = 'D', agg_period = 'D',
|
|
433
|
+
flow_station_ids = flow_station_id, sample_flag = sample_flag,
|
|
434
|
+
dropna = False)
|
|
435
|
+
metrics.stats(df.dropna(),units)
|
|
436
|
+
|
|
437
|
+
#df = df.loc[df.index.year < 2015]
|
|
438
|
+
metrics.hydro_stats(df.dropna(),drng_area)
|
|
439
|
+
ff.contTimeseries(df,station_ids,constituent,units)
|
|
440
|
+
ff.FDCexceed(df.dropna(),station_ids,constituent,units)
|
|
441
|
+
ff.timeseries(df,station_ids,constituent,units)
|
|
442
|
+
cal.save_output(constituent,station_ids,reach_ids,flow_station_id,drng_area)
|
|
443
|
+
#%%
|
|
444
|
+
# Goal: Reduce total annual sediment for reaches downstream of 210
|
|
445
|
+
perlnds = cal.uci.network.get_opnids('PERLND',550,[210])
|
|
446
|
+
cal.update_table(.5,'PERLND','SED-PARM3',0,columns = 'KSER',opnids = perlnds)
|
|
447
|
+
|
|
448
|
+
|
|
449
|
+
|
|
450
|
+
|
|
451
|
+
order = cal.uci.network.calibration_order(550)
|
|
452
|
+
reach_ids = order[2]
|
|
453
|
+
|
|
454
|
+
for reach_ids in order[18:]:
|
|
455
|
+
df = cal.model.reports.scour()
|
|
456
|
+
df = df.loc[df['LKFG'] == 0]
|
|
457
|
+
positives = df.loc[(df.index.isin(reach_ids)) & (df['depscour'] > 0)].index
|
|
458
|
+
if len(positives)>0:
|
|
459
|
+
print(positives)
|
|
460
|
+
break
|
|
461
|
+
|
|
462
|
+
cal.update_table(1.3,'RCHRES','SILT-CLAY-PM',0,columns = 'M', opnids = positives)
|
|
463
|
+
cal.update_table(1.3,'RCHRES','SILT-CLAY-PM',1,columns = 'M', opnids = positives)
|
|
464
|
+
|
|
465
|
+
|
|
466
|
+
# Negative scours
|
|
467
|
+
df_scour = cal.model.reports.scour()
|
|
468
|
+
negatives = df_scour.loc[df_scour['depscour'] < -700].index
|
|
469
|
+
|
|
470
|
+
cal.update_table(.25,'RCHRES','SILT-CLAY-PM',0,columns = 'M', opnids = negatives)
|
|
471
|
+
cal.update_table(.25,'RCHRES','SILT-CLAY-PM',1,columns = 'M', opnids = negatives)
|
|
472
|
+
|
|
473
|
+
cal.update_table(.25,'RCHRES','SILT-CLAY-PM',0,columns = 'M', opnids = negatives)
|
|
474
|
+
cal.update_table(.25,'RCHRES','SILT-CLAY-PM',1,columns = 'M', opnids = negatives)
|
|
475
|
+
|
|
476
|
+
|
|
477
|
+
|
|
478
|
+
import matplotlib.pyplot as plt
|
|
479
|
+
import numpy as np
|
|
480
|
+
|
|
481
|
+
df = cal.model.reports.runoff().groupby(cal.model.reports.runoff().index.year).sum().mean(axis=0)
|
|
482
|
+
x = df.index.levels[0]
|
|
483
|
+
y1 = df[:,'agwo']
|
|
484
|
+
y2 = df[:,'ifwo']
|
|
485
|
+
y3 = df[:,'suro']
|
|
486
|
+
# plot bars in stack manner
|
|
487
|
+
plt.bar(x, y1, color='g')
|
|
488
|
+
plt.bar(x,y2, bottom=y1, color='y')
|
|
489
|
+
plt.bar(x,y3, bottom=y1+y2, color='b')
|
|
490
|
+
|
|
491
|
+
|
|
492
|
+
df = cal.model.reports.runoff()
|
|
493
|
+
n_years = df.index.year.max()-df.index.year.min()
|
|
494
|
+
df = df.groupby(cal.model.reports.runoff().index.month).sum()/n_years
|
|
495
|
+
df.columns = df.columns.swaplevel(0,1)
|
|
496
|
+
x = df.index
|
|
497
|
+
y1 = df['agwo'].mean(axis=1)
|
|
498
|
+
y2 = df['ifwo'].mean(axis=1)
|
|
499
|
+
y3 = df['suro'].mean(axis=1)
|
|
500
|
+
# plot bars in stack manner
|
|
501
|
+
plt.bar(x, y1, color='g')
|
|
502
|
+
plt.bar(x,y2, bottom=y1, color='y')
|
|
503
|
+
plt.bar(x,y3, bottom=y1+y2, color='b')
|
|
504
|
+
|
|
505
|
+
land_cover = 'Old Decid Forest AB'
|
|
506
|
+
df = cal.model.reports.runoff()
|
|
507
|
+
n_years = df.index.year.max()-df.index.year.min()
|
|
508
|
+
df = df.groupby(cal.model.reports.runoff().index.month).sum()/n_years
|
|
509
|
+
dfsub = df[land_cover]
|
|
510
|
+
x = dfsub.index
|
|
511
|
+
y1 = dfsub.loc[:,'agwo']
|
|
512
|
+
y2 = dfsub.loc[:,'ifwo']
|
|
513
|
+
y3 = dfsub.loc[:,'suro']
|
|
514
|
+
# plot bars in stack manner
|
|
515
|
+
plt.bar(x, y1, color='g')
|
|
516
|
+
plt.bar(x,y2, bottom=y1, color='y')
|
|
517
|
+
plt.bar(x,y3, bottom=y1+y2, color='b')
|
|
518
|
+
|
|
519
|
+
|
|
520
|
+
|
|
521
|
+
station_ids = ['H76033001']
|
|
522
|
+
reach_ids = [290]
|
|
523
|
+
drng_area = cal.uci.network.drainage_area(290)
|
|
524
|
+
|
|
525
|
+
|
|
526
|
+
flow_station_id = None
|
|
527
|
+
constituent = 'Q'
|
|
528
|
+
units = 'cfs'
|
|
529
|
+
df = cal.compare_simulated_observed(station_ids,reach_ids,constituent,units,'D',flow_station_ids = flow_station_id)
|
|
530
|
+
|
|
531
|
+
|
|
532
|
+
|
|
533
|
+
df
|
|
534
|
+
|
|
535
|
+
metrics.monthly()
|
|
536
|
+
|
|
537
|
+
metrics.hydro_stats(df,drng_area)
|
|
538
|
+
metrics.NSE(df)
|
|
539
|
+
|
|
540
|
+
cal.load_model(64)
|
|
541
|
+
|
|
542
|
+
#cal.dm.download_station_data()
|
|
543
|
+
# Set relevant reaches to hourly timeseries.
|
|
544
|
+
cal.initialize([202,213,203,154,117,205,207,158])
|
|
545
|
+
|
|
546
|
+
station_ids = ['H57037001']
|
|
547
|
+
reach_ids = [154]
|
|
548
|
+
drng_area = cal.uci.network.drainage_area(154)
|
|
549
|
+
|
|
550
|
+
station_ids = ['E57028001']
|
|
551
|
+
reach_ids = [117]
|
|
552
|
+
drng_area = 4352000
|
|
553
|
+
|
|
554
|
+
station_ids = ['S007-461']
|
|
555
|
+
reach_ids = [213]
|
|
556
|
+
|
|
557
|
+
station_ids = ['S002-097']
|
|
558
|
+
flow_station_ids = ['E57028001']
|
|
559
|
+
reach_ids = [117]
|
|
560
|
+
constituent = 'N'
|
|
561
|
+
units = 'mg/l'
|
|
562
|
+
filepath = cal.output_path.joinpath(f'{constituent}_{reach_ids[0]}')
|
|
563
|
+
|
|
564
|
+
|
|
565
|
+
df = cal.compare_simulated_observed(station_ids,reach_ids,constituent,units,'D',flow_station_ids = flow_station_id)
|
|
566
|
+
|
|
567
|
+
df['observed_flow'].plot()
|
|
568
|
+
df['simulated_flow'].plot()
|
|
569
|
+
df['simulated'].plot()
|
|
570
|
+
df['observed.plot()']
|
|
571
|
+
|
|
572
|
+
ff.contTimeseries(df,[constituent],units,filepath)
|
|
573
|
+
ff.timeseries(df,station_ids,constituent,units,filepath = cal.output_path.joinpath('test'))
|
|
574
|
+
|
|
575
|
+
|
|
576
|
+
drng_area = cal.uci.network.drainage_area(154)
|
|
577
|
+
df = cal.compare_simulated_observed(['E57028001'],[117],'Q','cfs','D')*60*60*24/43560/drng_area*12
|
|
578
|
+
metrics.hydro_stats(df,drng_area)
|
|
579
|
+
|
|
580
|
+
station_ids = ['S010-822','S004-880','S003-271','S002-103']
|
|
581
|
+
reach_ids = [158]
|
|
582
|
+
len(cal.compare_simulated_observed(station_ids,reach_ids,'TP','mg/l','D')) # 19
|
|
583
|
+
len(cal.compare_simulated_observed(station_ids,reach_ids,'N','mg/l','D')) # 19
|
|
584
|
+
|
|
585
|
+
|
|
586
|
+
station_ids = ['S001-060','S004-881','S001-032']
|
|
587
|
+
reach_ids = [202]
|
|
588
|
+
len(cal.compare_simulated_observed(station_ids,reach_ids,'TP','mg/l','D')) # 105
|
|
589
|
+
len(cal.compare_simulated_observed(station_ids,reach_ids,'N','mg/l','D')) # 88
|
|
590
|
+
|
|
591
|
+
tation_ids = ['S007-461']
|
|
592
|
+
reach_ids = [213]
|
|
593
|
+
df = cal.compare_simulated_observed(station_ids,reach_ids,'TP','mg/l','D') # 106
|
|
594
|
+
ff.scatter(df,station_ids,'TP','mg/l')
|
|
595
|
+
ff.timeseries(df,station_ids,'TP','mg/l')
|
|
596
|
+
len(cal.compare_simulated_observed(station_ids,reach_ids,'N','mg/l','h')) # 89
|
|
597
|
+
|
|
598
|
+
|
|
599
|
+
station_ids = ['S005-322']
|
|
600
|
+
reach_ids = [154]
|
|
601
|
+
|
|
602
|
+
tation_ids = ['S007-461']
|
|
603
|
+
reach_ids = [213]
|
|
604
|
+
|
|
605
|
+
|
|
606
|
+
constituent = 'TP'
|
|
607
|
+
units = 'mg/l'
|
|
608
|
+
df = cal.compare_simulated_observed(station_ids,reach_ids,constituent,units,'D')
|
|
609
|
+
ff.scatter(df,station_ids,constituent,units)
|
|
610
|
+
ff.timeseries(df,station_ids,constituent,units)
|
|
611
|
+
|
|
612
|
+
|
|
613
|
+
len(cal.compare_simulated_observed(station_ids,reach_ids,'N','mg/l','h')) # 57
|
|
614
|
+
len(cal.compare_simulated_observed(station_ids,reach_ids,'TP','mg/l','h')) # 74
|
|
615
|
+
|
|
616
|
+
cal.get_observed_data(station_ids,'N','mg/l','h')
|
|
617
|
+
|
|
618
|
+
df = cal.compare_simulated_observed(station_ids,reach_ids,'TP','mg/l','h')
|
|
619
|
+
#df = cal.compare_simulated_observed(station_ids,reach_ids,'Q','cfs','D')
|
|
620
|
+
df[df<0] = 0
|
|
621
|
+
df.plot()
|
|
622
|
+
cal.aggregate(station_ids,reach_ids,'TSS','mg/l','D').plot()
|
|
623
|
+
|
|
624
|
+
|
|
625
|
+
|
|
626
|
+
cal.dm.download_station_data('E57028001','wiski')
|
|
627
|
+
|
|
628
|
+
station_ids [ 'H76108002','']
|
|
629
|
+
station_ids = ['H49009001']
|
|
630
|
+
station_ids = ['S006-770']
|
|
631
|
+
|
|
632
|
+
|
|
633
|
+
station_id = 'S006-770'
|
|
634
|
+
station_id = 'H49009001'
|
|
635
|
+
cal.dm.get_data(station_id = station_id,constituent = 'WT',unit = 'deg c')
|
|
636
|
+
|
|
637
|
+
cal.save_outputs(station_ids)
|
|
638
|
+
|
|
639
|
+
|
|
640
|
+
# Hydrology
|
|
641
|
+
cal.metrics.hydrology.stats(station_ids)
|
|
642
|
+
cal.metrics.hydrology.nse(station_ids)
|
|
643
|
+
cal.model.reports.runoff()
|
|
644
|
+
# Figures
|
|
645
|
+
cal.figures.hydrology.timeseries(station_ids)
|
|
646
|
+
cal.figures.hydrology.exceedence(station_ids)
|
|
647
|
+
|
|
648
|
+
|
|
649
|
+
|
|
650
|
+
|
|
651
|
+
# Sediment
|
|
652
|
+
cal.metrics.sediment.stats(station_ids,units='mg/l')
|
|
653
|
+
cal.model.reports.scour()
|
|
654
|
+
# Figures
|
|
655
|
+
cal.figures.sediment.timeseries(station_ids,units= 'mg/l')
|
|
656
|
+
cal.figures.sediment.exceedence(station_ids)
|
|
657
|
+
|
|
658
|
+
|
|
659
|
+
|
|
660
|
+
|
|
661
|
+
|
|
662
|
+
cal.MODL_DB[['station_id','true_opnid','name']]
|
|
663
|
+
|
|
664
|
+
|
|
665
|
+
|
|
666
|
+
model = hspfModel(cal.model_path.joinpath('HawkYellowMedicine_0.uci'))
|
|
667
|
+
|
|
668
|
+
|
|
669
|
+
|
|
670
|
+
cal.load_model(0)
|
|
671
|
+
cal.set_dates(start_date = '2013-01-01',
|
|
672
|
+
end_date = '2024-12-31')
|
|
673
|
+
|
|
674
|
+
|
|
675
|
+
|
|
676
|
+
|
|
677
|
+
|
|
678
|
+
precip = cal.model.wdms.series('UpperRed_Met_2022.wdm',111)
|
|
679
|
+
pevt = cal.model.wdms.series('UpperRed_Met_2022.wdm',121)*.6
|
|
680
|
+
df = precip - pevt
|
|
681
|
+
df.resample('Y').plot()
|
|
682
|
+
|
|
683
|
+
plt.plot(precip-pevt)
|
|
684
|
+
|
|
685
|
+
df = cal.model.hbns.get_multiple_timeseries('PERLND','yearly','PERO',activity ='PWATER')
|
|
686
|
+
|
|
687
|
+
df = cal.model.hbns.get_multiple_timeseries('PERLND','yearly','SURO',activity ='PWATER')
|
|
688
|
+
df.sum()/27
|
|
689
|
+
|
|
690
|
+
|
|
691
|
+
|
|
692
|
+
df.groupby('sender').message
|
|
693
|
+
.resample('D').count()
|
|
694
|
+
.unstack('sender')
|
|
695
|
+
.plot()
|
|
696
|
+
)
|
|
697
|
+
|
|
698
|
+
|
|
699
|
+
|
|
700
|
+
precip = cal.model.wdms.series('UpperRed_Met_2022.wdm',101)
|
|
701
|
+
precip = precip.loc[precip.index >= '1996-01-01']
|
|
702
|
+
precip_monthly = precip.resample('MS').sum()
|
|
703
|
+
supy = cal.model.hbns.get_multiple_timeseries('PERLND','monthly','SUPY',activity = 'PWATER')
|
|
704
|
+
prain = cal.model.hbns.get_multiple_timeseries('PERLND','yearly','PRAIN',activity = 'SNOW')
|
|
705
|
+
wyield = cal.model.hbns.get_multiple_timeseries('PERLND','yearly','WYIELD',activity = 'SNOW')
|
|
706
|
+
|
|
707
|
+
|
|
708
|
+
|
|
709
|
+
|
|
710
|
+
|
|
711
|
+
|