pyhcal 1.0.0__tar.gz → 1.0.2__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.
@@ -0,0 +1,3 @@
1
+ *.pyc
2
+ *.whl
3
+ *.gz
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pyhcal
3
- Version: 1.0.0
3
+ Version: 1.0.2
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>
@@ -12,4 +12,6 @@ Classifier: Programming Language :: Python
12
12
  Requires-Python: >=3.8
13
13
  Requires-Dist: geopandas
14
14
  Requires-Dist: hspf
15
+ Requires-Dist: matplotlib
15
16
  Requires-Dist: mpcahydro
17
+ Requires-Dist: scipy
@@ -5,11 +5,13 @@ 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.0.0"
8
+ version = "1.0.2"
9
9
  dependencies = [
10
10
  "hspf",
11
11
  "mpcaHydro",
12
- "geopandas"
12
+ "geopandas",
13
+ "scipy",
14
+ "matplotlib"
13
15
  ]
14
16
  requires-python = ">=3.8"
15
17
  authors = [
@@ -25,4 +27,9 @@ keywords = ["HSPF","Hydrology"]
25
27
  classifiers = [
26
28
  "Development Status :: 3 - Alpha",
27
29
  "Programming Language :: Python"
30
+ ]
31
+
32
+ [tool.hatch.build]
33
+ exclude = [
34
+ "/tests"
28
35
  ]
@@ -17,9 +17,9 @@ import numpy as np
17
17
  from pathlib import Path
18
18
 
19
19
  #My packages
20
- from pyhspf.hspfModel import hspfModel
21
- from pyhspf.wdm import wdmInterface
22
- from pyhspf import helpers
20
+ from hspf.hspfModel import hspfModel
21
+ from hspf.wdm import wdmInterface
22
+ from hspf import helpers
23
23
  from mpcaHydro import data_manager as dm
24
24
  from pyhcal import metrics
25
25
  from pyhcal import figures
@@ -271,7 +271,34 @@ class calibrator:
271
271
 
272
272
  return df_agg
273
273
 
274
- def landcover(self,constituent):
274
+ def landcover(cal,constituent,ref_landcover = None):
275
+ def normalize_group(group, ref_landcover):
276
+ if ref_landcover in group['LSID'].to_list():
277
+ ref_value = group.loc[group['LSID'] == ref_landcover, 'mean'].values[0]
278
+ group['mean_norm'] = group['mean'] / ref_value
279
+ else:
280
+ group['mean_norm'] = pd.NA
281
+ return group
282
+
283
+ if ref_landcover is None:
284
+ ref_landcover = cal.targets['uci_name'][cal.targets['dom_lc']==1].values[0]
285
+
286
+ df = cal.model.hbns.get_perlnd_data(constituent)*2000 #tons/ac/yr to lbs/acr/year
287
+ df = df[(df.index >= cal.start_date) & (df.index <= cal.end_date)]
288
+ df = df.mean().rename('mean').to_frame()
289
+ df = pd.merge(df, cal.uci.opnid_dict['PERLND'], left_index = True,right_on='TOPFST', how='inner')
290
+ df_normalized = pd.concat([normalize_group(group, ref_landcover) for _, group in list(df.groupby('metzone'))])
291
+
292
+ targets = cal.targets.set_index('uci_name')[constituent]
293
+ targets = targets/targets.loc[ref_landcover]
294
+
295
+ df_normalized['target'] = targets.loc[df_normalized['LSID']].values/df_normalized['mean_norm']
296
+ df_normalized = df_normalized.fillna(1) #don't make any changes to 0 concentration perlands
297
+ return df_normalized
298
+
299
+
300
+
301
+ def landcover_legacy(self,constituent):
275
302
  perlnd_names = self.model.uci.table('PERLND','GEN-INFO')['LSID']
276
303
  df = self.model.hbns.get_perlnd_data(constituent)*2000 #tons/ac/yr to lbs/acr/year
277
304
  df = df[(df.index >= self.start_date) & (df.index <= self.end_date)]
@@ -11,7 +11,7 @@ from pathlib import Path
11
11
  import shutil
12
12
 
13
13
 
14
- DEFUALT_REPOSITORY_PATH = Path('X:\Databases2\Water_Quality\Watershed_Modeling\MPCA_HSPF_Model_Repository') #could point to the github website if it becomes public?
14
+ DEFUALT_REPOSITORY_PATH = Path('X:/Databases2/Water_Quality/Watershed_Modeling/MPCA_HSPF_Model_Repository') #could point to the github website if it becomes public?
15
15
 
16
16
  class Repository():
17
17
 
@@ -5,8 +5,8 @@ Created on Wed Jun 15 15:21:35 2022
5
5
  @author: mfratki
6
6
  """
7
7
  from mpcaHydro.data_manager import dataManager
8
- from pyhspf.wdmReader import readWDM
9
- from pyhspf.uci import UCI
8
+ from hspf.wdmReader import readWDM
9
+ from hspf.uci import UCI
10
10
  from pyhcal.repository import Repository
11
11
 
12
12
  import numpy as np
pyhcal-1.0.0/.gitignore DELETED
@@ -1 +0,0 @@
1
- *.pyc
File without changes
File without changes
File without changes
File without changes
File without changes