{ "cells": [ { "cell_type": "markdown", "id": "d741d57e-03a1-4c35-b6af-6273992cdb03", "metadata": {}, "source": [ "# Explore the National Water Model Reanalysis v2.1 \n", "\n", "\n", "### CASE 1: each HDF file contains chunks in multiple variables; doesn't need h5py\n", "\n", "370k files." ] }, { "cell_type": "code", "execution_count": 1, "id": "cab2ddcf", "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "/Users/mdurant/conda/envs/py38/lib/python3.8/site-packages/xarray/conventions.py:512: SerializationWarning: variable 'qBtmVertRunoff' has multiple fill values {-9999000, 0}, decoding all values to NaN.\n", " new_vars[k] = decode_cf_variable(\n", "/Users/mdurant/conda/envs/py38/lib/python3.8/site-packages/xarray/conventions.py:512: SerializationWarning: variable 'qBucket' has multiple fill values {-999900000, 0}, decoding all values to NaN.\n", " new_vars[k] = decode_cf_variable(\n", "/Users/mdurant/conda/envs/py38/lib/python3.8/site-packages/xarray/conventions.py:512: SerializationWarning: variable 'qSfcLatRunoff' has multiple fill values {-999900000, 0}, decoding all values to NaN.\n", " new_vars[k] = decode_cf_variable(\n", "/Users/mdurant/conda/envs/py38/lib/python3.8/site-packages/xarray/conventions.py:512: SerializationWarning: variable 'q_lateral' has multiple fill values {0, -99990}, decoding all values to NaN.\n", " new_vars[k] = decode_cf_variable(\n", "/Users/mdurant/conda/envs/py38/lib/python3.8/site-packages/xarray/conventions.py:512: SerializationWarning: variable 'streamflow' has multiple fill values {0, -999900}, decoding all values to NaN.\n", " new_vars[k] = decode_cf_variable(\n", "/Users/mdurant/conda/envs/py38/lib/python3.8/site-packages/xarray/conventions.py:512: SerializationWarning: variable 'velocity' has multiple fill values {0, -999900}, decoding all values to NaN.\n", " new_vars[k] = decode_cf_variable(\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "CPU times: user 38.5 s, sys: 1.56 s, total: 40.1 s\n", "Wall time: 45.3 s\n" ] } ], "source": [ "%%time\n", "import fsspec\n", "import xarray as xr\n", "mapper = fsspec.get_mapper(\n", " \"reference://\",\n", " fo=\"s3://esip-qhub-public/noaa/nwm/nwm_reanalysis.json.zst\",\n", " target_options={\n", " \"anon\": True,\n", " \"compression\": \"zstd\"\n", " },\n", " remote_options={\"anon\": True}\n", ")\n", "ds = xr.open_dataset(mapper, engine=\"zarr\", backend_kwargs={\"consolidated\": False})" ] }, { "cell_type": "code", "execution_count": 2, "id": "c656c93e-9c10-4676-a8c0-3e7f24306f70", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
<xarray.Dataset>\n",
"Dimensions: (time: 367439, feature_id: 2776738)\n",
"Coordinates:\n",
" * feature_id (feature_id) float64 101.0 179.0 181.0 ... 1.18e+09 1.18e+09\n",
" latitude (feature_id) float32 ...\n",
" longitude (feature_id) float32 ...\n",
" * time (time) datetime64[ns] 1979-02-01T01:00:00 ... 2020-12-31T...\n",
"Data variables:\n",
" elevation (time, feature_id) float32 ...\n",
" order (time, feature_id) float64 ...\n",
" qBtmVertRunoff (time, feature_id) float64 ...\n",
" qBucket (time, feature_id) float64 ...\n",
" qSfcLatRunoff (time, feature_id) float64 ...\n",
" q_lateral (time, feature_id) float64 ...\n",
" streamflow (time, feature_id) float64 ...\n",
" velocity (time, feature_id) float64 ...\n",
"Attributes: (12/19)\n",
" Conventions: CF-1.6\n",
" TITLE: OUTPUT FROM WRF-Hydro v5.2.0-beta2\n",
" _NCProperties: version=2,netcdf=4.7.4,hdf5=1.10.7,\n",
" cdm_datatype: Station\n",
" code_version: v5.2.0-beta2\n",
" dev: dev_ prefix indicates development/internal me...\n",
" ... ...\n",
" model_output_type: channel_rt\n",
" model_output_valid_time: 1979-02-01_01:00:00\n",
" model_total_valid_times: 1416\n",
" proj4: +proj=lcc +units=m +a=6370000.0 +b=6370000.0 ...\n",
" station_dimension: feature_id\n",
" stream_order_output: 1array([1.010000e+02, 1.790000e+02, 1.810000e+02, ..., 1.180002e+09,\n",
" 1.180002e+09, 1.180002e+09])[2776738 values with dtype=float32]
[2776738 values with dtype=float32]
array(['1979-02-01T01:00:00.000000000', '1979-02-01T02:00:00.000000000',\n",
" '1979-02-01T03:00:00.000000000', ..., '2020-12-31T21:00:00.000000000',\n",
" '2020-12-31T22:00:00.000000000', '2020-12-31T23:00:00.000000000'],\n",
" dtype='datetime64[ns]')[1020281833982 values with dtype=float32]
[1020281833982 values with dtype=float64]
[1020281833982 values with dtype=float64]
[1020281833982 values with dtype=float64]
[1020281833982 values with dtype=float64]
[1020281833982 values with dtype=float64]
[1020281833982 values with dtype=float64]
[1020281833982 values with dtype=float64]