Skip to main content

Time-series peak extraction, basin delineation, state-level MRMS data download, and Zarr conversion.

Project description

Citation

If you use this package in your research, please cite:

DOI

🎥 Operational Demonstration of the Python Package in the "USGS MRMS Flood Explorer" Web Application

▶️ Demonstration

The package performs

Peak extraction, basin delineation, mask generation, state-scale MRMS downloads in less than one minute, and Zarr conversion. This fast processing enables state-based operational analyses across the entire United States using real observations.

Although the methodology can continue to be improved, it provides a flexible foundation for future research and collaborations are welcome to expand and refine its capabilities.

Environment Setup & package Installation

(WSL required for Windows users due to GDAL/GRIB dependencies)

  1. Install Micromamba

curl -Ls https://micro.mamba.pm/install.sh | bash

source ~/.bashrc

micromamba --version

micromamba info

  1. Create and activate environment

micromamba create -n tethys_flood -c conda-forge python=3.11 gdal geopandas libgdal-grib -y

micromamba activate tethys_flood

  1. Install the package

python -m pip install --upgrade pip # Upgrade pip

Development mode (code modifications)

pip install -e .

User mode (No code modifications)

python -m pip install mrms-usgs-events # Install the package (Do NOT run if using development mode (-e))

  1. Verify installation

gdalinfo --formats | grep -i grib # Verify gdal grib

mrms-usgs --help # Verify installation

Example use for the Texas July 4 2025 event at the Mystic Camp. (Use at least 1 year between start and end)

mrms-usgs run-site 08165500
--start 2023-07-01
--end 2025-07-10
--base-dir data
--overwrite

Create input tsv

mrms-usgs masks build-input --basins-dir "$BASE_DIR/basins_json" --out "$MASK_INPUT" --overwrite

mrms-usgs masks build-state-masks

mrms-usgs masks build-state-masks --sample-grib-gz "$SAMPLE_GRIB" --mask-input "$MASK_INPUT" --out-dir "$STATE_MASK_DIR" --overwrite

Create state basin index

mrms-usgs masks build-state-basin-index --sample-grib-gz "$SAMPLE_GRIB" --mask-input "$MASK_INPUT" --state-mask-dir "$STATE_MASK_DIR" --out-dir "$STATE_INDEX_DIR" --overwrite

Extract historical event information (Run using tmux)

./run_ews_by_state_parallel.sh

Training engine, filter data

mrms-usgs ews fit-predictors
--summary-dir "$BASE_DIR/ews_history"
--out-dir "$BASE_DIR/ews_predictors"

Download state current rainfall (Texas example)

BASE_DIR="/data/repository_code/unified_data" STATE="TEXAS"

mkdir -p "$BASE_DIR/current_rain"

mrms-usgs ews state-rain-current
--state "$STATE"
--state-mask "$BASE_DIR/state_masks/${STATE}_mrms_mask.npz"
--out-npz "$BASE_DIR/current_rain/${STATE}_current_rain.npz"
--base-dir "$BASE_DIR"
--hours-back 12
--workers 6

Run state alerts (Texas Example)

mrms-usgs ews run-state
--state "$STATE"
--recent-rain-npz "$BASE_DIR/current_rain/${STATE}_current_rain.npz"
--state-basin-index "$BASE_DIR/state_basin_index/${STATE}_state_basin_index.npz"
--predictor-dir "$BASE_DIR/ews_predictors"
--out-dir "$BASE_DIR/ews_alerts/${STATE}"

Data directory with subfolders created following this structure

data/

├── _mrms_cache/ # Temporary cache of downloaded MRMS .grib2 files to avoid re-downloading

├── basins_json/ # Watershed boundaries (GeoJSON) for each USGS station (used to mask rainfall)

├── events/ # Detected hydrologic events (CSV files with peaks, volumes, and timing)

├── logs/ # Execution logs for debugging and tracking pipeline progress

├── rain_zarr/ # Processed rainfall data stored in Zarr format (spatial + temporal arrays)

├── site_meta/ # Metadata for each USGS station (location, name, timezone, etc.)

└── stage_parquet/ # Time series of water level (stage) data from USGS in Parquet format

Acknowledgements

This material is based upon work supported by the U.S. National Science Foundation under Grant No. TI-2303756 and the Tethys Geoscience Foundation.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mrms_usgs_events-0.1.3.tar.gz (67.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mrms_usgs_events-0.1.3-py3-none-any.whl (78.6 kB view details)

Uploaded Python 3

File details

Details for the file mrms_usgs_events-0.1.3.tar.gz.

File metadata

  • Download URL: mrms_usgs_events-0.1.3.tar.gz
  • Upload date:
  • Size: 67.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for mrms_usgs_events-0.1.3.tar.gz
Algorithm Hash digest
SHA256 39ce9b26460f091531ecac8d7a38a43c0645bcf7d397d7e6d41bd7e2892872d6
MD5 371b380faa7b513f29674144ec637f87
BLAKE2b-256 b2294622b2743b80a84208c2efb5060da47a0820fbd1a232839e7dc39b73a785

See more details on using hashes here.

Provenance

The following attestation bundles were made for mrms_usgs_events-0.1.3.tar.gz:

Publisher: publish_to_pypi.yml on GonzaloAlbertoForeroBuitrago/mrms_usgs_events

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mrms_usgs_events-0.1.3-py3-none-any.whl.

File metadata

File hashes

Hashes for mrms_usgs_events-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 d56db069ccbaa7a535be521ff07ba0631bcdba2cf4937a6d8a6b4bab559cf712
MD5 f60dc44466c28395a8aeb2f6a1ec4d10
BLAKE2b-256 0b5918b56ea9e9fcec80e0777e837e777c5ca4151dcf5629f417350324388c19

See more details on using hashes here.

Provenance

The following attestation bundles were made for mrms_usgs_events-0.1.3-py3-none-any.whl:

Publisher: publish_to_pypi.yml on GonzaloAlbertoForeroBuitrago/mrms_usgs_events

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page