Skip to content

Latest commit

 

History

History
195 lines (137 loc) · 7.61 KB

File metadata and controls

195 lines (137 loc) · 7.61 KB

nwm-fcst-mgr

Description

A program to execute forecast and hindcast runs runs provided a configuration file from a past calibration run by the nwm-cal-mgr.

Installation

Clone nwm-fcst-mgr

This repository is the NGWPC fork of nwm-fcst-mgr, maintained ahead of eventual merge to NOAA-OWP/nwm-fcst-mgr. Clone instructions below reference the NGWPC fork, as it is the current active development source.

git clone --recurse-submodules https://github.com/NGWPC/nwm-fcst-mgr.git

Build the environment

To run the program, one would need an environment for successfully running ngen and its modules (including t-route).

If you already have an environment for running ngen, you can use the same venv and pip install matplotlib if it is not already installed.

Otherwise, follow the following steps to build a new environment (in AWS Ubuntu 22.04 LTS Workspace):

  1. cd [VENV_ROOT]
  2. /usr/bin/python3.11 -m venv venv.ngen
  3. source venv.ngen/bin/activate
  4. pip install --upgrade pip
  5. pip3 install numpy==1.26.4 pandas bmipy netcdf4==1.6.3 joblib toolz Cython geopandas pyarrow matplotlib deprecated
  6. cd [NGEN_ROOT]/ngen/extern/t-route/
  7. pip install -r requirements.txt
  8. ./compiler.sh

where [VENV_ROOT] and [NGEN_ROOT] refer to the directory to install the python virtual environment and the root directory where ngen is installed, respectively.

Setup

Follow the following steps to test the program:

  1. source [VENV_ROOT]/env.ngen/bin/activate
  2. cd [NWM-FCST-MGR_ROOT]/nwm-fcst-mgr
  3. pip install .

where [NWM-FCST-MGR_ROOT] is where nwm-fcst-mgr is installed.

Usage

nwm-fcst-mgr supports three workflows: forecast, hindcast, and lagged ensemble runs. Each workflow support two modes controlled by the --no_valid flag:

  • Validation-based mode (no_valid = False, default) - Uses a validation yaml file from a previous nwm-cal-mgr calibration/validation run.
  • Default/Regionaliztion-based mode (no_valid = True) - Runs a forecast using the msw-mgr default or regionalization run types. gpkg and ngen paths are derived from the run directory.

Note: the hindcast workflow only supports the validation-based mode (no_valid = False)


Forecast Workflow

Run a cold start, forecast, or lagged ensemble workflow. These runs must be preceded by calls to the nwm-msw-mgr.

Medium range lagged ensembles cycles are run with forcing inputs lagged at 6 hour intervals, with open and closed loop AnA start up states. Members 1 and no_da have no forcing time lags, while Members 2-6 have sequential 6 hour time lags. All lagged ensemble ngen runs are orchestrated to begin at the same time and run for either 10 days (Members 1 and no_da) or 8.5 days (Members 2-6). The no_da member should be initialized with a state load from an open loop cycle. Members 1-6 should be initialized with a state load from a closed loop cycle. The lagged ensemble workflow can only be executed with a medium range configuration.

CLI

** Validation-based mode:**

python -m nwm_fcst_mgr run_forecast \
    /path/to/realization.json \
    --valid_yaml /path/to/valid.yaml \
    --partition_file /path/to/partiton.json
    

** Default/Regionalization mode:**

python -m nwm_fcst_mgr run_forecast \
    /path/to/realization.json \
    --no_valid \
    --partition_file /path/to/partiton.json

Python

** Validation-based mode:**

from nwm_fcst_mgr.forecast import run_forecast

run_forecast(
    real_path='/path/to/realization.json'
    valid_yaml='/path/to/valid.yaml',
    partition_file='/path/to/partition.json',
)

** Default/Regionalization mode:**

from nwm_fcst_mgr.forecast import run_forecast

run_forecast(
    real_path='/path/to/realization.json',
    no_valid=True,
    partition_file='/path/to/partition.json',
)

Arguments

  • input_path - Path to cold start or forecast realization file generated by nwm-msw-mgr
  • --valid_yaml - (Optional) Path to validation yaml file from previous calibration run (from nwm-cal-mgr)
  • --no_valid - (Optional) Use validation-based workflow with valid_yaml (False, default) or default/regionalization-based workflow (True)
  • --partition_file - (Optional) Path to partition configuration file for parallel ngen execution

Hindcast Workflow

Run repeated hindcast cycles at regular intervals, with start up states provided by warm start runs. Cold start run must be executed separately using run_forecast.

Only supported with validation-based mode (no_valid = False)

CLI

python -m nwm_fcst_mgr run_hindcast \
    /path/to/input.config \
    my_hindcast_run \
    3 \
    10 \
    --valid_yaml /path/to/valid.yaml
    --cold_start_state '/path/to/cold_start_state/' \

Python

from nwm_fcst_mgr.forecast import run_hindcast

for _ in run_hindcast(
    valid_yaml='/path/to/valid.yaml',
    config='/path/to/input.config',
    fcst_run_name='my_hindcast_run',
    cycle_interval=3,
    num_iterations=10,
    cold_start_state='/path/to/cold_start_state/',
    yield_realizations=False,
):
    pass

Arguments

  • valid_yaml - Path to validation yaml file from previous calibration run (from nwm-cal-mgr)
  • config - Path to forecast input configuration file (as str), or instance of InputConfig (both from nwm-msw-mgr)
  • my_hindcast_run - Name for the hindcast run folder
  • cycle_interval - Cycle interval in hours (spacing between hindcast cycles)
  • num_iterations - Number of hindcast cycles to perform
  • cold_start_state - (Optional) Path to cold start state to initialize hindcasting workflow
  • yield_realizations - (Optional) Default False. If True, then this generator will yield each RealizationBuilder instance after constructing it and calling its build_fcst_realization() method, so the caller can execute the realization. If False, then this generator will yield None, and consuming it will instead execute each RealizationBuilder instance itself.

Hindcast Example

With cycle_interval=3 and num_iterations=10, hindcast runs will be executed at 0, 3, 6, 9, 12, 15, 18, 21, 24, 27 hours.

Docker container

Requirements

To build and run nwm-fcst-mgr, you will need the following software installed and running on your system:

  • Docker Engine

Build

To build the nwm-fcst-mgr container, execute the following command:

docker build --tag=nwm-fcst-mgr .

Running

Contributing

State if you are open to contributions and what your requirements are for accepting them.

For people who want to make changes to your project, it's helpful to have some documentation on how to get started. Perhaps there is a script that they should run or some environment variables that they need to set. Make these steps explicit. These instructions could also be useful to your future self.

You can also document commands to lint the code or run tests. These steps help to ensure high code quality and reduce the likelihood that the changes inadvertently break something. Having instructions for running tests is especially helpful if it requires external setup, such as starting a Selenium server for testing in a browser.

Authors and acknowledgment

Show your appreciation to those who have contributed to the project.

License

For open source projects, say how it is licensed.

Project status

If you have run out of energy or time for your project, put a note at the top of the README saying that development has slowed down or stopped completely. Someone may choose to fork your project or volunteer to step in as a maintainer or owner, allowing your project to keep going. You can also make an explicit request for maintainers.