Create an initial, ready-to-run calibration setup of a MIKE SHE model in OSTRICH or PEST.
This includes:
- Writing template files (*.she, *.mhydro, *.uzs, *.etv)
- Writing a forward model bash script
- Writing script for calculating model performance
- Writing control file for OSTRICH or PEST
mikecalsetup parameterizes the nested header file format (pfs files: https://docs.mikepoweredbydhi.com/core_libraries/pfs/pfs-file-content/) found in the MIKE SHE files she, hydro, uzs and etv. To parameterize the MIKE SHE data file system (dfs) format (https://docs.mikepoweredbydhi.com/core_libraries/dfs/dfs-file-system/), the reader is referred to the PstFrom module of pyEMU (https://github.com/pypest/pyemu). A short example of the combination of mikecalsetup with pyEMU is given in the examples folder.
The easiest way to install mikecalsetup with all dependencies is to create an environment using the file mike.yml.
conda env create -f mike.yml
Alternatively, use the package manager pip to install mikecalsetup. Download the package and run "pip install ." in the folder with the setup file.
cd mikecalsetup directory
pip install .
A short example of usage is given in the following. The jupyter notebooks in the examples folder provides a more complete overview of how to use this tool.
import mikecalsetup
# extract all relevant information from model
mod_nme = 'Karup_basic0' # name of model (no extension)
pth = '.\\test\\example_models\\Karup\\Karup_Basic' # relative path to model
setup = mikecalsetup.Setup(mod_nme, pth)
# constrain the number of processes that are parameterized with the par_from variable
setup = mikecalsetup.Setup(mod_nme, pth, par_from=['ol', 'sz', 'uz', 'river']) # possibilites ['lu', 'ol', 'sz', 'uz', 'river']
# check that path to mike she installation is correct
setup.mzpath
# parameters are specified in the par dataframe
par = setup.par
par_nme = par.index.to_list()
# drop parameters not needed for the calibration
drop_par = ['ol_InitialWaterDepth', 'sz_Drainage_Level']
par_nme = [nme for nme in par_nme if nme not in drop_par]
par = par.loc[par_nme]
# set transform ['none', 'fixed', 'tied'],
group = [nme for nme in par_nme if nme.startswith('riv')]
par.loc[group[0], 'transform'] = 'none'
par.loc[group[1:], 'transform'] = 'tied'
par.loc[group[1:], 'tied_to'] = group[0]
par.loc['ol_Manning', 'transform'] = 'fixed'
par.loc['ol_Manning', 'value'] = 2.5
# set upper and lower bounds
group = [nme for nme in par_nme if nme.endswith('HydrGenuchten_Ks')]
par.loc[group, ['lower', 'upper']] = 0.39, 0.46
# assign parameter dataframe back to class
setup.par = par
# assign needed statistics to observation-simulation pairs
results = setup.results
results['stats'] = 'fbal, nse' # possibilities = rmse, kge, nse, pcc, fbal delimited with comma
# write files based on setup
setup.write_files()
A collection of tests are developed using unittest. The test script is located in the test folder along with MIKE SHE example model setups. To run tests locally and get coverage report:
conda activate mike
cd to mikecalsetup directory
python -m unittest discover -v
python -m coverage report
python -m coverage html
Please do not hesitate to contact me directly if you need more information to apply the tool, find a bug, have ideas for extending the functionality. If you wish to contribute, please fork the mikecalsetup repository on GitHub, clone, and develop your modifications on a branch. Then submit a pull request.