GithubHelp home page GithubHelp logo

uw-hydro / pysumma Goto Github PK

View Code? Open in Web Editor NEW
14.0 3.0 18.0 71.44 MB

Python module for managing SUMMA simulations

License: BSD 3-Clause "New" or "Revised" License

Fortran 6.65% Python 23.53% Jupyter Notebook 69.76% Shell 0.05%

pysumma's Introduction

pysumma

pysumma Links & Badges
pysumma Tutorial Binder
pysumma Documentation Documentation Status
Travis-CI Build Build Status

pysumma is a Python wrapper for manipulating, running, managing, and analyzing of SUMMA (Structure for Unifying Multiple Modeling Alternatives)

pysumma provides methods for:

  • Running SUMMA
  • Modifying SUMMA input files
  • Automatically parallelizing distributed and sensitivity analysis type experiments
  • Calibration via OSTRICH
  • Visualizing output

Installation

pysumma can be installed from either conda or pip. Installation using conda is preferred, because it will also install a compatible version of SUMMA.

To install via conda use:

conda install -c conda-forge pysumma

To install via pip use:

pip install pysumma

Dependencies

A conda environment is available for management of pysumma's dependencies. You can create your own environment from this file by running:

conda env create -f environment.yml

Then, you can activate this environment with conda activate pysumma. Before installing pysumma into this environment you may also wish to install it as a kernel in your Jupyter environments. This can be accomplished by running:

python -m ipykernel install --user --name=pysumma

With this environment active you can install pysumma this environment with the instructions below.

Installing pysumma from source

Installing pysumma from source can be useful for developing new features. This can be accomplished by running:

git clone https://github.com/UW-Hydro/pysumma.git
cd pysumma
python setup.py develop

Additional SUMMA References

  • Document : SUMMA documentation is available online and remains a work in progress.
  • Source Code : NCAR github

Bugs

Our issue tracker is at https://github.com/UW-Hydro/pysumma/issues. Please report any bugs that you find. Or, even better, fork the repository on GitHub and create a pull request. All changes are welcome, big or small, and we will help you make the pull request if you are new to git (just ask on the issue).

How to run pySUMMA on HydroShare

