Welcome to the WC-WAVE Adaptors and Model Integration documentation!¶
Python API for Dynamic Waterhsed Science Modeling¶
This API targets two main tasks of watershed hydrology modeling: data management and model running and manipulation. The only model currently supported is the iSNOBAL model from the Software Tools for Hydro-Climatic Modeling and Analysis Image Processing Workbench (IPW).
For data management, this API provides a wrapper of the Virtual Watershed (VW) The VW is an extension of the GSToRE architecture hosted by the Earth Data Analysis Center at the University of New Mexico. It is a specialized database for hydrological data. By properly utilizing metadata, we may, for example, very intuitively create multiple “model runs”, where a given hydrological model or coupled hydrological models operate on a set of input data. This input data may then be modified, fed to another model run, with new outputs, and all this may be stored sanely.
For a quick look at what’s possible with the iSNOBAL interface, see the demonstration experiment of iSNOBAL where we modify some observed IPW binary data to increase the temperature, run iSNOBAL on every set of modified input data, and plot the results with pandas/matplotlib.
Quickstart¶
This part is very simple and basically consists of three parts:
- Clone the repository
- Install dependencies using pip install -r requirements.txt
- Copy default.conf.template to default.conf and src/test/test.conf.template to src/test/test.conf and fill out both with your login credentials and correct paths to the XML and JSON metadata templates
- Check that all is well by running the unittests
Clone repository¶
The repository is hosted on github. Clone it like so:
git clone https://github.com/tri-state-epscor/adaptors
Install dependencies¶
You need pip installed to complete this step.
From the root folder of the repository, run
pip install -r requirements.txt
Copy configuration files and edit them appropriately¶
First, copy the configuration file templates:
$ cp default.conf.template default.conf
$ cp src/test/test.conf.template src/test/test.conf
Next open default.conf in your text editor and fill in watershedIP, user, and passwd fields appropriately. For the two template_path variables in the two different sections, change EDIT-THIS-PATH-TO to the actual path to your adaptors directory.
Run Unittests¶
Finally, run the unittests from the root adaptors directory like so
# -v for verbose
nosetests -v
If all is well, you will see the following output:
Check that IPW header is properly re-made ... ok
Check that the IPW dataframe has been correctly built ... ok
Check that _bands_to_dtype works as expected ... ok
Convert an integer to a float using the header information in a Band ... ok
Test that a DF with floats is correctly translated to a binary string ... ok
Error when a data val is less than a band maximum? ... ok
Error when a data val is less than a band minimum? ... ok
Check that header lines are properly built into a dictionary ... ok
Test start-to-finish steps of load, modify, and save an IPW file using the IPW class ... ok
Test that headers are successfully recalculated after data has been ... ok
Load 5- and 6-band input and em/snow output IPW files and save back to a new file ... ok
Test that a single metadata JSON string is properly built (FGDC) ... ok
Test that a single metadata JSON string is properly built (JSON) ... ok
Test that failed authorization is correctly caught ... /Users/mturner/anaconda/lib/python2.7/site-packages/requests/packages/urllib3/connectionpool.py:730: InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.org/en/latest/security.html (This warning will only appear once by default.)
InsecureRequestWarning)
ok
VW Client properly downloads data ... ok
VW Client throws error on failed download ... ok
VW Client properly inserts data ... ok
VW Client throws error on failed insert ... ok
VW Client properly uploads data ... ok
----------------------------------------------------------------------
Ran 19 tests in 16.700s
OK