Code Monkey home page Code Monkey logo

pyhexwatershed's Introduction

HexWatershed

DOI

HexWatershed: a mesh independent flow direction model for hydrological models.

This Python package provides a Python interface to the underlying HexWatershed model.

HexWatershed has been compiled and tested on various 64-bit Linux and Mac based platforms.

Installation

Ensure you have a c++ compiler and the cmake utility installed.

Build the HexWatershed C++ backend and place the binary under the bin path.

Install the python package using conda: conda install -c conda-forge hexwatershed

For detailed installation instruction, please refer to the documentation.

Usage

Please use this tutorial to run the examples.

Acknowledgement

This work was supported by the Earth System Model Development program areas of the U.S. Department of Energy, Office of Science, Office of Biological and Environmental Research as part of the multi-program, collaborative Integrated Coastal Modeling (ICoM) project.

License

Copyright © 2022, Battelle Memorial Institute

  1. Battelle Memorial Institute (hereinafter Battelle) hereby grants permission to any person or entity lawfully obtaining a copy of this software and associated documentation files (hereinafter “the Software”) to redistribute and use the Software in source and binary forms, with or without modification. Such person or entity may use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and may permit others to do so, subject to the following conditions:
  • Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimers.

  • Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

  • Other than as used herein, neither the name Battelle Memorial Institute or Battelle may be used in any form whatsoever without the express written consent of Battelle.

  1. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BATTELLE OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

References

There are a number of publications that describe the algorithms used in HexWatershed in detail. If you make use of HexWatershed in your work, please consider including a reference to the following:

Scientific Publications

  • Liao, Chang, Zhou, T., Xu, D., Tan, Z., Bisht, G., Cooper, M. G., et al. (2023). Topological relationship-based flow direction modeling: Stream burning and depression filling. Journal of Advances in Modeling Earth Systems, 15, e2022MS003487. https://doi.org/10.1029/2022MS003487

  • Liao, Chang, Zhou, T., Xu, D., Cooper, M. G., Engwirda, D., Li, H.-Y., Leung, L. R. (2023). Topological relationship-based flow direction modeling: Mesh-independent river networks representation. Journal of Advances in Modeling Earth Systems, 15, e2022MS003089. https://doi.org/10.1029/2022MS003089

  • Liao, Chang, Tian Zhou, Donghui Xu, Richard Barnes, Gautam Bisht, Hong-Yi Li, Zeli Tan, et al. (02/2022AD) 2022. “Advances In Hexagon Mesh-Based Flow Direction Modeling”. Advances In Water Resources 160. Elsevier BV: 104099. https://doi.org/10.1016/j.advwatres.2021.104099.

  • Liao, C., Tesfa, T., Duan, Z., & Leung, L. R. (2020). Watershed delineation on a hexagonal mesh grid. Environmental Modelling & Software, 128, 104702. https://doi.org/10.1016/j.envsoft.2020.104702

Software

For a full list of references including applications of HexWatershed in other projects, please refer to the documentation.

pyhexwatershed's People

Contributors

changliao1025 avatar dependabot[bot] avatar

Stargazers

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

Watchers

 avatar  avatar  avatar

pyhexwatershed's Issues

HPC job function

Create a slurm job file through the Python API.
Allow the bash script to run the Python script and run the C++ component within Python.

Setup a slurm job file for the workflow

Option 1: connect all steps into one single python script and let the python script run the hexwatershed.
Option 2: separate different steps and run them in a sequence.

Spatial reference

The spatial reference is used for mesh generation. Currently, the DEM has the spatial reference already, so is it necessary to use an additional vector file?

Configuration file update

The configuration file will be updated after the pyflowline simulation.
changliao1025/pyflowline#31
However, should this be done by the main program or the sub-program is not decided.
The main configuration is passed to pyflowline, so there are essentially the same.
It is more straightforward to let pyflowline hand this because the basin config is within pyflowline.

Variable name across different modules

Currently, the existing modules within the HexWatershed can have different names in different settings.
I will update each component so they will be more consistent.

Vertex location information

While it is desirable to have vertex location, it will incur additional storage and file I/O burden.
The vtk function can be supported in both C++ and Python.
The other visualization can be designed within Python.

Boundary processing

Image processing was used in hexwatershed global scale simulation:
globe_hexagon_erossion ();
globe_hexagon_dilation ();

The reason for these two operations is to ensure each boundary cell ONLY has two neighboring boundary cells.

In the latest development, they will be removed because the requirement will be dropped. We will a different approach to build the queue.

DEM source

Since MPAS mesh provides elevation, it will be used in global scale.
Elevation profile requires fine scale DEM, which is not available yet in MPAS netcdf file.

Boundary or flowline extent

To create mesh from scratch, the program needs to know the extent (up, top, left, right).
This information can be retrieved from spatial extend of both DEM and flowline.

To have consistent design, we will use the DEM as primary information source, and also use flowline as secondary information.

Map projection is another issue.

GDAL intercept two shapefiles

After the recent updates, the GeoJSON is used for all data transfer.
The intersection is done using the GDAL python API.
image

Auto update boundary using the outlet location

Currently, if the mesh was generated "well", then the outlet location may not be on the edge, which causes the program to crash in other meshes.
In the next development, we will add a function to auto-generate mesh that will match with outlet location and DEM.

Stream segment output

The backend will now output a json file which contains all the stream segments for each watershed.

Example folder re-organization

Following the other repos, the main repo now uses a new folder structure for different domain under the example folder.

Checkpoint feature

Running a simulation with all the steps or features may be computationally expensive, adding a checkpoint feature may speed up some process.

Stream flowline preparation

#step 1: convert it to json format
#step 2: merge all as one single feature   
#step 3: split into segment   
#step 4: remove loops
#step 5: remove small headwater segment
#step 6: intersect with mesh and simplify
#step 7: rebuild index and order
#step 8: calculate properties

Vertex comparison

There is a bug in the existing vertex comparison algorithm.
Although the algorithm avoids using a threshold to compare two objects, the precision of float can cause this bug in rare cases.

image

Flowline simplification process

The simplification is required, however this can be done in either Python or in C++.
There are both pros and cons.
Reason to pick Python:
Easy to test and implement
Should be fast enough because information is limited
There are some existing C++ to Python conversion tools.
Reason to not pick Python:
Not sure about the STL alternative.
Global scale high resolution computational demand.

Reason to pick C++:
There are existing algorithm built;
performance;
natural C++ STL library
Reason not to pick C++:
Not ideal in long run.

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.