Skip to content

Commit

Permalink
Merge pull request #166 from timcera/develop
Browse files Browse the repository at this point in the history
Move to single python package "hsp2"
Nice work, thanks @timcera !
  • Loading branch information
PaulDudaRESPEC authored May 24, 2024
2 parents 460f9f7 + a6c1b76 commit 9f542a8
Show file tree
Hide file tree
Showing 91 changed files with 13,786 additions and 6,735 deletions.
10 changes: 5 additions & 5 deletions HSP2_Driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,21 +32,21 @@

if file_ext.upper() == "UCI":
h5_name = filename[:-3] + "h5"
from HSP2tools.readUCI import readUCI
from hsp2.hsp2tools.readUCI import readUCI
readUCI(filename, h5_name)
# readUCI('HSPF.uci', 'test.h5')

if file_ext.upper() == "WDM":
h5_name = filename[:-3] + "h5"
from HSP2tools.readWDM import readWDM
from hsp2.hsp2tools.readWDM import readWDM
readWDM(filename, h5_name)
# readWDM('GRICM.wdm', 'test.h5')
# readWDM('ZUMBROSCEN.WDM', 'test.h5')

if file_ext.upper() == ".H5":
from HSP2.main import main
from HSP2IO.hdf import HDF5
from HSP2IO.io import IOManager
from hsp2.hsp2.main import main
from hsp2.hsp2io.hdf import HDF5
from hsp2.hsp2io.io import IOManager

hdf5_instance = HDF5(filename)
io_manager = IOManager(hdf5_instance)
Expand Down
14 changes: 0 additions & 14 deletions HSP2tools/__init__.py

This file was deleted.

236 changes: 162 additions & 74 deletions examples/1_Intro_to_HSP2.ipynb

Large diffs are not rendered by default.

