pyhcal 1.1.3__tar.gz → 1.1.4__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pyhcal
3
- Version: 1.1.3
3
+ Version: 1.1.4
4
4
  Summary: Python package for calibrating MPCA HSPF models
5
5
  Project-URL: Homepage, https://github.com/mfratkin1/pyhcal
6
6
  Author-email: Mulu Fratkin <michael.fratkin@state.mn.us>
pyhcal-1.1.4/demo.py ADDED
@@ -0,0 +1,52 @@
1
+ #%%
2
+ from pyhcal.calibrators import calibrator
3
+ from pyhcal import metrics
4
+ from pyhcal import figures
5
+ #%%
6
+ cal = calibrator('C:/Users/mfratki/Documents/Calibrations/Nemadji')
7
+ cal.load_model(0)
8
+
9
+ # %% Outlets
10
+
11
+ cal.get_outlets()
12
+
13
+ station_ids = ['S007-571', 'W28068001', 'S005-671', 'S008-051', 'S012-414']
14
+ reach_ids = [417]
15
+
16
+ df = cal.compare_simulated_observed(station_ids,reach_ids,'WT','h')
17
+ #
18
+
19
+ figures.contTimeseries(df.dropna(subset=['observed']),station_ids,'WT','degf')
20
+
21
+
22
+ #%% Mapping
23
+ cal.mapper.map_parameter('PERLND',
24
+ 'PWAT-PARM2',
25
+ 'LZSN')
26
+ cal.mapper.map_parameter('PERLND',
27
+ 'PWAT-PARM2',
28
+ 'LZSN',
29
+ weight_by_area=False)
30
+
31
+ cal.mapper.map_output('PERLND','PERO')
32
+
33
+ #%% Reports
34
+
35
+ # loading at catchment and watershed
36
+ cal.reports
37
+
38
+
39
+ # Total amount of constituent contributed from the landscape to channels
40
+
41
+ cal.model.reports.contributions('Q',630)
42
+
43
+
44
+ cal.model.reports.landcover_contributions('Q',417)
45
+
46
+
47
+
48
+ #%% Data
49
+
50
+ cal.dm.constituent_summary('Q','h')
51
+ cal.dm.reports.outlet_summary()
52
+
@@ -0,0 +1,8 @@
1
+ 2026-02-04 16:48:27.489460 starting: opening PstFrom.log for logging
2
+ 2026-02-04 16:48:27.489629 starting PstFrom process
3
+ 2026-02-04 16:48:27.489740 starting: setting up dirs
4
+ 2026-02-04 16:48:27.489948 starting: removing existing new_d 'C:\Users\mfratki\Documents\Projects\Tests\Nemadji\pest'
5
+ 2026-02-04 16:48:27.492489 finished: removing existing new_d 'C:\Users\mfratki\Documents\Projects\Tests\Nemadji\pest' took: 0:00:00.002541
6
+ 2026-02-04 16:48:27.492551 starting: copying original_d 'C:\Users\mfratki\Documents\Projects\Tests\Nemadji\model' to new_d 'C:\Users\mfratki\Documents\Projects\Tests\Nemadji\pest'
7
+ 2026-02-04 16:48:27.919204 finished: copying original_d 'C:\Users\mfratki\Documents\Projects\Tests\Nemadji\model' to new_d 'C:\Users\mfratki\Documents\Projects\Tests\Nemadji\pest' took: 0:00:00.426653
8
+ 2026-02-04 16:48:27.920766 finished: setting up dirs took: 0:00:00.431026
@@ -5,7 +5,7 @@ build-backend = "hatchling.build"
5
5
  [project]
6
6
  name = "pyhcal"
7
7
  urls = { "Homepage" = "https://github.com/mfratkin1/pyhcal" } # ? Add this!
8
- version = "1.1.3"
8
+ version = "1.1.4"
9
9
  dependencies = [
10
10
  "hspf",
11
11
  "mpcaHydro",
@@ -159,7 +159,8 @@ class calibrator:
159
159
  outlets[int(outlet_id)] = {}
160
160
  df_outlet = df.loc[df['outlet_id'] == outlet_id]
161
161
  outlets[int(outlet_id)]['station_ids'] = list(set(df_outlet['station_id']))
162
- outlets[int(outlet_id)]['reach_ids'] = list(set(df_outlet['reach_id']))
162
+ outlets[int(outlet_id)]['reach_ids'] = list([int(reach_id) for reach_id in set(df_outlet['reach_id'])])
163
+ outlets[int(outlet_id)]['true_reach_id'] = list([int(reach_id) for reach_id in set(df_outlet['reach_id'])])
163
164
  outlets[int(outlet_id)]['model_name'] = df_outlet['repository_name'].iloc[0]
164
165
  return outlets
165
166
 
@@ -47,7 +47,7 @@ class uciMapper():
47
47
  tables = [mapper.join_table(operation,table_name,table_id) for mapper in self.mappers]
48
48
  table = pd.concat(tables)
49
49
  return table
50
-
50
+
51
51
  class Mapper():
52
52
  def __init__(self,model_name,uci,subwatershed_gdf,hbn = None):
53
53
  self.model_name = model_name
@@ -63,7 +63,7 @@ class Mapper():
63
63
 
64
64
  def map_parameter(self,operation,table_name,parameter,table_id=0,weight_by_area = True):
65
65
  fig, ax = plt.subplots()
66
- self.join_table(operation,table_name,parameter,table_id).plot(column = parameter,ax = ax,cmap='viridis',legend=True)
66
+ self.join_table(operation,table_name,parameter,table_id,weight_by_area).plot(column = parameter,ax = ax,cmap='viridis',legend=True)
67
67
  plt.title(parameter)
68
68
 
69
69
  def join_table(self,operation,table_name,parameter,table_id=0,weight_by_area = True):
@@ -4,10 +4,11 @@ Created on Wed Jun 15 15:21:35 2022
4
4
 
5
5
  @author: mfratki
6
6
  """
7
+ from operator import mod
7
8
  from mpcaHydro.data_manager import dataManager
8
9
  from hspf.wdmReader import readWDM
9
10
  from hspf.uci import UCI
10
- from hpsf.hspfModel import hspfModel
11
+ from hspf.hspfModel import hspfModel
11
12
  from pyhcal.repository import Repository
12
13
  from mpcaHydro import outlets
13
14
 
@@ -42,7 +43,7 @@ class Builder():
42
43
  self.new_uci = None
43
44
  self.uci = None
44
45
  self.dm = None
45
- self.calibration_reaches = outlets.wplmn_station_opnids(model_name)
46
+ self.calibration_reaches = [abs(opnid) for opnid in outlets.wplmn_station_opnids(model_name)]
46
47
  self.oracle_username = oracle_username
47
48
  self.oracle_password = oracle_password
48
49
 
@@ -201,7 +202,6 @@ def setup_binaryinfo(uci,default_output = 4,reach_ids = None):
201
202
  uci.update_table(2,'RCHRES','BINARY-INFO',0,columns = ['HEATPR','HYDRPR'],opnids = reach_ids,operator = 'set')
202
203
  return uci
203
204
 
204
-
205
205
  def setup_qualid(uci):
206
206
  #### Standardize QUAL-ID Names
207
207
  # Perlands
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes