A python package for building files for hydrologic modeling, specifcally targeting smrf/awsm
BASIN SETUP TOOL v0.14.1
- GDAL 2.3.2
- pip 19.2.1
To begin the install for basin_setup, ensure that GDAL is compiled from source. Note: Do not install the python library for GDAL but rather the command line utiltiies. To compile from source follow the instructions provided at:
Once GDAL is installed, install the python requirements using pip:
$ pip install -r requirements.txt
Finally to install basin_setup for commandline use use:
$ python install setup.py
If you want to develop on basin_setup use the following command to install the utility so that you changes to the source will be used without having to reinstall
$ python setup.py develop
There are 6 commands that are installed after installing using the make file.
- basin_setup - creates all the images for running SMRF/AWSM
- delineate - Automatically delineates a new basin.
- grm - Aggregates Lidar snow depths into a single netcdf
- make_qgis_proj - Adds files to a xml file to be used in QGIS
- make_dem_colormap - Makes a custom colormap for a dem specifically making nice maps
- make_veg_type_colormap - Makes a custom colormap from the landfire data set specifically for maps
The basin_setup outputs a single netcdf file containing:
- Basin mask
- Basin DEM
- Basin Vegetation type (From Landfire)
- Basin Vegetation Height (From Landfire)
- Basin Vegetation Tau
- Basin Vegetation K
To use basin_setup you only need a shapefile of your basins boundary and a dem that contains the the extents of the shapefile. It is required that the shapefile is in UTM. The projection of the DEM wil be converted to that of the shapefile.
To use basin_setup at it's simplest form, just provide a shapefile and dem:
$ basin_setup -f rme_basin_outline.shp -dm ~/Downloads/ASTGTM2_N43W117/ASTGTM2_N43W117_dem.tif
Custom Cell Size To specify the cell size use the cellsize flag which is specified in meters, if it is not used the default is 50m:
$ basin_setup -f rme_basin_outline.shp -dm ~/Downloads/ASTGTM2_N43W117/ASTGTM2_N43W117_dem.tif --cell_size 10
Switching Array Origin
Occasionally an image will have the correct coordinates and orientation
but its array will have a different origin than expected. This can
happen when alternating between raster images and other data sets. For
example, using the commands above will produce successful topo.nc for
SMRF and will display correctly when using something like ncview (which
considers the x and y data inputted). However if you were to simply plot
with imshow from matplotlib that data you will find is upside down, so
the default behavior flips the image. This is because of a difference in
array origins. To not flip this use the
--noflip flag which flips
the y axis data and the images over the x-axis resulting images
correctly oriented in ncview and
$ basin_setup -f rme_basin_outline.shp -dm ~/Downloads/ASTGTM2_N43W117/ASTGTM2_N43W117_dem.tif --noflip
Setting Up Point Models
It is possible to create what our group considers a point model. The goal here is to create all the files necessary to run in SMRF/AWSM without having to change the SMRF/AWSM code to test the modeling system on a point. This means creating the smallest sized topo possible. In this case thats a 3X3 image. NetCDF dictates an image cannot be 1 pixel. Below is the simplest way to create a point model for Reynolds Mountain East's snow pillow site.
$ basin_setup -p 519976,4768323 -dm ASTGTM2_N43W117_dem.tif --epsg 2153
Note: Until this code is improved the user must provided the EPSG code so the projection information can be obtained. If you are not sure what your EPSG is use this link to find it. http://spatialreference.org/ref/epsg/
With a point model there is sometimes the desire to use a uniform value for variables. This is done by using the uniform flag.
$ basin_setup -p 519976,4768323 -dm ASTGTM2_N43W117_dem.tif --epsg 2153 --uniform
Which simply picks the middle cell and applies it everywhere. On this same idea the DEM can be provided as a single value. So the user can choose a different elevation than what an image can provide. E.g.
$ basin_setup -p 519976,4768323 -dm 1000 --epsg 2153 --uniform
Using it in Docker
Building GDAL can sometimes be a headache if you are unfamiliar with normal build practices. If you would like to just use the tool with no questions asked, then use the docker command. However note that the file structure is what is represented inside the docker. So you must mount local directories to docker ones fortunately we have created a data folder for you to do just that. Mounting these will also ensure files you generate persist.
The commands are used the same but with extra:
$ docker run -it --rm -v $(pwd):/data -v <DOWNLOADS>/:/data/downloads usdaarsnwrc/basin_setup:develop -f SHAPEFILE -dm DME_IMG -d /data/downloads
The command above is:
- Mounting the current working directory to the
/datafolder inside docker
- Mounting the current working directory to the
/data/downloadsfolder inside docker
- Running basin_setup with the dowloads pointing to the docker side.
The delineation script automatically delineates a basin using pour points and a dem. The tool is based on TaudDEM.
The script will produce shapefiles of all the subbasins using a threshold. It also saves data to allow for re-running faster.
- Auto delineation.
- Multiruns with multiple thresholds.
- Rerun functionality to reduce computation time.
- Outputs Shapefiles for basins and subbasins
- Runs in parallel
- pour points must be in a BNA format. The name of the points in the BNA file will be used as the name for the output files.
- DEM must be a .tif
$ delineate -p pour_points.bna -d dem.tif --rerun -t 2000000 -n 2 --debug
Using the debug flag will leave lots of extra files that were generated on the way in a folder named delineation
To get files necessary for streamflow add --streamflow flag to the command
- Project Inception!
- point model setup
- cell size bug fix 1_
- Array flipping option
- improved documentation
- Python 3 compatibility
- output unique veg values being used
- Projection Information added
- Project metdata and badges
- Fixes for 8_ and 9_
- Updated Requirements
- Added Makefile for installing
- Prototype for a delineation script!
- Fixed Spelling errors in file management for delineate
- Exanded delineate shapefile output including subassins
- Improved documentation for delineate
- Auto determining the projection info
- Fixes for 12_, 15_, 16_, 17_, 18_
- Data provenance work for delineate
- Improvements to docker build
- Output expanded in delineate for files required for Streamflow
- Extracted functionality and moved to spatialnc
- Added GRM tool for aggregating lidar flights into a netcdf from ASO
.. _12: https://github.com/USDA-ARS-NWRC/basin_setup/issues/12 .. _15: https://github.com/USDA-ARS-NWRC/basin_setup/issues/15 .. _16: https://github.com/USDA-ARS-NWRC/basin_setup/issues/16 .. _17: https://github.com/USDA-ARS-NWRC/basin_setup/issues/17 .. _18: https://github.com/USDA-ARS-NWRC/basin_setup/issues/18
- Fixes for 27_
- Working on NaN assignments
- Expanded resampling techniques for GRM
- Fixes for 24_
- Added in Static file output fro ARS streamflow modeling
- Documentation Improvements .. _24: https://github.com/USDA-ARS-NWRC/basin_setup/issues/24
- Fixes for 31_
- First Release on Pypi
- Converted Basin_setup to a python package not a collection of scripts
- Vegetation Parameter requirements more strict, requiring a csv to dictate the interpretation
- Updated Docker
- Fixes for 34_
- Added in CLI extents flag for cutting exactly to a known domain.
- Added resampling to DEM and Veg Height layers, all else use nearest neighbor.
- Fixes for 29_, 36_, 37_, 39_, 40_
- Added in a bypass flag for skipping over missing tau/k data
- Updated veg tau/k parameters
- Added tif file format to parse_extent
- Added first unittests!
.. _29: https://github.com/USDA-ARS-NWRC/basin_setup/issues/29 .. _36: https://github.com/USDA-ARS-NWRC/basin_setup/issues/36 .. _37: https://github.com/USDA-ARS-NWRC/basin_setup/issues/37 .. _39: https://github.com/USDA-ARS-NWRC/basin_setup/issues/39 .. _40: https://github.com/USDA-ARS-NWRC/basin_setup/issues/40
- Fixes for 41_, 42_, 43_, 44__, 45__
- Added in colormap making scripts
- Added in QGIS project maker script
- Added in a script for adding veg values to landfire dataset
- Added values in the landfire vegetation table
.. _41: https://github.com/USDA-ARS-NWRC/basin_setup/issues/41 .. _42: https://github.com/USDA-ARS-NWRC/basin_setup/issues/42 .. _43: https://github.com/USDA-ARS-NWRC/basin_setup/issues/43 .. _44: https://github.com/USDA-ARS-NWRC/basin_setup/issues/44 .. _45: https://github.com/USDA-ARS-NWRC/basin_setup/issues/45
- Fixes for 46_
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
|Filename, size||File type||Python version||Upload date||Hashes|
|Filename, size basin_setup-0.14.1-py3-none-any.whl (79.6 kB)||File type Wheel||Python version py3||Upload date||Hashes View|
|Filename, size basin_setup-0.14.1.tar.gz (46.5 kB)||File type Source||Python version None||Upload date||Hashes View|
Hashes for basin_setup-0.14.1-py3-none-any.whl