Skip to content

NGWPC/nwm-fcst-mgr

 
 

Repository files navigation

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

git clone -b development --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 two workflows: forecast and hindcast runs.

Forecast Workflow

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

CLI

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

Python

from nwm_fcst_mgr.forecast import run_forecast

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

Arguments

  • valid_yaml - Path to validation yaml file from previous calibration run (from nwm-cal-mgr)
  • input_path - Path to cold start or forecast realization file generated by nwm-msw-mgr

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.

CLI

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

Python

from nwm_fcst_mgr.forecast import run_hindcast

run_hindcast(
    valid_yaml='/path/to/valid.yaml',
    input_path='/path/to/input.config',
    fcst_run_name='my_hindcast_run',
    cycle_interval=3,
    num_iterations=10,
    cold_start_state='/path/to/cold_start_state/'
)

Arguments

  • valid_yaml - Path to validation yaml file from previous calibration run (from nwm-cal-mgr)
  • input_path - Path to forecast input configuration file (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

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.

Lagged Ensemble Workflow

Run medium range lagged ensembles cycles 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 lagged ensemble workflow can only be executed with a medium range configuration.

CLI

python -m nwm_fcst_mgr run_lagged_ens \
    /path/to/valid.yaml \
    /path/to/input.config \
    my_lagged_ens_run \
    --open_loop_state /path/to/open_loop_state/ \
    --closed_loop_state /path/to/closed_loop_state/ \

Python

from nwm_fcst_mgr.forecast import run_lagged_ens

run_lagged_ens(
    valid_yaml='/path/to/valid.yaml',
    input_path='/path/to/input.config',
    fcst_run_name='my_lagged_ens_run',
    open_loop_state='/path/to/open_loop_state/',
    closed_loop_state='/path/to/closed_loop_state/'
)

Arguments

  • valid_yaml - Path to validation yaml file from previous calibration run (from nwm-cal-mgr)
  • input_path - Path to forecast input configuration file (from nwm-msw-mgr)
  • my_lagged_ens_run - Name for the lagged ensemble run folder
  • --open_start_state - Path to open loop AnA state to initialize no data assimilation member
  • --closed_start_state - Path to closed loop AnA state to initialize members 1-6

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.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages

  • Python 77.2%
  • Shell 16.3%
  • Dockerfile 6.5%