Skip to content

WaterPix is a hydrologic data-based model used to perform water balances at a pixel scale.

License

Notifications You must be signed in to change notification settings

gespinoza/waterpix

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

WaterPix

WaterPix is a hydrologic data-based model used to perform water balances at a pixel scale.

How to use the code

Before you start

There are two software options to run WaterPix on python:

The two options are equivalent, the only difference is about the underlying library to process the geospatial data.

Requirements

Installation

  1. Identify a folder in your computer that is recognized by python (e.g. ...\Lib\site-packages). You can check which folders are recognized by python with the following commands:
    >>> import sys
    >>> sys.path
    ['',
    'C:\\Program Files\\Anaconda2\\lib\\site-packages',
    ...
  2. Download or clone the waterpix module from the online repository and place it into the folder recognized by python.
  3. Check that waterpix works and that all the required modules are installed.
    • gdal
      >>> from waterpix import wp_gdal
      >>> wa_gdal.__all__
      ['create_input_nc', 'run', 'output_nc_to_tiffs']
    • arcpy
      >>> from waterpix import wp_arcpy
      >>> wa_gdal.__all__
      ['create_input_nc', 'run', 'output_nc_to_tiffs']
    Note: If you get the following error:
    ImportError: No module named ...
    install the required modules, restart the python console, and repeat this step.

Example

from waterpix import wp_gdal

# Create input netcdf file
wp_gdal.create_input_nc(start_date='2010-01-01',
                        years=7,  # 2010 - 2016
                        cellsize=0.01078
                        basin_shp = r'C:\Temp\Basin_A.shp',
                        p_path = r'C:\Precipitation\chirps-v2.0_monthly_{yyyy}{mm}.tif',
                        et_path = r'C:\Evapotranspiration\L1_AET_{yyyy}{mm}.tif',
                        eto_path = r'C:\ReferenceET\ETref_mm-month-1_monthly_{yyyy}.{mm}.01.tif',
                        lai_path = r'C:\LeafAreaIndex\LAI_{yyyy}{mm}.tif',
                        swi_path = r'C:\Soil Moisture\MonthlyMean\SWI_{yyyy}{mm}.tif',
                        swio_path = r'C:\Soil Moisture\FirstDay\SWI_{yyyy}{mm}.tif',
                        swix_path = r'C:\Soil Moisture\LastDay\SWI_{yyyy}{mm}.tif',
                        qratio_path = r'C:\Runoff Ratio\Qr_{yyyy}.tif',
                        rainydays_path = r'C:\Rainy days\chirps-v2.0.{yyyy}.{mm}_rainydays.tif',
                        thetasat_ras = r'C:\Saturated water content\wcsat_topsoil.tif',
                        rootdepth_ras = r'C:\Root depth\rd_mm.tif',
                        input_nc = r'C:\input_file_basin_A.nc')

# Run WaterPix
input_nc = r'C:\input_file_basin_A.nc'
output_nc=r'C:\output_file_basin_A.nc'
wp_gdal.run(input_nc, output_nc)

# Export rasters
output_path = r'C:\output_rasters'
wp_gdal.output_nc_to_tiffs(output_nc, output_path)

Citation

Espinoza-Dávalos, G. E., & Bastiaanssen, W. G. M. (2017). WaterPix: A Data Based Water Balance Model for Water Accounting. http://doi.org/10.5281/zenodo.1045574

Contact

Gonzalo E. Espinoza, PhD, MSc
Integrated Water Systems and Governance
IHE Delft Institute for Water Education
T: +31 15 2152313
E: g.espinoza@un-ihe.org
I: un-ihe.org | wateraccounting.org | gespinoza.org