(Link YouTube: https://www.youtube.com/watch?v=pL-LNd474Tw)

  1. log in HydoShare(https://www.hydroshare.org)
  2. Start CUAHSI JupyterHub from APPS menu on HydroShare(https://www.hydroshare.org/apps/)
  3. Open "Welcome.ipynb" to download pySUMMA resources from HydroShare
  • run the code "1.How to connect with HydroShare"
  • change the code from "resid = os.environ['HS_RES_ID']" to "resid = 'c1bb4a12bff44bf08c5958cba7947348'".
  1. You can see the list of Jupyter Notebooks and click one of Jupyter Notebook.
  2. Run one of Jupyter Notebooks.

pysumma's People

Contributors

arbennett avatar bartnijssen avatar davecasson avatar edward-morgan avatar jsadler2 avatar lukeydchoi avatar mks7ad avatar synapticarbors avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

pysumma's Issues

Creating a new model instance prints unwanted output

Creating a new simulation object as follows:

# Define location of .exe and file manager
executable = '/usr/local/bin/summa.exe'
file_manager = '/home/jovyan/data/pbhm-exercise-2/settings/mizoguchi/summa_fileManager_mizoguchi.txt'

# Create a model instance
s = ps.Simulation(executable, file_manager)

Generates the following output printed to the screen:

/home/jovyan/data/pbhm-exercise-2/settings/mizoguchi/ ../GENPARM.TBL

Contents of the file manager file:

controlVersion                       'SUMMA_FILE_MANAGER_V3.0.0'
simStartTime                         '2000-01-01 00:01'
simEndTime                           '2000-01-03 12:00'
tmZoneInfo                           'localTime'
settingsPath                         '/home/jovyan/data/pbhm-exercise-2/settings/mizoguchi/'
forcingPath                          '/home/jovyan/data/pbhm-exercise-2/data/mizoguchi/'
outputPath                           '/home/jovyan/data/pbhm-exercise-2/output/mizoguchi/'
decisionsFile                        'summa_zDecisions_mizoguchi.txt'
outputControlFile                    '../Model_Output.txt'
globalHruParamFile                   'summa_zLocalParamInfo.txt'
globalGruParamFile                   'summa_zBasinParamInfo.txt'
attributeFile                        'summa_zLocalAttributes.nc'
trialParamFile                       'summa_zParamTrial_mizoguchi.nc'
forcingListFile                      'summa_zForcingFileList.txt'
initConditionFile                    'summa_zInitialCond_mizoguchi.nc'
outFilePrefix                        'mizoguchi1990'
vegTableFile                         '../VEGPARM.TBL'
soilTableFile                        '../SOILPARM.TBL'
generalTableFile                     '../GENPARM.TBL'
noahmpTableFile                      '../MPTABLE.TBL'

This issue occurs on Hydroshare, unsure about other environments.

Provide more sophisticated logic for dataset merging

Currently, if there are hru and gru dimensioned variables in the output you can't simply xr.concat them because it is only possible to specify a single dimension to concatenate along. We can improve this by handling the gru and hru dimensioned variables separately, then merging that all together after.

Add ability to easily perturb forcings

It would be useful to be able to perform sensitivity analysis on forcing data. Currently this is not implemented, but could be added with some helper methods on the Ensemble class or ensemble module. To accomplish this we would need to:

  1. Standardize the way that forcings are perturbed - I propose we should enforce use of xarray here for predictability.
  2. Standardize naming of perturbations.
  3. Update the force file list to include the standardized naming of forcing perturbations.
  4. Update the file manager to point to any changes to the forcing file list name.
  5. Ensure interop with other types of ensembles. It should be possible to create larger sets of ensembles with forcing perturbations, parameter perturbations, and decision sets without going deep into the internals of the Ensemble configuration.

I have been running some of these types of runs in an ad hoc manner by writing multiple file managers and forcing file lists with some shell scripts then using the following lines to set up the ensembles:

dT_list = ['-4.0K', '+0.0K', '+4.0K']
config_perturbed = {
    '{}K_perturb'.format(dT): 
        {'file_manager': './file_manager_{}K.txt'.format(dT),
         'decisions': {'snowLayers': 'jrdn1991'},
         'parameters': {'windReductionParam': 0.90} 
    for dT in dT_list}

executable = 'summa.exe'
ens_dT = ps.Ensemble(executable, config_perturbed, num_workers=len(config_perturbed))

Instantiation of multiple ensembles share simulations

If I create 2 ensembles via:

import pysumma as ps

exe = 'summa.exe'
fman = 'file_manager.txt'
config1 = {...some_config...}
config2 = {...some_config...}
ens1 = ps.Ensemble(exe, config1, fman)
ens2 = ps.Ensemble(exe, config2, fman)

Then ens2.simulations will contain simulations from both config1 and config2. Clearly this was not the intended behavior.

Run summa with Docker using pysumma

The user should be able to run SUMMA using the SUMMA docker image via pysumma. This will likely go in execute method in the Simulation class.

Encode status strings in an enumeration type

Right now the status of the Ensemble and Simulation classes have status attributes which are explicitly referenced. It would be nice to pull this out and encode it separately into something like a Status class in a constants.py type module.

Create parent Option class

Much of the functionality in the DecisionOption class methods is also needed for the SimulationOption class. It would be nicer to have an abstract Option class that the two more specific classes can inherit from.

Unable to use BigBuckt option for groundwatr decision

When I try to change the summa groundwater decision to bigBuckt, I encounter an error which suggests that pysumma doesn't recognize this option. Notice the last line of the error message, which lists out valid options that has noXplict listed twice, and bigBuckt not listed.

Running this code:

def run_summa_error(site):
s = pysumma.Simulation.Simulation(fman_dict[site])
s.decision_obj.groundwatr.value = 'bigBuckt'
s.executable = '/opt/local/bin/summa.exe'
s.library_path = '/opt/local/lib:/opt/local/lib64:$LD_LIBRARY_PATH'
additional_args = ['export OMP_NUM_THREADS=8']
return s.execute('test_simpleResistance', 'local', additional_args)

I get:

ValueError Traceback (most recent call last)
in ()
----> 1 run_summa_error('Amplero')

in run_summa_error(site)
1 def run_summa_error(site):
2 s = pysumma.Simulation.Simulation(fman_dict[site])
----> 3 s.decision_obj.groundwatr.value = 'bigBuckt'
4 s.executable = '/opt/local/bin/summa.exe'
5 s.library_path = '/opt/local/lib:/opt/local/lib64:$LD_LIBRARY_PATH'

/pool0/data/tushark/pysumma/pysumma/Decisions.py in value(self, new_value)
77 self.write_value(self.value, new_value)
78 else:
---> 79 raise ValueError('Your input value {} is not one of the valid options {}'.format(new_value, self.options))
80
81

ValueError: Your input value bigBuckt is not one of the valid options ['qTopmodl', 'noXplict', 'noXplict']

e.start() problem to execute ensemble simulation

Even though e.start() command finished in Jupyter Notebook, the output of summa is continuously generating. So we have to wait for this process finishing. Without waiting, when we try to combine output dataset from NetCDF, that makes errors.

apply avoidable code for methods of decision file that should not overlap

  1. The LAI method option ["specified"] is no longer supported.
  2. Groundwater parameterization must be (11)bigBucket when using (28)singleBasin for spatial_gw.
  3. pow_prof(power-law transmissivity profile) must be selected when using (11) qTopmodl baseflow option
  4. upper boundary condition for thermodynamics must be (13)presTemp with (15) (16) presHead option for soil hydrology
  5. lower boundary condition for thermodynamics must be (14) zeroFlux with (15) (16) presHead option for soil hydrology
  6. upper boundary condition for soil hydrology must be (15) presHead with (13)(14) presTemp and (14) zeroFlux options for thermodynamics
  7. lower boundary condition for soil hydrology must be (16) zeroFlux with (11) qTopmodl option for groundwater.

Update output control object for new style

Right now the output control object reads/writes only the old style of:

! varName          | outFreq | inst | sum | mean | var | min | max | mode
scalarSenHeatTotal | 24      | 0    | 1   | 1    | 0   | 1   | 1   | 0

We should also support the new style:

scalarSWE                     | timestep   | instant
scalarRainPlusMelt            | day        | mean

Creating input file as netCDF

Step-1

  • Creating 1 HRU Input (LocalAttributes, InitialCond, zParamTrial) using CSV file

Step-2

  • Creating 2 or more than HRUs Input (LocalAttributes, InitialCond, zParamTrial) using CSV file

Step-3

  • Creating forcing input file from Website(EarthData-NLDAS 1hour, 0.125°*0.125°)

Step-4

  • Creating 1 HRU Input (LocalAttributes, InitialCond, zParamTrial) using GIS data

Step-5

  • Creating 2 or more than HRUs Input (LocalAttributes, InitialCond, zParamTrial) using GIS data

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.