{ "cells": [ { "cell_type": "markdown", "id": "67d08aaf-db12-4fb7-a1b0-f1aab0bed707", "metadata": {}, "source": [ "## National Water Model Example\n", "\n", "This notebook gives a brief introduction to the National Water Model data available from Azure Blob Storage. It uses [xarray](https://xarray.pydata.org/) and [adlfs](https://fsspec.github.io/adlfs) to load the NetCDF files and visualize the data. We'll work with the raw NetCDF data pushed to azure by [NODD](https://www.noaa.gov/information-technology/open-data-dissemination).\n", "\n", "The goals of this notebook are to learn what NWM data are available on Azure, and to build a bit of familiarity with the compute environment you're in." ] }, { "cell_type": "code", "execution_count": 1, "id": "cb4a6570-752a-4333-afc7-bb80a536a407", "metadata": { "tags": [] }, "outputs": [], "source": [ "import adlfs\n", "import azure.storage.blob\n", "import planetary_computer\n", "import xarray as xr\n", "import matplotlib.pyplot as plt\n", "import geopandas\n", "import pyproj\n", "import contextily\n", "import planetary_computer\n", "import pystac_client\n", "from IPython.display import Image\n", "import odc.stac" ] }, { "cell_type": "code", "execution_count": 2, "id": "9927234a-b192-4f94-9f90-fe5b7e2744e6", "metadata": { "tags": [] }, "outputs": [], "source": [ "fs = adlfs.AzureBlobFileSystem(\"noaanwm\")" ] }, { "cell_type": "markdown", "id": "397c3dac-5d39-4099-9cf4-42a6e9bc0004", "metadata": {}, "source": [ "A new set of files is produced every few hours. This example uses the files from 2023-01-23T00:00. We'll load a short-range forecast for the Continental United States." ] }, { "cell_type": "code", "execution_count": 3, "id": "a5c8d8d2-a6b9-42c7-859f-5e3c63a3d4e0", "metadata": { "tags": [] }, "outputs": [ { "data": { "text/html": [ "
<xarray.Dataset>\n", "Dimensions: (time: 1, reference_time: 1, x: 4608, y: 3840)\n", "Coordinates:\n", " * time (time) datetime64[ns] 2023-01-23T01:00:00\n", " * reference_time (reference_time) datetime64[ns] 2023-01-23\n", " * x (x) float64 -2.303e+06 -2.302e+06 ... 2.303e+06 2.304e+06\n", " * y (y) float64 -1.92e+06 -1.919e+06 ... 1.918e+06 1.919e+06\n", "Data variables:\n", " crs |S1 ...\n", " SNOWH (time, y, x) float64 ...\n", " SNEQV (time, y, x) float64 ...\n", " FSNO (time, y, x) float64 ...\n", " ACCET (time, y, x) float64 ...\n", " SOILSAT_TOP (time, y, x) float64 ...\n", " SNOWT_AVG (time, y, x) float64 ...\n", "Attributes:\n", " TITLE: OUTPUT FROM NWM v2.2\n", " model_initialization_time: 2023-01-23_00:00:00\n", " model_output_valid_time: 2023-01-23_01:00:00\n", " model_total_valid_times: 18\n", " Conventions: CF-1.6\n", " code_version: v5.2.0-beta2\n", " NWM_version_number: v2.2\n", " model_output_type: land\n", " model_configuration: short_range\n", " proj4: +proj=lcc +units=m +a=6370000.0 +b=6370000.0 ...\n", " GDAL_DataType: Generic
<xarray.Dataset>\n", "Dimensions: (time: 1, reference_time: 1, feature_id: 5783)\n", "Coordinates:\n", " * time (time) datetime64[ns] 2023-01-23T01:00:00\n", " * reference_time (reference_time) datetime64[ns] 2023-01-23\n", " * feature_id (feature_id) int32 491 531 ... 1021092845\n", " latitude (feature_id) float32 46.18 46.16 ... 44.59\n", " longitude (feature_id) float32 -68.38 -68.45 ... -73.31\n", "Data variables:\n", " crs |S1 b''\n", " reservoir_type (feature_id) float64 1.0 1.0 1.0 ... 1.0 1.0\n", " reservoir_assimilated_value (feature_id) float32 nan nan nan ... nan nan\n", " water_sfc_elev (feature_id) float32 206.2 247.9 ... 42.85\n", " inflow (feature_id) float64 0.41 0.04 ... 352.5\n", " outflow (feature_id) float64 0.56 0.39 ... 347.0\n", "Attributes:\n", " TITLE: OUTPUT FROM NWM v2.2\n", " featureType: timeSeries\n", " proj4: +proj=lcc +units=m +a=6370000.0 +b=6370000.0 ...\n", " model_initialization_time: 2023-01-23_00:00:00\n", " station_dimension: lake_id\n", " model_output_valid_time: 2023-01-23_01:00:00\n", " model_total_valid_times: 18\n", " Conventions: CF-1.6\n", " code_version: v5.2.0-beta2\n", " NWM_version_number: v2.2\n", " model_output_type: reservoir\n", " model_configuration: short_range
\n", " | \n", " | \n", " | reservoir_type | \n", "reservoir_assimilated_value | \n", "latitude | \n", "longitude | \n", "water_sfc_elev | \n", "inflow | \n", "outflow | \n", "geometry | \n", "
---|---|---|---|---|---|---|---|---|---|---|
time | \n", "reference_time | \n", "feature_id | \n", "\n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " |
2023-01-23 01:00:00 | \n", "2023-01-23 | \n", "491 | \n", "1.0 | \n", "NaN | \n", "46.183273 | \n", "-68.379036 | \n", "206.240295 | \n", "0.41 | \n", "0.56 | \n", "POINT (-68.37904 46.18327) | \n", "
531 | \n", "1.0 | \n", "NaN | \n", "46.161163 | \n", "-68.454887 | \n", "247.883514 | \n", "0.04 | \n", "0.39 | \n", "POINT (-68.45489 46.16116) | \n", "||
747 | \n", "1.0 | \n", "NaN | \n", "46.034088 | \n", "-68.064995 | \n", "190.345016 | \n", "0.02 | \n", "0.12 | \n", "POINT (-68.06499 46.03409) | \n", "||
759 | \n", "1.0 | \n", "NaN | \n", "46.022385 | \n", "-68.162132 | \n", "165.124863 | \n", "0.00 | \n", "0.17 | \n", "POINT (-68.16213 46.02238) | \n", "||
1581 | \n", "1.0 | \n", "NaN | \n", "45.648441 | \n", "-67.937202 | \n", "130.215378 | \n", "0.76 | \n", "0.96 | \n", "POINT (-67.93720 45.64844) | \n", "
<xarray.Dataset>\n", "Dimensions: (y: 61601, x: 71804, time: 24)\n", "Coordinates:\n", " * y (y) float64 5.102e+06 5.102e+06 ... 4.486e+06 4.486e+06\n", " * x (x) float64 -1.083e+05 -1.082e+05 ... 6.098e+05 6.098e+05\n", " spatial_ref int32 32613\n", " * time (time) datetime64[ns] 2022-07-01T18:09:31.024000 ... 2022-07...\n", "Data variables:\n", " B01 (time, y, x) float32 dask.array<chunksize=(1, 61601, 71804), meta=np.ndarray>\n", " B02 (time, y, x) float32 dask.array<chunksize=(1, 61601, 71804), meta=np.ndarray>\n", " B03 (time, y, x) float32 dask.array<chunksize=(1, 61601, 71804), meta=np.ndarray>