From 14879e3ba2d8c1bf23cc6803a28fab6e485e31b8 Mon Sep 17 00:00:00 2001 From: Matthew Iannucci Date: Fri, 19 Jul 2024 14:59:12 -0400 Subject: [PATCH] Add working stofs 3d support --- examples/stofs_2d.ipynb | 1241 +++++- examples/stofs_3d.ipynb | 6181 +++++++++++++++++++++++++++++ xarray_subset_grid/grids/ugrid.py | 3 +- 3 files changed, 7356 insertions(+), 69 deletions(-) create mode 100644 examples/stofs_3d.ipynb diff --git a/examples/stofs_2d.ipynb b/examples/stofs_2d.ipynb index 910f9e3..23e76c1 100644 --- a/examples/stofs_2d.ipynb +++ b/examples/stofs_2d.ipynb @@ -9,7 +9,1126 @@ }, { "cell_type": "code", - "execution_count": 1, + "execution_count": 3, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "
<xarray.Dataset> Size: 810MB\n",
+       "Dimensions:           (time: 4, node: 12785004, nele: 24875336, nvertex: 3,\n",
+       "                       mesh: 1, nbou: 262, nvel: 12421)\n",
+       "Coordinates:\n",
+       "  * time              (time) datetime64[ns] 32B 2024-06-19 ... 2024-06-26T12:...\n",
+       "    x                 (node) float64 102MB dask.array<chunksize=(511401,), meta=np.ndarray>\n",
+       "    y                 (node) float64 102MB dask.array<chunksize=(511401,), meta=np.ndarray>\n",
+       "Dimensions without coordinates: node, nele, nvertex, mesh, nbou, nvel\n",
+       "Data variables:\n",
+       "    element           (nele, nvertex) int32 299MB dask.array<chunksize=(2763927, 1), meta=np.ndarray>\n",
+       "    adcirc_mesh       (mesh) int32 4B dask.array<chunksize=(1,), meta=np.ndarray>\n",
+       "    nvell             (nbou) int32 1kB dask.array<chunksize=(262,), meta=np.ndarray>\n",
+       "    max_nvell         int32 4B ...\n",
+       "    ibtype            (nbou) int32 1kB dask.array<chunksize=(262,), meta=np.ndarray>\n",
+       "    nbvv              (nvel) int32 50kB dask.array<chunksize=(12421,), meta=np.ndarray>\n",
+       "    depth             (node) float64 102MB dask.array<chunksize=(511401,), meta=np.ndarray>\n",
+       "    wind_max          (node) float64 102MB dask.array<chunksize=(511401,), meta=np.ndarray>\n",
+       "    time_of_wind_max  (node) float64 102MB dask.array<chunksize=(511401,), meta=np.ndarray>\n",
+       "Attributes: (12/49)\n",
+       "    _FillValue:         -99999.0\n",
+       "    model:              ADCIRC\n",
+       "    version:            56.dev\n",
+       "    grid_type:          Triangular\n",
+       "    description:        2024061900 :-6 hr nowcast and +180 hr forecast ! 32 C...\n",
+       "    agrid:              OceanMesh2D\n",
+       "    ...                 ...\n",
+       "    sfea0:              45.0\n",
+       "    cf:                 0.001\n",
+       "    eslm:               -0.2\n",
+       "    cori:               0.0\n",
+       "    ntif:               8\n",
+       "    nbfr:               0
" + ], + "text/plain": [ + " Size: 810MB\n", + "Dimensions: (time: 4, node: 12785004, nele: 24875336, nvertex: 3,\n", + " mesh: 1, nbou: 262, nvel: 12421)\n", + "Coordinates:\n", + " * time (time) datetime64[ns] 32B 2024-06-19 ... 2024-06-26T12:...\n", + " x (node) float64 102MB dask.array\n", + " y (node) float64 102MB dask.array\n", + "Dimensions without coordinates: node, nele, nvertex, mesh, nbou, nvel\n", + "Data variables:\n", + " element (nele, nvertex) int32 299MB dask.array\n", + " adcirc_mesh (mesh) int32 4B dask.array\n", + " nvell (nbou) int32 1kB dask.array\n", + " max_nvell int32 4B ...\n", + " ibtype (nbou) int32 1kB dask.array\n", + " nbvv (nvel) int32 50kB dask.array\n", + " depth (node) float64 102MB dask.array\n", + " wind_max (node) float64 102MB dask.array\n", + " time_of_wind_max (node) float64 102MB dask.array\n", + "Attributes: (12/49)\n", + " _FillValue: -99999.0\n", + " model: ADCIRC\n", + " version: 56.dev\n", + " grid_type: Triangular\n", + " description: 2024061900 :-6 hr nowcast and +180 hr forecast ! 32 C...\n", + " agrid: OceanMesh2D\n", + " ... ...\n", + " sfea0: 45.0\n", + " cf: 0.001\n", + " eslm: -0.2\n", + " cori: 0.0\n", + " ntif: 8\n", + " nbfr: 0" + ] + }, + "execution_count": 3, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "import cf_xarray #noqa\n", + "import fsspec\n", + "import numpy as np\n", + "import xarray as xr\n", + "\n", + "import xarray_subset_grid\n", + "\n", + "# Open the dataset from NODD s3 bucket directly\n", + "fs = fsspec.filesystem(\"s3\")\n", + "ds = xr.open_dataset(\n", + " fs.open(\n", + " \"s3://noaa-gestofs-pds/_para2/stofs_2d_glo.20240619/stofs_2d_glo.t00z.fields.cwl.maxwvel.nc\"\n", + " ),\n", + " chunks={},\n", + " drop_variables=['nvel']\n", + ")\n", + "\n", + "ds" + ] + }, + { + "cell_type": "code", + "execution_count": 4, "metadata": {}, "outputs": [ { @@ -379,10 +1498,10 @@ " fill: currentColor;\n", "}\n", "
<xarray.Dataset> Size: 810MB\n",
-       "Dimensions:           (time: 3, node: 12785004, nele: 24875336, nvertex: 3,\n",
+       "Dimensions:           (time: 4, node: 12785004, nele: 24875336, nvertex: 3,\n",
        "                       mesh: 1, nbou: 262, nvel: 12421)\n",
        "Coordinates:\n",
-       "  * time              (time) datetime64[ns] 24B 2023-08-19 ... 2023-08-26T12:...\n",
+       "  * time              (time) datetime64[ns] 32B 2024-06-19 ... 2024-06-26T12:...\n",
        "    x                 (node) float64 102MB dask.array<chunksize=(511401,), meta=np.ndarray>\n",
        "    y                 (node) float64 102MB dask.array<chunksize=(511401,), meta=np.ndarray>\n",
        "Dimensions without coordinates: node, nele, nvertex, mesh, nbou, nvel\n",
@@ -401,7 +1520,7 @@
        "    model:              ADCIRC\n",
        "    version:            56.dev\n",
        "    grid_type:          Triangular\n",
-       "    description:        2023081900 :-6 hr nowcast and +180 hr forecast ! 32 C...\n",
+       "    description:        2024061900 :-6 hr nowcast and +180 hr forecast ! 32 C...\n",
        "    agrid:              OceanMesh2D\n",
        "    ...                 ...\n",
        "    sfea0:              45.0\n",
@@ -409,8 +1528,9 @@
        "    eslm:               -0.2\n",
        "    cori:               0.0\n",
        "    ntif:               8\n",
-       "    nbfr:               0