pyhcal 1.1.2__py3-none-any.whl → 1.1.4__py3-none-any.whl

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.
pyhcal/calibrators.py CHANGED
@@ -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
 
pyhcal/mappers.py CHANGED
@@ -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):
pyhcal/setup_utils.py CHANGED
@@ -4,9 +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
11
+ from hspf.hspfModel import hspfModel
10
12
  from pyhcal.repository import Repository
11
13
  from mpcaHydro import outlets
12
14
 
@@ -41,7 +43,7 @@ class Builder():
41
43
  self.new_uci = None
42
44
  self.uci = None
43
45
  self.dm = None
44
- self.calibration_reaches = outlets.wplmn_station_opnids(model_name)
46
+ self.calibration_reaches = [abs(opnid) for opnid in outlets.wplmn_station_opnids(model_name)]
45
47
  self.oracle_username = oracle_username
46
48
  self.oracle_password = oracle_password
47
49
 
@@ -113,32 +115,10 @@ class Builder():
113
115
  copy_path.joinpath(wdm_file.name.replace('.wdm','.hdf5').replace('.WDM','hdf5')))
114
116
 
115
117
  def run_model(self, wait_for_completion=True):
116
- #run_model(self.new_uci, wait_for_completion)
117
118
  # Run the uci file
118
- winHSPF = str(Path(__file__).resolve().parent.parent) + '\\bin\\WinHSPFLt\\WinHspfLt.exe'
119
+ winHSPF = hspfModel.winHSPF #TODO: fix this hardcoding
119
120
  subprocess.run([winHSPF,self.new_uci]) #, stdout=subprocess.PIPE, creationflags=0x08000000)
120
121
 
121
- def run_model(uci_file, wait_for_completion=True):
122
- winHSPF = str(Path(__file__).resolve().parent.parent) + '\\bin\\WinHSPFlt\\WinHspfLt.exe'
123
-
124
- # Arguments for the subprocess
125
- args = [winHSPF, uci_file.as_posix()]
126
-
127
- if wait_for_completion:
128
- # Use subprocess.run to wait for the process to complete (original behavior)
129
- subprocess.run(args)
130
- else:
131
- # Use subprocess.Popen to run the process in the background without waiting
132
- # On Windows, you can use creationflags to prevent a console window from appearing
133
- if sys.platform.startswith('win'):
134
- # Use a variable for the flag to ensure it's only used on Windows
135
- creationflags = subprocess.CREATE_NO_WINDOW
136
- subprocess.Popen(args, creationflags=creationflags)
137
- else:
138
- # For other platforms (like Linux/macOS), Popen without special flags works fine
139
- subprocess.Popen(args)
140
-
141
-
142
122
 
143
123
  ### functions for setting up the UCI file properly
144
124
  def setup(uci,name,run = 0,reach_ids = None,n = 1,time_step = 3):
@@ -222,7 +202,6 @@ def setup_binaryinfo(uci,default_output = 4,reach_ids = None):
222
202
  uci.update_table(2,'RCHRES','BINARY-INFO',0,columns = ['HEATPR','HYDRPR'],opnids = reach_ids,operator = 'set')
223
203
  return uci
224
204
 
225
-
226
205
  def setup_qualid(uci):
227
206
  #### Standardize QUAL-ID Names
228
207
  # Perlands
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pyhcal
3
- Version: 1.1.2
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>
@@ -1,12 +1,12 @@
1
1
  pyhcal/ERROR.FIL,sha256=w35iHJYKYpcU9lrmU4FqLGMlKLabOOX-_Z567kHF8CA,5018
2
2
  pyhcal/__init__.py,sha256=4TEpGD-PfEY8yK-od8DpEMA4_iQ-q9y0PBvROXSPdB0,94
3
- pyhcal/calibrators.py,sha256=J_RdArI5FAAiU-tEnvSQxiRtIBv3ol13vOJmb34CuGk,27964
3
+ pyhcal/calibrators.py,sha256=rGtqn1FDgBBVT-y7jWal47AVDZCIQhyC24aXjR2AE60,28117
4
4
  pyhcal/figures.py,sha256=Iu7LaN_i2IuDA_nfxj-a8AkG-FTLZVicJ3-efIs5OiE,45534
5
- pyhcal/mappers.py,sha256=bAeBb-_EbhegPTn4sR4elRyQNrcBpr9CFzNoZcMDng8,5674
5
+ pyhcal/mappers.py,sha256=yRc0mYoe9QSK6Z0e5C0DzEA7UHRr0S3nwsUNzkugDbw,5685
6
6
  pyhcal/metrics.py,sha256=GUGHd-op-g1Foj8wnS_JVURSms4ifcC0a5h8ketQ29I,17911
7
7
  pyhcal/repository.py,sha256=cZfAZRCI99_rhCSHi58_O6pV8aAofXuvQHrao0B5CzI,4606
8
- pyhcal/setup_utils.py,sha256=YyFpOUlyzsJySrnBBnLs3CPLs3al93Mez_H69di4yeo,31145
8
+ pyhcal/setup_utils.py,sha256=aB49tm2Q48FdXvg7p83yK77tGy8wA2b9g6hL9NV7yZo,30177
9
9
  pyhcal/data/HUC_Names.csv,sha256=UGmd3Q5E8DyFWggXzaXWpsRze7sFyrlpYqaYpMWAiGM,18946
10
- pyhcal-1.1.2.dist-info/METADATA,sha256=CNDp8wMXQJNlttSLA9uI_z9zjImiZrY6lRTisF7_3jQ,560
11
- pyhcal-1.1.2.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
12
- pyhcal-1.1.2.dist-info/RECORD,,
10
+ pyhcal-1.1.4.dist-info/METADATA,sha256=EgdrYOn4IxhVeSEt5acNBv-U91BlNC5KwBW_MXUtqyw,560
11
+ pyhcal-1.1.4.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
12
+ pyhcal-1.1.4.dist-info/RECORD,,
File without changes