39 changes: 20 additions & 19 deletions examples/2_ExploreResultsHDF5.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,9 @@
"import os\n",
"from pathlib import Path\n",
"\n",
"import tables # PyTables\n",
"import h5py\n",
"\n",
"import pandas as pd"
"import pandas as pd\n",
"import tables # PyTables"
]
},
{
Expand All @@ -70,7 +69,7 @@
],
"source": [
"# Confirm that your active environment for this notebook is the one you created for HSP2.\n",
"os.environ['CONDA_DEFAULT_ENV']"
"os.environ[\"CONDA_DEFAULT_ENV\"]"
]
},
{
Expand Down Expand Up @@ -113,7 +112,7 @@
"outputs": [],
"source": [
"# Set your project directory to your local folder for your clone of the HSPsquared repository\n",
"project_folder = Path('/Users/aaufdenkampe/Documents/Python/respec.HSPsquared/')"
"project_folder = Path(\"/Users/aaufdenkampe/Documents/Python/respec.HSPsquared/\")"
]
},
{
Expand All @@ -132,16 +131,18 @@
}
],
"source": [
"# use the Path module to construct file path \n",
"# use the Path module to construct file path\n",
"\n",
"output_data_folder = Path('examples/_TutorialData')\n",
"output_data_folder = Path(\"examples/_TutorialData\")\n",
"\n",
"output_file = 'test10.h5' # HSP2 data HDF5 binary file, for all inputs and outputs\n",
"output_file = \"test10.h5\" # HSP2 data HDF5 binary file, for all inputs and outputs\n",
"\n",
"output_hdf5_path = project_folder / output_data_folder / output_file # pathlib concatenation\n",
"output_hdf5_path = (\n",
" project_folder / output_data_folder / output_file\n",
") # pathlib concatenation\n",
"\n",
"print(output_hdf5_path)\n",
"print('File exists? ' + str(output_hdf5_path.exists()) )\n",
"print(\"File exists? \" + str(output_hdf5_path.exists()))\n",
"# The file path should not yet exist. If it does, delete it for this tutorial."
]
},
Expand Down Expand Up @@ -489,7 +490,7 @@
],
"source": [
"# If you know what table you want, you can easily retrieve it with the `pd.read_hdf()` function\n",
"pd.read_hdf(output_hdf5_path, '/TIMESERIES/SUMMARY')"
"pd.read_hdf(output_hdf5_path, \"/TIMESERIES/SUMMARY\")"
]
},
{
Expand Down Expand Up @@ -557,7 +558,7 @@
}
],
"source": [
"pd.read_hdf(output_hdf5_path, '/CONTROL/GLOBAL')"
"pd.read_hdf(output_hdf5_path, \"/CONTROL/GLOBAL\")"
]
},
{
Expand All @@ -567,7 +568,7 @@
"metadata": {},
"outputs": [],
"source": [
"ts_hydrology = pd.read_hdf(output_hdf5_path, '/RESULTS/RCHRES_R005/HYDR')"
"ts_hydrology = pd.read_hdf(output_hdf5_path, \"/RESULTS/RCHRES_R005/HYDR\")"
]
},
{
Expand Down Expand Up @@ -10197,7 +10198,7 @@
],
"source": [
"for key in h5py_file.keys():\n",
" print(key)"
" print(key)"
]
},
{
Expand All @@ -10218,7 +10219,7 @@
}
],
"source": [
"h5py_file['CONTROL'].keys()"
"h5py_file[\"CONTROL\"].keys()"
]
},
{
Expand All @@ -10239,7 +10240,7 @@
}
],
"source": [
"h5py_file['CONTROL']['GLOBAL'].keys()"
"h5py_file[\"CONTROL\"][\"GLOBAL\"].keys()"
]
},
{
Expand Down Expand Up @@ -10353,7 +10354,7 @@
"source": [
"for name in h5py_file:\n",
" for subname in h5py_file[name]:\n",
" print(name+r'\\ '+subname)\n",
" print(name + r\"\\ \" + subname)\n",
"# print(r'')\n",
"# for subsubname in h5py_file[name][subname]:\n",
"# print(name+r'\\ '+subname+r'\\ '+subsubname)"
Expand Down Expand Up @@ -10446,7 +10447,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "Python 3.8.12 ('hsp2_py38')",
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
Expand All @@ -10460,7 +10461,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.12"
"version": "3.10.14"
},
"toc-autonumbering": true,
"vscode": {
Expand Down
3,919 changes: 3,852 additions & 67 deletions examples/3_DataVisualizationDemo.ipynb

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions examples/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
import HSP2
__version__ = HSP2.__version__
from hsp2 import hsp2
__version__ = hsp2.__version__
6 changes: 3 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ test = ["pytest", "pytest-cov"]
dev = ["hsp2[test]"]

[project.scripts]
hsp2 = "HSP2tools.HSP2_CLI:main"
hsp2 = "hsp2.hsp2tools.HSP2_CLI:main"

[project.urls]
documentation = "http://www.respec.com/product/hydrologic-simulation-program-python-hsp%C2%B2/"
Expand All @@ -67,7 +67,7 @@ readme = {file = "README.rst"}
version = {file = "VERSION"}

[tool.setuptools.packages.find]
include = ["HSP2*"]
where = ["src"]

[tool.setuptools.package-data]
"HSP2tools.data" = ["*"]
"hsp2.hsp2tools.data" = ["*"]
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion HSP2/ADCALC.py → src/hsp2/hsp2/ADCALC.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

from numpy import zeros, array
from numba import njit
from HSP2.utilities import make_numba_dict
from hsp2.hsp2.utilities import make_numba_dict

# The clean way to get calculated data from adcalc() into advert() is to use a closure.
# This is not currently supported by Numba.
Expand Down
4 changes: 2 additions & 2 deletions HSP2/ATEMP.py → src/hsp2/hsp2/ATEMP.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@

from numba import njit
from numpy import empty, zeros, int64
from HSP2.utilities import hoursval, make_numba_dict, LAPSE
from hsp2.hsp2.utilities import hoursval, make_numba_dict, LAPSE

from HSP2IO.protocols import SupportsReadTS, Category
from hsp2.hsp2io.protocols import SupportsReadTS, Category

ERRMSGS = ()

Expand Down
4 changes: 2 additions & 2 deletions HSP2/CONS.py → src/hsp2/hsp2/CONS.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
'''

from numpy import zeros
from HSP2.ADCALC import advect
from hsp2.hsp2.ADCALC import advect
from numba import njit
from HSP2.utilities import make_numba_dict, initm
from hsp2.hsp2.utilities import make_numba_dict, initm

ERRMSG = []

Expand Down
4 changes: 2 additions & 2 deletions HSP2/COPY.py → src/hsp2/hsp2/COPY.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from HSP2.utilities import get_timeseries
from hsp2.hsp2.utilities import get_timeseries
import pandas as pd
from typing import List, Dict

from HSP2IO.protocols import SupportsReadTS
from hsp2.hsp2io.protocols import SupportsReadTS

class Copy():
"""
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions HSP2/GQUAL.py → src/hsp2/hsp2/GQUAL.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
from numpy import array, zeros, int64
from numba import njit
from math import exp
from HSP2.utilities import initm, make_numba_dict, hoursval, dayval
from HSP2.ADCALC import advect, oxrea
from hsp2.hsp2.utilities import initm, make_numba_dict, hoursval, dayval
from hsp2.hsp2.ADCALC import advect, oxrea

ERRMSGS =('GQUAL: one or more gquals are sediment-associated, but section sedtrn not active', #ERRMSG0
'GQUAL: simulation of photolysis requires aux1fg to be on to calculate average depth', #ERRMSG1
Expand Down
4 changes: 2 additions & 2 deletions HSP2/HTRCH.py → src/hsp2/hsp2/HTRCH.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@
END IF
'''

from HSP2.ADCALC import advect
from hsp2.hsp2.ADCALC import advect
from numpy import zeros, full, float64, int64
from numba import njit
from HSP2.utilities import make_numba_dict, hourflag, hoursval, initm
from hsp2.hsp2.utilities import make_numba_dict, hourflag, hoursval, initm


# METRIC LAPSE DATA
Expand Down
8 changes: 4 additions & 4 deletions HSP2/HYDR.py → src/hsp2/hsp2/HYDR.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
from math import sqrt, log10
from numba import njit, types
from numba.typed import List
from HSP2.utilities import initm, make_numba_dict
from hsp2.hsp2.utilities import initm, make_numba_dict

# the following imports added by rb to handle dynamic code and special actions
from HSP2.state import hydr_get_ix, hydr_init_ix
from HSP2.om import pre_step_model, step_model, model_domain_dependencies
from hsp2.hsp2.state import hydr_get_ix, hydr_init_ix
from hsp2.hsp2.om import pre_step_model, step_model, model_domain_dependencies
from numba.typed import Dict


Expand Down Expand Up @@ -140,7 +140,7 @@ def hydr(io_manager, siminfo, uci, ts, ftables, state):
if (hsp2_local_py != False):
from hsp2_local_py import state_step_hydr
else:
from HSP2.state_fn_defaults import state_step_hydr
from hsp2.hsp2.state_fn_defaults import state_step_hydr
# initialize the hydr paths in case they don't already reside here
hydr_init_ix(state, state['domain'])
# must split dicts out of state Dict since numba cannot handle mixed-type nested Dicts
Expand Down
2 changes: 1 addition & 1 deletion HSP2/IQUAL.py → src/hsp2/hsp2/IQUAL.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from math import exp
from numpy import zeros, where, full, float64, int64
from numba import njit
from HSP2.utilities import initm, make_numba_dict, hourflag, initmdiv
from hsp2.hsp2.utilities import initm, make_numba_dict, hourflag, initmdiv


''' DESIGN NOTES
Expand Down
2 changes: 1 addition & 1 deletion HSP2/IWATER.py → src/hsp2/hsp2/IWATER.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from numpy import zeros, ones, full, nan, int64, float64
from math import sqrt
from numba import njit
from HSP2.utilities import hourflag, hoursval, initm, make_numba_dict
from hsp2.hsp2.utilities import hourflag, hoursval, initm, make_numba_dict

MAXLOOPS = 100 # newton method max steps
TOLERANCE = 0.01 # newton method exit tolerance
Expand Down
2 changes: 1 addition & 1 deletion HSP2/IWTGAS.py → src/hsp2/hsp2/IWTGAS.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

from numpy import zeros, where, full, float64, int64
from numba import njit
from HSP2.utilities import initm, make_numba_dict, hourflag
from hsp2.hsp2.utilities import initm, make_numba_dict, hourflag

ERRMSG = []

Expand Down
8 changes: 4 additions & 4 deletions HSP2/NUTRX_Class.py → src/hsp2/hsp2/NUTRX_Class.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
import numba as nb
from numba.experimental import jitclass

from HSP2.ADCALC import advect
from HSP2.RQUTIL import sink, decbal, benth
from HSP2.OXRX_Class import OXRX_Class
from HSP2.utilities import make_numba_dict, initm
from hsp2.hsp2.ADCALC import advect
from hsp2.hsp2.RQUTIL import sink, decbal, benth
from hsp2.hsp2.OXRX_Class import OXRX_Class
from hsp2.hsp2.utilities import make_numba_dict, initm

spec = [
('adnh4', nb.float64[:]),
Expand Down
6 changes: 3 additions & 3 deletions HSP2/OXRX_Class.py → src/hsp2/hsp2/OXRX_Class.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
from numba.experimental import jitclass
from math import exp

from HSP2.ADCALC import advect, oxrea
from HSP2.RQUTIL import sink
from HSP2.utilities import make_numba_dict
from hsp2.hsp2.ADCALC import advect, oxrea
from hsp2.hsp2.RQUTIL import sink
from hsp2.hsp2.utilities import make_numba_dict

spec = [
('AFACT', nb.float64),
Expand Down
4 changes: 2 additions & 2 deletions HSP2/PHCARB_Class.py → src/hsp2/hsp2/PHCARB_Class.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
from numba.experimental import jitclass
from math import log10

from HSP2.ADCALC import advect
from HSP2.RQUTIL import benth
from hsp2.hsp2.ADCALC import advect
from hsp2.hsp2.RQUTIL import benth

spec = [
('alk', nb.float64),
Expand Down
10 changes: 5 additions & 5 deletions HSP2/PLANK_Class.py → src/hsp2/hsp2/PLANK_Class.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
import numba as nb
from numba.experimental import jitclass

from HSP2.ADCALC import advect
from HSP2.OXRX_Class import OXRX_Class
from HSP2.NUTRX_Class import NUTRX_Class
from HSP2.RQUTIL import sink, decbal
from HSP2.utilities import make_numba_dict, initm
from hsp2.hsp2.ADCALC import advect
from hsp2.hsp2.OXRX_Class import OXRX_Class
from hsp2.hsp2.NUTRX_Class import NUTRX_Class
from hsp2.hsp2.RQUTIL import sink, decbal
from hsp2.hsp2.utilities import make_numba_dict, initm

if os.environ.get("NUMBA_DISABLE_JIT", 0): # jit should be on by default.
OXRX_Class_ = OXRX_Class
Expand Down
2 changes: 1 addition & 1 deletion HSP2/PQUAL.py → src/hsp2/hsp2/PQUAL.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from math import exp
from numpy import zeros, where, full, float64, int64
from numba import njit
from HSP2.utilities import initm, make_numba_dict, hourflag, initmdiv
from hsp2.hsp2.utilities import initm, make_numba_dict, hourflag, initmdiv

''' DESIGN NOTES
Each constituent will be in its own subdirectory in the HDF5 file.
Expand Down
2 changes: 1 addition & 1 deletion HSP2/PSTEMP.py → src/hsp2/hsp2/PSTEMP.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

from numpy import zeros, where, ones, float64, full, int64
from numba import njit
from HSP2.utilities import hoursval, initm, make_numba_dict
from hsp2.hsp2.utilities import hoursval, initm, make_numba_dict


ERRMSG = ['SLTMP temperature less than -100C', # MSG0
Expand Down
Loading

0 comments on commit 9f542a8

Please sign in to comment.