Download NWM Retrospective Point Data#
# Import the required packages.
import os
import teehr.loading.nwm.retrospective_points as nwm_retro
from pathlib import Path
from datetime import datetime
from dask.distributed import Client
Set Variables#
Set variables to specify what NWM version to download, the time period, location IDs, and where to save the files.
NWM_VERSION = "nwm20"
VARIABLE_NAME = "streamflow"
START_DATE = datetime(2000, 1, 1)
END_DATE = datetime(2000, 1, 2, 23)
LOCATION_IDS = [7086109, 7040481]
OUTPUT_ROOT = Path(Path().home(), "temp")
OUTPUT_DIR = Path(OUTPUT_ROOT, "nwm20_retrospective")
# Start a dask cluster to improve performance.
n_workers = max(os.cpu_count() - 1, 1)
client = Client(n_workers=n_workers)
client
Fetch and Load to the Data Model#
%%time
nwm_retro.nwm_retro_to_parquet(
nwm_version=NWM_VERSION,
variable_name=VARIABLE_NAME,
start_date=START_DATE,
end_date=END_DATE,
location_ids=LOCATION_IDS,
output_parquet_dir=OUTPUT_DIR
)