Graphical Tools for creating Next Gen Water model input data.
Project description
NGIAB Data Preprocess
This repository contains tools for preparing data to run a next gen simulation using NGIAB. The tools allow you to select a catchment of interest on an interactive map, choose a date range, and prepare the data with just a few clicks!
Table of Contents
- What does this tool do?
- Requirements
- Installation and Running
- Development Installation
- Usage
- CLI Documentation
What does this tool do?
This tool prepares data to run a next gen simulation by creating a run package that can be used with NGIAB. It picks default data sources, including the v20.1 hydrofabric and nwm retrospective v3 forcing data.
Requirements
- This tool is officially supported on macOS or Ubuntu. To use it on Windows, please install WSL.
- GDAL needs to be installed.
- The 'ogr2ogr' command needs to work in your terminal.
sudo apt install gdal-bin
will install gdal and ogr2ogr on ubuntu / wsl
Installation and Running
# optional but encouraged: create a virtual environment
python3 -m venv env
source env/bin/activate
# installing and running the tool
pip install ngiab_data_preprocess
python -m map_app
The first time you run this command, it will download the hydrofabric and model parameter files from Lynker Spatial. If you already have them, place conus.gpkg
and model_attributes.parquet
into modules/data_sources/
.
Development Installation
Click to expand installation steps
To install and run the tool, follow these steps:
- Clone the repository:
git clone https://github.com/CIROH-UA/NGIAB_data_preprocess cd NGIAB_data_preprocess
- Create a virtual environment and activate it:
python3 -m venv env source env/bin/activate
- Install the tool:
pip install -e .
- Run the map app:
python -m map_app
Usage
Running the command python -m map_app
will open the app in a new browser tab. Alternatively, you can manually open it by going to http://localhost:5000 with the app running.
To use the tool:
- Select the catchment you're interested in on the map.
- Pick the time period you want to simulate.
- Click the following buttons in order:
- Create subset gpkg
- Create Forcing from Zarrs
- Create Realization
Once all the steps are finished, you can run NGIAB on the folder shown underneath the subset button.
Note: When using the tool, the output will be stored in the ./output/<your-first-catchment>/
folder. There is no overwrite protection on the folders.
CLI Documentation
Click to expand CLI documentation
Arguments
-h
,--help
: Show the help message and exit.-i INPUT_FILE
,--input_file INPUT_FILE
: Path to a CSV or TXT file containing a list of waterbody IDs, or a single waterbody ID (e.g.,wb-5173
).-s
,--subset
: Subset the hydrofabric to the given waterbody IDs.-f
,--forcings
: Generate forcings for the given waterbody IDs.-r
,--realization
: Create a realization for the given waterbody IDs.--start_date START_DATE
: Start date for forcings/realization (format YYYY-MM-DD).--end_date END_DATE
: End date for forcings/realization (format YYYY-MM-DD).-o OUTPUT_NAME
,--output_name OUTPUT_NAME
: Name of the subset to be created (default is the first waterbody ID in the input file).
Examples
-
Subset hydrofabric:
python -m ngiab_data_cli -i waterbody_ids.txt -s
-
Generate forcings:
python -m ngiab_data_cli -i wb-5173 -f --start_date 2023-01-01 --end_date 2023-12-31
-
Create realization:
python -m ngiab_data_cli -i waterbody_ids.csv -r --start_date 2023-01-01 --end_date 2023-12-31 -o custom_output
-
Perform all operations:
python -m ngiab_data_cli -i waterbody_ids.txt -s -f -r --start_date 2023-01-01 --end_date 2023-12-31
File Formats
The input file can be either a CSV or TXT file containing a list of waterbody IDs, one per line. Alternatively, you can provide a single waterbody ID directly as an argument (e.g., wb-5173
).
Output
The script creates an output folder named after the first waterbody ID in the input file or the provided output name. This folder will contain the results of the subsetting, forcings generation, and realization creation operations.
Error Handling
The script includes error handling for common issues such as:
- Missing required arguments
- Invalid input file formats
- Non-existent input files
- Unsupported file types
If an error occurs, the script will log an error message and terminate.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for ngiab_data_preprocess-1.2.2.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5d5cd32ef44d49ce460ab5f6355c4371137e08a29b2e54973c0991997bb470b7 |
|
MD5 | 72a9a6e745d71f6cf6958739448223b0 |
|
BLAKE2b-256 | a2f5f63bc4ed881dfaf50ff5e45a9a9b12a0251f7512bb84ad10dd7de8e33481 |
Hashes for ngiab_data_preprocess-1.2.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 71cfe04a6a987349557f684447b35145bfaf264821c822b85a6b2147726484a3 |
|
MD5 | 1804a67a9d5d20bb91ad20f1a9b1dc5f |
|
BLAKE2b-256 | a3da0949caab48d12be85513e59586f6ec668f289aec17d5252b6235bac3c4d1 |