diff --git a/Jupyter_notebooks/1.2-rotated_grids.ipynb b/Jupyter_notebooks/1.2-rotated_grids.ipynb index 41ef31309f56d2040926dc637c26e97f335f5bf6..9ace309cd1f519f0977b568452fa71f07a45de01 100644 --- a/Jupyter_notebooks/1.2-rotated_grids.ipynb +++ b/Jupyter_notebooks/1.2-rotated_grids.ipynb @@ -415,14 +415,14 @@ " rotated_pole |S1 b''\n", "Attributes:\n", " Conventions: CF-1.7\n", - " comment: Generated on marenostrum4
  • Conventions :
    CF-1.7
    comment :
    Generated on marenostrum4
  • " ], "text/plain": [ "\n", @@ -483,7 +483,7 @@ { "data": { "text/plain": [ - "" + "" ] }, "execution_count": 4, @@ -783,6 +783,7 @@ "Rank 000: Dimensions done\n", "Rank 000: Writing O3_all var (1/1)\n", "Rank 000: Var O3_all created (1/1)\n", + "Rank 000: Filling O3_all)\n", "Rank 000: Var O3_all data (1/1)\n", "Rank 000: Var O3_all completed (1/1)\n" ] @@ -809,7 +810,7 @@ { "data": { "text/plain": [ - "" + "" ] }, "execution_count": 12, @@ -1182,28 +1183,29 @@ " fill: currentColor;\n", "}\n", "
    <xarray.Dataset>\n",
    -       "Dimensions:    (time: 1, time_nv: 2, lev: 24, rlat: 271, rlon: 351)\n",
    +       "Dimensions:       (time: 1, time_nv: 2, lev: 24, rlat: 271, rlon: 351)\n",
            "Coordinates:\n",
    -       "  * time       (time) datetime64[ns] 2021-08-03\n",
    -       "  * lev        (lev) float64 0.0 1.0 2.0 3.0 4.0 ... 19.0 20.0 21.0 22.0 23.0\n",
    -       "    lat        (rlat, rlon) float64 16.35 16.43 16.52 16.6 ... 58.83 58.68 58.53\n",
    -       "    lon        (rlat, rlon) float64 -22.18 -22.02 -21.85 ... 87.87 88.05 88.23\n",
    -       "  * rlat       (rlat) float64 -27.0 -26.8 -26.6 -26.4 ... 26.4 26.6 26.8 27.0\n",
    -       "  * rlon       (rlon) float64 -35.0 -34.8 -34.6 -34.4 ... 34.4 34.6 34.8 35.0\n",
    +       "  * time          (time) datetime64[ns] 2021-08-03\n",
    +       "  * lev           (lev) float64 0.0 1.0 2.0 3.0 4.0 ... 19.0 20.0 21.0 22.0 23.0\n",
    +       "    lat           (rlat, rlon) float64 16.35 16.43 16.52 ... 58.83 58.68 58.53\n",
    +       "    lon           (rlat, rlon) float64 -22.18 -22.02 -21.85 ... 88.05 88.23\n",
    +       "  * rlat          (rlat) float64 -27.0 -26.8 -26.6 -26.4 ... 26.4 26.6 26.8 27.0\n",
    +       "  * rlon          (rlon) float64 -35.0 -34.8 -34.6 -34.4 ... 34.4 34.6 34.8 35.0\n",
            "Dimensions without coordinates: time_nv\n",
            "Data variables:\n",
    -       "    time_bnds  (time, time_nv) datetime64[ns] 2021-08-03 2021-08-07\n",
    -       "    O3_all     (time, lev, rlat, rlon) float32 ...\n",
    +       "    time_bnds     (time, time_nv) datetime64[ns] 2021-08-03 2021-08-07\n",
    +       "    O3_all        (time, lev, rlat, rlon) float32 ...\n",
    +       "    rotated_pole  |S1 b''\n",
            "Attributes:\n",
            "    Conventions:  CF-1.7\n",
    -       "    comment:      Generated on marenostrum4
    • time_bnds
      (time, time_nv)
      datetime64[ns]
      ...
      array([['2021-08-03T00:00:00.000000000', '2021-08-07T00:00:00.000000000']],\n",
      +       "      dtype='datetime64[ns]')
    • O3_all
      (time, lev, rlat, rlon)
      float32
      ...
      units :
      kg/m3
      long_name :
      TRACERS_044
      cell_methods :
      time: maximum (interval: 1hr)
      grid_mapping :
      rotated_pole
      [2282904 values with dtype=float32]
    • rotated_pole
      ()
      |S1
      ...
      grid_mapping_name :
      rotated_latitude_longitude
      grid_north_pole_latitude :
      39.0
      grid_north_pole_longitude :
      -170.0
      array(b'', dtype='|S1')
  • Conventions :
    CF-1.7
    comment :
    Generated on marenostrum4
  • " ], "text/plain": [ "\n", - "Dimensions: (time: 1, time_nv: 2, lev: 24, rlat: 271, rlon: 351)\n", + "Dimensions: (time: 1, time_nv: 2, lev: 24, rlat: 271, rlon: 351)\n", "Coordinates:\n", - " * time (time) datetime64[ns] 2021-08-03\n", - " * lev (lev) float64 0.0 1.0 2.0 3.0 4.0 ... 19.0 20.0 21.0 22.0 23.0\n", - " lat (rlat, rlon) float64 ...\n", - " lon (rlat, rlon) float64 ...\n", - " * rlat (rlat) float64 -27.0 -26.8 -26.6 -26.4 ... 26.4 26.6 26.8 27.0\n", - " * rlon (rlon) float64 -35.0 -34.8 -34.6 -34.4 ... 34.4 34.6 34.8 35.0\n", + " * time (time) datetime64[ns] 2021-08-03\n", + " * lev (lev) float64 0.0 1.0 2.0 3.0 4.0 ... 19.0 20.0 21.0 22.0 23.0\n", + " lat (rlat, rlon) float64 ...\n", + " lon (rlat, rlon) float64 ...\n", + " * rlat (rlat) float64 -27.0 -26.8 -26.6 -26.4 ... 26.4 26.6 26.8 27.0\n", + " * rlon (rlon) float64 -35.0 -34.8 -34.6 -34.4 ... 34.4 34.6 34.8 35.0\n", "Dimensions without coordinates: time_nv\n", "Data variables:\n", - " time_bnds (time, time_nv) datetime64[ns] ...\n", - " O3_all (time, lev, rlat, rlon) float32 ...\n", + " time_bnds (time, time_nv) datetime64[ns] ...\n", + " O3_all (time, lev, rlat, rlon) float32 ...\n", + " rotated_pole |S1 ...\n", "Attributes:\n", " Conventions: CF-1.7\n", " comment: Generated on marenostrum4" diff --git a/Jupyter_notebooks/1.4-lcc_grids.ipynb b/Jupyter_notebooks/1.4-lcc_grids.ipynb new file mode 100644 index 0000000000000000000000000000000000000000..1d4a0f25e464fe79303033639adfad9e8c1f5212 --- /dev/null +++ b/Jupyter_notebooks/1.4-lcc_grids.ipynb @@ -0,0 +1,1710 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# How to read and write LCC grids" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": {}, + "outputs": [], + "source": [ + "from nes import *\n", + "import xarray as xr" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": {}, + "outputs": [], + "source": [ + "nc_path_1 = '/esarchive/exp/wrf-hermes-cmaq/b075/eu/hourly/pm10/pm10_2022062600.nc'" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## 1. Read and write" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Open with xarray" + ] + }, + { + "cell_type": "code", + "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>\n",
    +       "Dimensions:            (time: 48, y: 398, x: 478, lev: 1)\n",
    +       "Coordinates:\n",
    +       "  * time               (time) datetime64[ns] 2022-06-26 ... 2022-06-27T23:00:00\n",
    +       "    lat                (y, x) float32 ...\n",
    +       "    lon                (y, x) float32 ...\n",
    +       "  * x                  (x) float64 -2.126e+06 -2.114e+06 ... 3.586e+06 3.598e+06\n",
    +       "  * y                  (y) float64 -2.067e+06 -2.055e+06 ... 2.685e+06 2.697e+06\n",
    +       "  * lev                (lev) float32 0.0\n",
    +       "Data variables:\n",
    +       "    pm10               (time, lev, y, x) float32 ...\n",
    +       "    Lambert_conformal  int32 -2147483647
    " + ], + "text/plain": [ + "\n", + "Dimensions: (time: 48, y: 398, x: 478, lev: 1)\n", + "Coordinates:\n", + " * time (time) datetime64[ns] 2022-06-26 ... 2022-06-27T23:00:00\n", + " lat (y, x) float32 ...\n", + " lon (y, x) float32 ...\n", + " * x (x) float64 -2.126e+06 -2.114e+06 ... 3.586e+06 3.598e+06\n", + " * y (y) float64 -2.067e+06 -2.055e+06 ... 2.685e+06 2.697e+06\n", + " * lev (lev) float32 0.0\n", + "Data variables:\n", + " pm10 (time, lev, y, x) float32 ...\n", + " Lambert_conformal int32 ..." + ] + }, + "execution_count": 3, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "xr.open_dataset(nc_path_1)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Open with NES" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "" + ] + }, + "execution_count": 4, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "nessy_1 = open_netcdf(path=nc_path_1, info=True)\n", + "nessy_1" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "[datetime.datetime(2022, 6, 26, 0, 0),\n", + " datetime.datetime(2022, 6, 26, 1, 0),\n", + " datetime.datetime(2022, 6, 26, 2, 0),\n", + " datetime.datetime(2022, 6, 26, 3, 0),\n", + " datetime.datetime(2022, 6, 26, 4, 0),\n", + " datetime.datetime(2022, 6, 26, 5, 0),\n", + " datetime.datetime(2022, 6, 26, 6, 0),\n", + " datetime.datetime(2022, 6, 26, 7, 0),\n", + " datetime.datetime(2022, 6, 26, 8, 0),\n", + " datetime.datetime(2022, 6, 26, 9, 0),\n", + " datetime.datetime(2022, 6, 26, 10, 0),\n", + " datetime.datetime(2022, 6, 26, 11, 0),\n", + " datetime.datetime(2022, 6, 26, 12, 0),\n", + " datetime.datetime(2022, 6, 26, 13, 0),\n", + " datetime.datetime(2022, 6, 26, 14, 0),\n", + " datetime.datetime(2022, 6, 26, 15, 0),\n", + " datetime.datetime(2022, 6, 26, 16, 0),\n", + " datetime.datetime(2022, 6, 26, 17, 0),\n", + " datetime.datetime(2022, 6, 26, 18, 0),\n", + " datetime.datetime(2022, 6, 26, 19, 0),\n", + " datetime.datetime(2022, 6, 26, 20, 0),\n", + " datetime.datetime(2022, 6, 26, 21, 0),\n", + " datetime.datetime(2022, 6, 26, 22, 0),\n", + " datetime.datetime(2022, 6, 26, 23, 0),\n", + " datetime.datetime(2022, 6, 27, 0, 0),\n", + " datetime.datetime(2022, 6, 27, 1, 0),\n", + " datetime.datetime(2022, 6, 27, 2, 0),\n", + " datetime.datetime(2022, 6, 27, 3, 0),\n", + " datetime.datetime(2022, 6, 27, 4, 0),\n", + " datetime.datetime(2022, 6, 27, 5, 0),\n", + " datetime.datetime(2022, 6, 27, 6, 0),\n", + " datetime.datetime(2022, 6, 27, 7, 0),\n", + " datetime.datetime(2022, 6, 27, 8, 0),\n", + " datetime.datetime(2022, 6, 27, 9, 0),\n", + " datetime.datetime(2022, 6, 27, 10, 0),\n", + " datetime.datetime(2022, 6, 27, 11, 0),\n", + " datetime.datetime(2022, 6, 27, 12, 0),\n", + " datetime.datetime(2022, 6, 27, 13, 0),\n", + " datetime.datetime(2022, 6, 27, 14, 0),\n", + " datetime.datetime(2022, 6, 27, 15, 0),\n", + " datetime.datetime(2022, 6, 27, 16, 0),\n", + " datetime.datetime(2022, 6, 27, 17, 0),\n", + " datetime.datetime(2022, 6, 27, 18, 0),\n", + " datetime.datetime(2022, 6, 27, 19, 0),\n", + " datetime.datetime(2022, 6, 27, 20, 0),\n", + " datetime.datetime(2022, 6, 27, 21, 0),\n", + " datetime.datetime(2022, 6, 27, 22, 0),\n", + " datetime.datetime(2022, 6, 27, 23, 0)]" + ] + }, + "execution_count": 5, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "nessy_1.time" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "{'data': masked_array(data=[0.],\n", + " mask=False,\n", + " fill_value=1e+20,\n", + " dtype=float32), 'dimensions': ('lev',), 'positive': 'up'}" + ] + }, + "execution_count": 6, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "nessy_1.lev" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "{'data': masked_array(data=[-2.12584753e+06, -2.11384761e+06, -2.10184701e+06,\n", + " -2.08984901e+06, -2.07784716e+06, -2.06584784e+06,\n", + " -2.05384791e+06, -2.04185027e+06, -2.02984883e+06,\n", + " -2.01784924e+06, -2.00584929e+06, -1.99384819e+06,\n", + " -1.98184942e+06, -1.96984999e+06, -1.95784950e+06,\n", + " -1.94584776e+06, -1.93384820e+06, -1.92184804e+06,\n", + " -1.90984965e+06, -1.89784727e+06, -1.88584974e+06,\n", + " -1.87384798e+06, -1.86184856e+06, -1.84984781e+06,\n", + " -1.83784882e+06, -1.82584878e+06, -1.81384730e+06,\n", + " -1.80184766e+06, -1.78985000e+06, -1.77784784e+06,\n", + " -1.76584709e+06, -1.75384839e+06, -1.74184822e+06,\n", + " -1.72984970e+06, -1.71784950e+06, -1.70584804e+06,\n", + " -1.69384799e+06, -1.68184961e+06, -1.66984941e+06,\n", + " -1.65784782e+06, -1.64584735e+06, -1.63384873e+06,\n", + " -1.62184786e+06, -1.60984877e+06, -1.59784781e+06,\n", + " -1.58584811e+06, -1.57384978e+06, -1.56184949e+06,\n", + " -1.54984706e+06, -1.53784949e+06, -1.52584971e+06,\n", + " -1.51384784e+06, -1.50185029e+06, -1.48984741e+06,\n", + " -1.47784881e+06, -1.46584796e+06, -1.45384829e+06,\n", + " -1.44184935e+06, -1.42984834e+06, -1.41784813e+06,\n", + " -1.40584895e+06, -1.39384732e+06, -1.38184958e+06,\n", + " -1.36984970e+06, -1.35784703e+06, -1.34584852e+06,\n", + " -1.33384739e+06, -1.32185023e+06, -1.30984708e+06,\n", + " -1.29784782e+06, -1.28584924e+06, -1.27384787e+06,\n", + " -1.26185017e+06, -1.24984974e+06, -1.23784984e+06,\n", + " -1.22584679e+06, -1.21384762e+06, -1.20184864e+06,\n", + " -1.18985017e+06, -1.17784863e+06, -1.16584730e+06,\n", + " -1.15384933e+06, -1.14184842e+06, -1.12984761e+06,\n", + " -1.11785016e+06, -1.10584945e+06, -1.09384884e+06,\n", + " -1.08184809e+06, -1.06984737e+06, -1.05784994e+06,\n", + " -1.04584897e+06, -1.03384802e+06, -1.02185016e+06,\n", + " -1.00984874e+06, -9.97847138e+05, -9.85848430e+05,\n", + " -9.73849460e+05, -9.61850193e+05, -9.49847198e+05,\n", + " -9.37847136e+05, -9.25849883e+05, -9.13848882e+05,\n", + " -9.01847317e+05, -8.89848619e+05, -8.77849203e+05,\n", + " -8.65849037e+05, -8.53848483e+05, -8.41850255e+05,\n", + " -8.29848103e+05, -8.17848443e+05, -8.05848159e+05,\n", + " -7.93850146e+05, -7.81847983e+05, -7.69848242e+05,\n", + " -7.57847649e+05, -7.45849126e+05, -7.33849816e+05,\n", + " -7.21849273e+05, -7.09847665e+05, -6.97848323e+05,\n", + " -6.85847775e+05, -6.73849354e+05, -6.61849656e+05,\n", + " -6.49848767e+05, -6.37849773e+05, -6.25849455e+05,\n", + " -6.13847832e+05, -6.01848000e+05, -5.89850037e+05,\n", + " -5.77847297e+05, -5.65849601e+05, -5.53850360e+05,\n", + " -5.41849485e+05, -5.29850392e+05, -5.17849446e+05,\n", + " -5.05850300e+05, -4.93849326e+05, -4.81849796e+05,\n", + " -4.69848463e+05, -4.57848676e+05, -4.45850309e+05,\n", + " -4.33849861e+05, -4.21847579e+05, -4.09849797e+05,\n", + " -3.97850061e+05, -3.85848258e+05, -3.73847618e+05,\n", + " -3.61848107e+05, -3.49849786e+05, -3.37849091e+05,\n", + " -3.25849544e+05, -3.13847764e+05, -3.01850147e+05,\n", + " -2.89850223e+05, -2.77847869e+05, -2.65849682e+05,\n", + " -2.53848995e+05, -2.41849099e+05, -2.29849935e+05,\n", + " -2.17848225e+05, -2.05850456e+05, -1.93850007e+05,\n", + " -1.81850198e+05, -1.69847633e+05, -1.57848901e+05,\n", + " -1.45847355e+05, -1.33849541e+05, -1.21848866e+05,\n", + " -1.09848557e+05, -9.78485812e+04, -8.58489110e+04,\n", + " -7.38495157e+04, -6.18503428e+04, -4.98480588e+04,\n", + " -3.78492294e+04, -2.58472156e+04, -1.38485865e+04,\n", + " -1.85000093e+03, 1.01518839e+04, 2.21504974e+04,\n", + " 3.41524846e+04, 4.61512675e+04, 5.81502025e+04,\n", + " 7.01526052e+04, 8.21519418e+04, 9.41515115e+04,\n", + " 1.06151401e+05, 1.18151593e+05, 1.30152150e+05,\n", + " 1.42149821e+05, 1.54151239e+05, 1.66149805e+05,\n", + " 1.78152206e+05, 1.90151841e+05, 2.02152103e+05,\n", + " 2.14149676e+05, 2.26151179e+05, 2.38150101e+05,\n", + " 2.50149789e+05, 2.62150163e+05, 2.74151423e+05,\n", + " 2.86150208e+05, 2.98149857e+05, 3.10150460e+05,\n", + " 3.22152060e+05, 3.34151271e+05, 3.46151519e+05,\n", + " 3.58149605e+05, 3.70152044e+05, 3.82152331e+05,\n", + " 3.94150502e+05, 4.06149863e+05, 4.18150448e+05,\n", + " 4.30152410e+05, 4.42152326e+05, 4.54150354e+05,\n", + " 4.66149752e+05, 4.78150600e+05, 4.90149630e+05,\n", + " 5.02150092e+05, 5.14152159e+05, 5.26152471e+05,\n", + " 5.38151163e+05, 5.50151477e+05, 5.62150197e+05,\n", + " 5.74150715e+05, 5.86149501e+05, 5.98150157e+05,\n", + " 6.10149476e+05, 6.22150579e+05, 6.34150250e+05,\n", + " 6.46151947e+05, 6.58152226e+05, 6.70151301e+05,\n", + " 6.82152394e+05, 6.94152233e+05, 7.06151050e+05,\n", + " 7.18151992e+05, 7.30151725e+05, 7.42150415e+05,\n", + " 7.54151335e+05, 7.66151356e+05, 7.78150447e+05,\n", + " 7.90151805e+05, 8.02152305e+05, 8.14151909e+05,\n", + " 8.26150803e+05, 8.38152179e+05, 8.50149463e+05,\n", + " 8.62152600e+05, 8.74151875e+05, 8.86150469e+05,\n", + " 8.98151720e+05, 9.10152442e+05, 9.22152590e+05,\n", + " 9.34152281e+05, 9.46151555e+05, 9.58150185e+05,\n", + " 9.70151947e+05, 9.82150008e+05, 9.94151009e+05,\n", + " 1.00615168e+06, 1.01815215e+06, 1.03015237e+06,\n", + " 1.04215255e+06, 1.05415245e+06, 1.06615219e+06,\n", + " 1.07815192e+06, 1.09015146e+06, 1.10215106e+06,\n", + " 1.11415084e+06, 1.12615055e+06, 1.13815031e+06,\n", + " 1.15015027e+06, 1.16215026e+06, 1.17415050e+06,\n", + " 1.18615117e+06, 1.19815184e+06, 1.21014970e+06,\n", + " 1.22215106e+06, 1.23414955e+06, 1.24615161e+06,\n", + " 1.25815089e+06, 1.27015072e+06, 1.28215091e+06,\n", + " 1.29415184e+06, 1.30614966e+06, 1.31815171e+06,\n", + " 1.33015072e+06, 1.34215086e+06, 1.35415143e+06,\n", + " 1.36614929e+06, 1.37815146e+06, 1.39015111e+06,\n", + " 1.40215157e+06, 1.41414946e+06, 1.42615154e+06,\n", + " 1.43815149e+06, 1.45015214e+06, 1.46215061e+06,\n", + " 1.47414997e+06, 1.48615052e+06, 1.49815230e+06,\n", + " 1.51015149e+06, 1.52215197e+06, 1.53415035e+06,\n", + " 1.54615023e+06, 1.55815110e+06, 1.57015010e+06,\n", + " 1.58215014e+06, 1.59415154e+06, 1.60615118e+06,\n", + " 1.61815225e+06, 1.63015134e+06, 1.64215177e+06,\n", + " 1.65415073e+06, 1.66615110e+06, 1.67814931e+06,\n", + " 1.69014976e+06, 1.70215157e+06, 1.71415178e+06,\n", + " 1.72615026e+06, 1.73815066e+06, 1.75015254e+06,\n", + " 1.76214949e+06, 1.77415192e+06, 1.78614949e+06,\n", + " 1.79815196e+06, 1.81015012e+06, 1.82214994e+06,\n", + " 1.83415163e+06, 1.84615225e+06, 1.85815149e+06,\n", + " 1.87014939e+06, 1.88214927e+06, 1.89415152e+06,\n", + " 1.90615253e+06, 1.91815231e+06, 1.93015091e+06,\n", + " 1.94215219e+06, 1.95415199e+06, 1.96615088e+06,\n", + " 1.97815184e+06, 1.99015212e+06, 2.00215141e+06,\n", + " 2.01414974e+06, 2.02615043e+06, 2.03815022e+06,\n", + " 2.05014932e+06, 2.06215089e+06, 2.07415183e+06,\n", + " 2.08615200e+06, 2.09815142e+06, 2.11015031e+06,\n", + " 2.12215125e+06, 2.13415212e+06, 2.14615216e+06,\n", + " 2.15815181e+06, 2.17015090e+06, 2.18215236e+06,\n", + " 2.19415062e+06, 2.20615132e+06, 2.21815157e+06,\n", + " 2.23015162e+06, 2.24215129e+06, 2.25415041e+06,\n", + " 2.26614942e+06, 2.27815103e+06, 2.29014950e+06,\n", + " 2.30215084e+06, 2.31415199e+06, 2.32614967e+06,\n", + " 2.33815052e+06, 2.35015105e+06, 2.36215151e+06,\n", + " 2.37415171e+06, 2.38615211e+06, 2.39815209e+06,\n", + " 2.41014925e+06, 2.42214936e+06, 2.43414979e+06,\n", + " 2.44615014e+06, 2.45815065e+06, 2.47015092e+06,\n", + " 2.48215186e+06, 2.49414885e+06, 2.50615033e+06,\n", + " 2.51815099e+06, 2.53014892e+06, 2.54215075e+06,\n", + " 2.55414946e+06, 2.56615190e+06, 2.57815081e+06,\n", + " 2.59015090e+06, 2.60215059e+06, 2.61415105e+06,\n", + " 2.62615163e+06, 2.63814974e+06, 2.65015084e+06,\n", + " 2.66215003e+06, 2.67414918e+06, 2.68614955e+06,\n", + " 2.69814946e+06, 2.71015063e+06, 2.72215238e+06,\n", + " 2.73415141e+06, 2.74615082e+06, 2.75815088e+06,\n", + " 2.77015212e+06, 2.78215001e+06, 2.79414938e+06,\n", + " 2.80614927e+06, 2.81814994e+06, 2.83015143e+06,\n", + " 2.84215046e+06, 2.85415010e+06, 2.86615064e+06,\n", + " 2.87815237e+06, 2.89015096e+06, 2.90215132e+06,\n", + " 2.91415163e+06, 2.92615073e+06, 2.93815062e+06,\n", + " 2.95015108e+06, 2.96214987e+06, 2.97415232e+06,\n", + " 2.98614959e+06, 2.99815110e+06, 3.01015052e+06,\n", + " 3.02215092e+06, 3.03414984e+06, 3.04615228e+06,\n", + " 3.05814999e+06, 3.07015153e+06, 3.08215198e+06,\n", + " 3.09414943e+06, 3.10615189e+06, 3.11815252e+06,\n", + " 3.13015077e+06, 3.14215026e+06, 3.15415157e+06,\n", + " 3.16615058e+06, 3.17815090e+06, 3.19015010e+06,\n", + " 3.20214982e+06, 3.21415120e+06, 3.22615069e+06,\n", + " 3.23815162e+06, 3.25015100e+06, 3.26215215e+06,\n", + " 3.27415093e+06, 3.28615124e+06, 3.29815011e+06,\n", + " 3.31015056e+06, 3.32214902e+06, 3.33414971e+06,\n", + " 3.34615147e+06, 3.35815161e+06, 3.37014985e+06,\n", + " 3.38215073e+06, 3.39415246e+06, 3.40614937e+06,\n", + " 3.41815139e+06, 3.43015224e+06, 3.44215134e+06,\n", + " 3.45415201e+06, 3.46615129e+06, 3.47814888e+06,\n", + " 3.49015204e+06, 3.50214995e+06, 3.51415017e+06,\n", + " 3.52615242e+06, 3.53814916e+06, 3.55015129e+06,\n", + " 3.56214954e+06, 3.57415226e+06, 3.58615021e+06,\n", + " 3.59815064e+06],\n", + " mask=False,\n", + " fill_value=1e+20),\n", + " 'dimensions': ('x',),\n", + " 'units': 'm',\n", + " 'long_name': 'x coordinate of projection',\n", + " 'standard_name': 'projection_x_coordinate'}" + ] + }, + "execution_count": 7, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "nessy_1.x" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "{'data': masked_array(data=[-2067138.47948561, -2055138.33742867,\n", + " -2043137.54665598, -2031137.11044915,\n", + " -2019137.8807928 , -2007138.08379361,\n", + " -1995137.55201761, -1983138.30318791,\n", + " -1971139.14829968, -1959137.5926525 ,\n", + " -1947137.10543589, -1935138.53320712,\n", + " -1923137.4951208 , -1911137.45400782,\n", + " -1899138.2432851 , -1887137.51394029,\n", + " -1875138.43810423, -1863136.92956926,\n", + " -1851137.89552799, -1839137.1121049 ,\n", + " -1827137.15927377, -1815138.01203912,\n", + " -1803138.7795864 , -1791137.70775766,\n", + " -1779137.3704284 , -1767137.74254063,\n", + " -1755137.93518378, -1743137.06138263,\n", + " -1731137.6875659 , -1719137.19999768,\n", + " -1707136.43834552, -1695137.96319842,\n", + " -1683137.44174755, -1671137.43454641,\n", + " -1659137.056387 , -1647138.00256504,\n", + " -1635137.66921584, -1623136.89251186,\n", + " -1611137.36489549, -1599137.34432241,\n", + " -1587137.79320469, -1575137.57084194,\n", + " -1563136.9109904 , -1551137.37235623,\n", + " -1539137.94554037, -1527137.1502086 ,\n", + " -1515138.25410466, -1503138.66687657,\n", + " -1491138.4899473 , -1479136.59453581,\n", + " -1467137.47233746, -1455137.55905622,\n", + " -1443137.68244934, -1431137.81703208,\n", + " -1419138.78837709, -1407138.99088641,\n", + " -1395137.42673134, -1383137.47212092,\n", + " -1371137.40019024, -1359138.03433592,\n", + " -1347136.9224302 , -1335137.31271794,\n", + " -1323137.4816182 , -1311137.94634304,\n", + " -1299137.29022577, -1287137.1818736 ,\n", + " -1275137.59439096, -1263136.92697495,\n", + " -1251137.57275311, -1239136.12380517,\n", + " -1227137.6241066 , -1215137.51625937,\n", + " -1203137.04074528, -1191137.62692217,\n", + " -1179138.21301879, -1167137.50751754,\n", + " -1155137.89726681, -1143138.09129864,\n", + " -1131138.06316848, -1119137.05825655,\n", + " -1107137.15205236, -1095138.20305536,\n", + " -1083138.08298794, -1071137.18627622,\n", + " -1059138.64697368, -1047138.74478058,\n", + " -1035138.51485085, -1023137.92955771,\n", + " -1011137.6894263 , -999137.45744737,\n", + " -987137.51499851, -975137.83442915,\n", + " -963137.76831308, -951139.05433923,\n", + " -939137.39017683, -927137.54863286,\n", + " -915138.66481437, -903137.47725183,\n", + " -891138.44385041, -879137.99257723,\n", + " -867138.69715018, -855137.92810361,\n", + " -843137.53065969, -831137.99786638,\n", + " -819138.36299108, -807137.87013262,\n", + " -795137.32354617, -783137.83855245,\n", + " -771137.41075253, -759138.09010529,\n", + " -747137.76958547, -735137.98006167,\n", + " -723137.5495894 , -711137.6947773 ,\n", + " -699137.86979959, -687138.5622281 ,\n", + " -675137.66992397, -663138.06610574,\n", + " -651137.23497902, -639136.80506847,\n", + " -627138.30290647, -615137.65946231,\n", + " -603138.15712078, -591136.87075576,\n", + " -579137.08014637, -567137.82964577,\n", + " -555137.63384505, -543137.50696179,\n", + " -531138.0283756 , -519137.73451411,\n", + " -507137.93240193, -495137.45153707,\n", + " -483137.30641057, -471137.15203014,\n", + " -459138.19530608, -447138.75770337,\n", + " -435136.43449817, -423137.59544964,\n", + " -411136.54082615, -399138.59271965,\n", + " -387138.05393281, -375137.17535161,\n", + " -363137.35013412, -351138.04215929,\n", + " -339138.30575139, -327138.29921261,\n", + " -315137.89921544, -303137.58006488,\n", + " -291137.12571846, -279137.5132003 ,\n", + " -267137.79855472, -255137.95212261,\n", + " -243138.35433354, -231138.15527529,\n", + " -219137.41721347, -207138.06770319,\n", + " -195138.02753911, -183138.17757006,\n", + " -171137.98702931, -159138.24510045,\n", + " -147137.37488813, -135137.71176692,\n", + " -123137.99774014, -111137.06580801,\n", + " -99137.65919525, -87138.52051766,\n", + " -75137.66532798, -63138.24447606,\n", + " -51137.45613798, -39138.44989177,\n", + " -27137.19935201, -15137.26193513,\n", + " -3138.2870129 , 8862.70158754,\n", + " 20863.19613188, 32862.09109349,\n", + " 44862.1850711 , 56862.28417564,\n", + " 68862.09833787, 80862.79348443,\n", + " 92862.04079618, 104861.82177242,\n", + " 116861.75894296, 128861.96917478,\n", + " 140861.98836512, 152861.43960268,\n", + " 164861.6613091 , 176862.10360022,\n", + " 188862.1547975 , 200862.57312437,\n", + " 212861.43960038, 224862.6824761 ,\n", + " 236862.02704646, 248862.67280663,\n", + " 260861.80232975, 272862.69968633,\n", + " 284863.03968892, 296862.27594177,\n", + " 308863.36959344, 320862.7767121 ,\n", + " 332862.79683064, 344861.59736628,\n", + " 356861.88372131, 368861.82305626,\n", + " 380861.27672775, 392861.25573027,\n", + " 404862.83978888, 416862.48790187,\n", + " 428862.26071291, 440862.59403697,\n", + " 452861.89377259, 464861.81366973,\n", + " 476862.70563957, 488861.51974816,\n", + " 500861.77140022, 512861.95044987,\n", + " 524862.40904252, 536862.85449188,\n", + " 548862.09945016, 560862.20196287,\n", + " 572862.70276656, 584862.09217358,\n", + " 596862.4276693 , 608861.6280585 ,\n", + " 620861.42797071, 632862.17940113,\n", + " 644862.3726426 , 656861.95444672,\n", + " 668862.65863139, 680862.81014377,\n", + " 692862.52099743, 704861.41511084,\n", + " 716862.19408409, 728863.02536633,\n", + " 740861.50621775, 752862.36459892,\n", + " 764861.74143799, 776862.50273099,\n", + " 788863.2968091 , 800862.6963584 ,\n", + " 812861.94605002, 824861.7205462 ,\n", + " 836861.80803198, 848862.4778583 ,\n", + " 860861.89719402, 872862.84895905,\n", + " 884862.52520112, 896861.84719109,\n", + " 908861.8945184 , 920862.37268268,\n", + " 932862.58191684, 944862.38597276,\n", + " 956862.70585726, 968862.75932956,\n", + " 980862.97978011, 992862.99006537,\n", + " 1004862.00768959, 1016862.08692122,\n", + " 1028861.63462963, 1040862.21737941,\n", + " 1052861.91891392, 1064861.98284895,\n", + " 1076862.35437825, 1088862.01009992,\n", + " 1100862.02850585, 1112862.4370279 ,\n", + " 1124863.3456949 , 1136862.34934454,\n", + " 1148862.23038066, 1160861.47692509,\n", + " 1172862.46616204, 1184862.06404513,\n", + " 1196861.91951627, 1208861.89356904,\n", + " 1220862.17889049, 1232861.99106498,\n", + " 1244862.49052547, 1256862.89251711,\n", + " 1268862.41196453, 1280861.96984232,\n", + " 1292861.10334917, 1304861.8676576 ,\n", + " 1316861.85408047, 1328862.71199087,\n", + " 1340862.92749166, 1352862.44262531,\n", + " 1364861.60505252, 1376863.04434379,\n", + " 1388861.42362458, 1400862.3692699 ,\n", + " 1412861.20141946, 1424861.92291089,\n", + " 1436862.85005413, 1448862.46695994,\n", + " 1460862.42366287, 1472861.93234365,\n", + " 1484862.55875226, 1496862.0583845 ,\n", + " 1508862.3186023 , 1520862.95731279,\n", + " 1532862.13580359, 1544862.14789759,\n", + " 1556862.20427556, 1568862.0074687 ,\n", + " 1580861.9026419 , 1592861.99921494,\n", + " 1604861.10001189, 1616862.31297015,\n", + " 1628862.98422931, 1640862.32262325,\n", + " 1652862.62179676, 1664862.12766606,\n", + " 1676862.23304256, 1688862.2324209 ,\n", + " 1700861.42018878, 1712862.49792768,\n", + " 1724861.99388639, 1736861.79393994,\n", + " 1748861.68713378, 1760862.01617442,\n", + " 1772861.8994825 , 1784862.35010491,\n", + " 1796861.98991304, 1808861.01601485,\n", + " 1820862.85914197, 1832862.09010331,\n", + " 1844861.90765863, 1856861.83581031,\n", + " 1868862.30366401, 1880861.87554469,\n", + " 1892861.61954572, 1904861.96465242,\n", + " 1916862.20298818, 1928862.26487282,\n", + " 1940862.25984512, 1952861.70845873,\n", + " 1964862.6760201 , 1976862.40781729,\n", + " 1988862.0601863 , 2000862.06152662,\n", + " 2012861.61160637, 2024861.54817743,\n", + " 2036862.29978874, 2048862.33737603,\n", + " 2060862.31546611, 2072862.34356724,\n", + " 2084862.02940992, 2096862.21104696,\n", + " 2108862.08564468, 2120862.80904264,\n", + " 2132861.29995525, 2144863.04431031,\n", + " 2156861.7680832 , 2168862.22975281,\n", + " 2180862.0745934 , 2192862.45785697,\n", + " 2204862.98450722, 2216862.11947367,\n", + " 2228862.25144406, 2240861.84524301,\n", + " 2252861.64424617, 2264862.07524215,\n", + " 2276862.64609012, 2288862.83419518,\n", + " 2300861.95483109, 2312863.00214068,\n", + " 2324862.2811275 , 2336862.69096942,\n", + " 2348862.5961938 , 2360862.83510549,\n", + " 2372862.49844879, 2384862.20620674,\n", + " 2396862.09153175, 2408862.0470545 ,\n", + " 2420862.20439962, 2432861.21701588,\n", + " 2444862.20681598, 2456862.29183621,\n", + " 2468862.30979652, 2480862.37103315,\n", + " 2492861.55935617, 2504862.36887632,\n", + " 2516862.32624744, 2528862.6837446 ,\n", + " 2540862.62276294, 2552862.56717894,\n", + " 2564862.52648303, 2576862.09514914,\n", + " 2588861.69682198, 2600862.48360977,\n", + " 2612862.07561471, 2624862.03895504,\n", + " 2636862.06879401, 2648862.48574049,\n", + " 2660862.15334881, 2672862.22245282,\n", + " 2684862.70004968, 2696862.03251993],\n", + " mask=False,\n", + " fill_value=1e+20),\n", + " 'dimensions': ('y',),\n", + " 'units': 'm',\n", + " 'long_name': 'y coordinate of projection',\n", + " 'standard_name': 'projection_y_coordinate'}" + ] + }, + "execution_count": 8, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "nessy_1.y" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "{'data': masked_array(\n", + " data=[[19.706436, 19.728317, 19.750084, ..., 16.264694, 16.22998 ,\n", + " 16.19516 ],\n", + " [19.805984, 19.827904, 19.849716, ..., 16.358276, 16.323502,\n", + " 16.288643],\n", + " [19.905594, 19.927544, 19.949394, ..., 16.45192 , 16.417084,\n", + " 16.382141],\n", + " ...,\n", + " [59.66961 , 59.70968 , 59.74953 , ..., 53.457195, 53.39534 ,\n", + " 53.33333 ],\n", + " [59.76223 , 59.802353, 59.842262, ..., 53.541912, 53.47999 ,\n", + " 53.417908],\n", + " [59.854744, 59.89492 , 59.934883, ..., 53.62653 , 53.56453 ,\n", + " 53.502373]],\n", + " mask=False,\n", + " fill_value=1e+20,\n", + " dtype=float32),\n", + " 'dimensions': ('y', 'x'),\n", + " 'units': 'degrees_north',\n", + " 'axis': 'Y',\n", + " 'long_name': 'latitude coordinate',\n", + " 'standard_name': 'latitude'}" + ] + }, + "execution_count": 9, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "nessy_1.lat" + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "{'data': masked_array(\n", + " data=[[-22.32898 , -22.223236, -22.117432, ..., 28.619202, 28.716614,\n", + " 28.813965],\n", + " [-22.352325, -22.24646 , -22.140533, ..., 28.655334, 28.752869,\n", + " 28.850311],\n", + " [-22.375702, -22.269714, -22.163696, ..., 28.69159 , 28.789185,\n", + " 28.886719],\n", + " ...,\n", + " [-39.438995, -39.25531 , -39.07132 , ..., 53.106964, 53.249176,\n", + " 53.391052],\n", + " [-39.518707, -39.334717, -39.15039 , ..., 53.210876, 53.35321 ,\n", + " 53.49518 ],\n", + " [-39.598724, -39.41443 , -39.229828, ..., 53.315125, 53.45755 ,\n", + " 53.59964 ]],\n", + " mask=False,\n", + " fill_value=1e+20,\n", + " dtype=float32),\n", + " 'dimensions': ('y', 'x'),\n", + " 'units': 'degrees_east',\n", + " 'axis': 'X',\n", + " 'long_name': 'longitude coordinate',\n", + " 'standard_name': 'longitude'}" + ] + }, + "execution_count": 10, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "nessy_1.lon" + ] + }, + { + "cell_type": "code", + "execution_count": 11, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Rank 000: Loading pm10 var (1/1)\n", + "Rank 000: Loaded pm10 var ((48, 1, 398, 478))\n" + ] + } + ], + "source": [ + "nessy_1.load()" + ] + }, + { + "cell_type": "code", + "execution_count": 12, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "{'pm10': {'data': masked_array(\n", + " data=[[[[2.05903081e-08, 2.10736815e-08, 2.16505036e-08, ...,\n", + " 1.57139212e-07, 1.56582516e-07, 1.58654302e-07],\n", + " [2.02237249e-08, 2.07961541e-08, 2.16525038e-08, ...,\n", + " 1.56947792e-07, 1.52752250e-07, 1.51975840e-07],\n", + " [1.92542160e-08, 1.95532017e-08, 2.09430890e-08, ...,\n", + " 1.56698391e-07, 1.52042290e-07, 1.49590434e-07],\n", + " ...,\n", + " [2.00155412e-08, 1.88844460e-08, 1.72373600e-08, ...,\n", + " 1.03697766e-10, 1.24570437e-10, 1.35568029e-10],\n", + " [1.88825418e-08, 1.78339921e-08, 1.65571699e-08, ...,\n", + " 1.29691299e-10, 1.19366197e-10, 1.26047242e-10],\n", + " [1.75334254e-08, 1.67024794e-08, 1.57620299e-08, ...,\n", + " 5.90659299e-10, 5.99817251e-10, 6.93886892e-10]]],\n", + " \n", + " \n", + " [[[2.04419166e-08, 2.10894218e-08, 2.14073363e-08, ...,\n", + " 1.50338764e-07, 1.46800986e-07, 1.45907649e-07],\n", + " [1.97089882e-08, 2.07061799e-08, 2.14063096e-08, ...,\n", + " 1.50352193e-07, 1.44729924e-07, 1.41249188e-07],\n", + " [1.88334628e-08, 1.97772980e-08, 2.10062652e-08, ...,\n", + " 1.50320858e-07, 1.45472683e-07, 1.40802484e-07],\n", + " ...,\n", + " [1.58354645e-08, 1.31688500e-08, 1.04182032e-08, ...,\n", + " 1.36057263e-10, 1.61256425e-10, 1.82640861e-10],\n", + " [1.58553863e-08, 1.35575196e-08, 1.12653220e-08, ...,\n", + " 4.73602046e-10, 5.22056454e-10, 5.99001682e-10],\n", + " [1.51028274e-08, 1.29572175e-08, 1.06422196e-08, ...,\n", + " 1.20180965e-09, 1.22420163e-09, 1.27862843e-09]]],\n", + " \n", + " \n", + " [[[2.06775415e-08, 2.09295870e-08, 2.10403801e-08, ...,\n", + " 1.43437418e-07, 1.36887849e-07, 1.33009308e-07],\n", + " [2.03318944e-08, 2.06964064e-08, 2.09895372e-08, ...,\n", + " 1.43851324e-07, 1.36785971e-07, 1.30620521e-07],\n", + " [1.96500309e-08, 1.97185361e-08, 2.00775236e-08, ...,\n", + " 1.43990789e-07, 1.38915652e-07, 1.32079862e-07],\n", + " ...,\n", + " [1.15522543e-08, 1.03884448e-08, 8.92967922e-09, ...,\n", + " 2.96768943e-10, 5.31864996e-10, 6.76325274e-10],\n", + " [1.30444580e-08, 1.24477344e-08, 1.19089290e-08, ...,\n", + " 9.38010669e-10, 1.02875852e-09, 1.09171505e-09],\n", + " [1.33038087e-08, 1.28954767e-08, 1.27622268e-08, ...,\n", + " 1.10067289e-09, 1.11675491e-09, 1.12590814e-09]]],\n", + " \n", + " \n", + " ...,\n", + " \n", + " \n", + " [[[1.99427657e-08, 2.07774260e-08, 2.12375095e-08, ...,\n", + " 1.42070576e-07, 1.23106801e-07, 1.05545318e-07],\n", + " [1.94999394e-08, 2.03327897e-08, 2.09769428e-08, ...,\n", + " 1.40088332e-07, 1.22823366e-07, 1.06322936e-07],\n", + " [1.92740401e-08, 2.01404546e-08, 2.12538360e-08, ...,\n", + " 1.37738098e-07, 1.25881471e-07, 1.11278482e-07],\n", + " ...,\n", + " [1.62301383e-09, 3.29047856e-09, 4.25983115e-09, ...,\n", + " 5.10578968e-10, 7.78555886e-10, 7.58658358e-10],\n", + " [1.61382108e-09, 3.05706660e-09, 3.85214838e-09, ...,\n", + " 1.44986870e-10, 4.45782633e-10, 6.53098131e-10],\n", + " [1.51593449e-09, 2.81125856e-09, 3.49995122e-09, ...,\n", + " 3.83349671e-11, 5.17163673e-11, 1.41100784e-10]]],\n", + " \n", + " \n", + " [[[2.12318145e-08, 2.15663487e-08, 2.17239737e-08, ...,\n", + " 1.33982709e-07, 1.17447051e-07, 1.01946490e-07],\n", + " [2.09607443e-08, 2.13947366e-08, 2.17022080e-08, ...,\n", + " 1.30945295e-07, 1.15195341e-07, 1.00572883e-07],\n", + " [2.06122941e-08, 2.12153246e-08, 2.20146017e-08, ...,\n", + " 1.27737934e-07, 1.15350041e-07, 1.01470562e-07],\n", + " ...,\n", + " [1.74116932e-09, 3.57977159e-09, 4.66885952e-09, ...,\n", + " 1.35524800e-10, 3.73824971e-10, 5.27946020e-10],\n", + " [1.69331171e-09, 3.35175421e-09, 4.35682335e-09, ...,\n", + " 6.59049343e-11, 8.77121500e-11, 1.72610246e-10],\n", + " [1.66064651e-09, 3.09451931e-09, 3.84808585e-09, ...,\n", + " 3.81935802e-11, 3.20906392e-11, 2.95690208e-11]]],\n", + " \n", + " \n", + " [[[2.20933263e-08, 2.23298162e-08, 2.22625207e-08, ...,\n", + " 1.25896420e-07, 1.11788722e-07, 9.83487993e-08],\n", + " [2.17691785e-08, 2.21585328e-08, 2.22608545e-08, ...,\n", + " 1.21806693e-07, 1.07571751e-07, 9.48248058e-08],\n", + " [2.10832365e-08, 2.17355911e-08, 2.23796377e-08, ...,\n", + " 1.17739212e-07, 1.04824068e-07, 9.16652283e-08],\n", + " ...,\n", + " [1.82784676e-09, 3.94770527e-09, 5.16965803e-09, ...,\n", + " 7.80837409e-11, 9.47864148e-11, 1.31354164e-10],\n", + " [1.82815707e-09, 3.68124264e-09, 4.70819206e-09, ...,\n", + " 5.68534525e-11, 4.92194792e-11, 5.04330119e-11],\n", + " [1.79193316e-09, 3.41961126e-09, 4.36335901e-09, ...,\n", + " 4.09052167e-11, 3.92018085e-11, 3.67623848e-11]]]],\n", + " mask=False,\n", + " fill_value=1e+20,\n", + " dtype=float32),\n", + " 'dimensions': ('time', 'lev', 'y', 'x'),\n", + " 'units': 'kgm-3',\n", + " 'coordinates': 'lat lon',\n", + " 'grid_mapping': 'Lambert_conformal'}}" + ] + }, + "execution_count": 12, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "nessy_1.variables" + ] + }, + { + "cell_type": "code", + "execution_count": 13, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Rank 000: Creating lcc_file_1.nc\n", + "Rank 000: NetCDF ready to write\n", + "Rank 000: Dimensions done\n", + "Rank 000: Writing pm10 var (1/1)\n", + "Rank 000: Var pm10 created (1/1)\n", + "Rank 000: Filling pm10)\n", + "Rank 000: Var pm10 data (1/1)\n", + "Rank 000: Var pm10 completed (1/1)\n" + ] + } + ], + "source": [ + "nessy_1.to_netcdf('lcc_file_1.nc', info=True)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Reopen with NES" + ] + }, + { + "cell_type": "code", + "execution_count": 14, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "" + ] + }, + "execution_count": 14, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "nessy_2 = open_netcdf('lcc_file_1.nc', info=True)\n", + "nessy_2" + ] + }, + { + "cell_type": "code", + "execution_count": 15, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
    \n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "
    <xarray.Dataset>\n",
    +       "Dimensions:            (time: 48, lev: 1, y: 398, x: 478)\n",
    +       "Coordinates:\n",
    +       "  * time               (time) datetime64[ns] 2022-06-26 ... 2022-06-27T23:00:00\n",
    +       "  * lev                (lev) float64 0.0\n",
    +       "    lat                (y, x) float64 ...\n",
    +       "    lon                (y, x) float64 ...\n",
    +       "  * y                  (y) float64 -2.067e+06 -2.055e+06 ... 2.685e+06 2.697e+06\n",
    +       "  * x                  (x) float64 -2.126e+06 -2.114e+06 ... 3.586e+06 3.598e+06\n",
    +       "Data variables:\n",
    +       "    pm10               (time, lev, y, x) float32 ...\n",
    +       "    Lambert_conformal  |S1 b''\n",
    +       "Attributes:\n",
    +       "    Conventions:  CF-1.7
    " + ], + "text/plain": [ + "\n", + "Dimensions: (time: 48, lev: 1, y: 398, x: 478)\n", + "Coordinates:\n", + " * time (time) datetime64[ns] 2022-06-26 ... 2022-06-27T23:00:00\n", + " * lev (lev) float64 0.0\n", + " lat (y, x) float64 ...\n", + " lon (y, x) float64 ...\n", + " * y (y) float64 -2.067e+06 -2.055e+06 ... 2.685e+06 2.697e+06\n", + " * x (x) float64 -2.126e+06 -2.114e+06 ... 3.586e+06 3.598e+06\n", + "Data variables:\n", + " pm10 (time, lev, y, x) float32 ...\n", + " Lambert_conformal |S1 ...\n", + "Attributes:\n", + " Conventions: CF-1.7" + ] + }, + "execution_count": 15, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "xr.open_dataset('lcc_file_1.nc')" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.7.4" + } + }, + "nbformat": 4, + "nbformat_minor": 4 +} diff --git a/Jupyter_notebooks/2-create_nes.ipynb b/Jupyter_notebooks/2-create_nes.ipynb index 01ccb10ed32fb8e58455a4a798b134508a714b67..99a24420807dd4586cffc527764904d3d65c5e02 100644 --- a/Jupyter_notebooks/2-create_nes.ipynb +++ b/Jupyter_notebooks/2-create_nes.ipynb @@ -4,7 +4,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "# How to create regular, rotated and points grids" + "# How to create regular, rotated, points and LCC grids" ] }, { @@ -38,7 +38,7 @@ "inc_lon = 0.1\n", "n_lat = 10\n", "n_lon = 10\n", - "regular_grid = create_nes(comm=None, info=False, projection='regular', create_nes=True,\n", + "regular_grid = create_nes(comm=None, info=False, projection='regular',\n", " lat_orig=lat_orig, lon_orig=lon_orig, inc_lat=inc_lat, inc_lon=inc_lon, \n", " n_lat=n_lat, n_lon=n_lon)" ] @@ -431,7 +431,7 @@ "Data variables:\n", " crs |S1 b''\n", "Attributes:\n", - " Conventions: CF-1.7" + " Conventions: CF-1.7" ], "text/plain": [ "\n", @@ -475,7 +475,7 @@ "south_boundary = -27\n", "inc_rlat = 0.2\n", "inc_rlon = 0.2\n", - "rotated_grid = create_nes(comm=None, info=False, projection='rotated', create_nes=True,\n", + "rotated_grid = create_nes(comm=None, info=False, projection='rotated',\n", " centre_lat=centre_lat, centre_lon=centre_lon,\n", " west_boundary=west_boundary, south_boundary=south_boundary,\n", " inc_rlat=inc_rlat, inc_rlon=inc_rlon)" @@ -860,23 +860,24 @@ " fill: currentColor;\n", "}\n", "
    <xarray.Dataset>\n",
    -       "Dimensions:  (time: 1, lev: 1, rlat: 271, rlon: 351)\n",
    +       "Dimensions:       (time: 1, lev: 1, rlat: 271, rlon: 351)\n",
            "Coordinates:\n",
    -       "  * time     (time) datetime64[ns] 1996-12-31\n",
    -       "  * lev      (lev) float64 0.0\n",
    -       "  * rlat     (rlat) float64 -27.0 -26.8 -26.6 -26.4 ... 26.4 26.6 26.8 27.0\n",
    -       "  * rlon     (rlon) float64 -35.0 -34.8 -34.6 -34.4 ... 34.4 34.6 34.8 35.0\n",
    +       "  * time          (time) datetime64[ns] 1996-12-31\n",
    +       "  * lev           (lev) float64 0.0\n",
    +       "  * rlat          (rlat) float64 -27.0 -26.8 -26.6 -26.4 ... 26.4 26.6 26.8 27.0\n",
    +       "  * rlon          (rlon) float64 -35.0 -34.8 -34.6 -34.4 ... 34.4 34.6 34.8 35.0\n",
            "Data variables:\n",
    -       "    lat      (rlat, rlon) float64 16.35 16.43 16.52 16.6 ... 58.83 58.68 58.53\n",
    -       "    lon      (rlat, rlon) float64 -22.18 -22.02 -21.85 ... 87.87 88.05 88.23\n",
    +       "    lat           (rlat, rlon) float64 16.35 16.43 16.52 ... 58.83 58.68 58.53\n",
    +       "    lon           (rlat, rlon) float64 -22.18 -22.02 -21.85 ... 88.05 88.23\n",
    +       "    rotated_pole  |S1 b''\n",
            "Attributes:\n",
    -       "    Conventions:  CF-1.7
  • Conventions :
    CF-1.7
  • " ], "text/plain": [ "\n", - "Dimensions: (time: 1, lev: 1, rlat: 271, rlon: 351)\n", + "Dimensions: (time: 1, lev: 1, rlat: 271, rlon: 351)\n", "Coordinates:\n", - " * time (time) datetime64[ns] 1996-12-31\n", - " * lev (lev) float64 0.0\n", - " * rlat (rlat) float64 -27.0 -26.8 -26.6 -26.4 ... 26.4 26.6 26.8 27.0\n", - " * rlon (rlon) float64 -35.0 -34.8 -34.6 -34.4 ... 34.4 34.6 34.8 35.0\n", + " * time (time) datetime64[ns] 1996-12-31\n", + " * lev (lev) float64 0.0\n", + " * rlat (rlat) float64 -27.0 -26.8 -26.6 -26.4 ... 26.4 26.6 26.8 27.0\n", + " * rlon (rlon) float64 -35.0 -34.8 -34.6 -34.4 ... 34.4 34.6 34.8 35.0\n", "Data variables:\n", - " lat (rlat, rlon) float64 ...\n", - " lon (rlat, rlon) float64 ...\n", + " lat (rlat, rlon) float64 ...\n", + " lon (rlat, rlon) float64 ...\n", + " rotated_pole |S1 ...\n", "Attributes:\n", " Conventions: CF-1.7" ] @@ -1106,7 +1108,7 @@ "metadata": {}, "outputs": [], "source": [ - "points_grid = create_nes(comm=None, info=False, projection=None, create_nes=True, parallel_method='X',\n", + "points_grid = create_nes(comm=None, info=False, projection=None, parallel_method='X',\n", " lat=lat, lon=lon)" ] }, @@ -1145,9 +1147,9 @@ "name": "stderr", "output_type": "stream", "text": [ - "/esarchive/scratch/avilanova/software/NES/nes/nc_projections/points_nes.py:362: UserWarning: WARNING!!! Different data types for variable station_codeInput dtype=, data dtype=object\n", + "/esarchive/scratch/avilanova/software/NES/nes/nc_projections/points_nes.py:396: UserWarning: WARNING!!! Different data types for variable station_codeInput dtype=, data dtype=object\n", " warnings.warn(msg)\n", - "/esarchive/scratch/avilanova/software/NES/nes/nc_projections/points_nes.py:362: UserWarning: WARNING!!! Different data types for variable area_classificationInput dtype=, data dtype=object\n", + "/esarchive/scratch/avilanova/software/NES/nes/nc_projections/points_nes.py:396: UserWarning: WARNING!!! Different data types for variable area_classificationInput dtype=, data dtype=object\n", " warnings.warn(msg)\n" ] } @@ -1526,7 +1528,7 @@ " lat (station) float64 41.38 41.73 41.57 ... 41.24 42.36\n", " lon (station) float64 2.086 1.839 2.015 ... 1.857 1.459\n", "Attributes:\n", - " Conventions: CF-1.7
  • Conventions :
    CF-1.7
  • " ], "text/plain": [ "\n", @@ -2168,7 +2170,7 @@ "metadata": {}, "outputs": [], "source": [ - "points_grid = create_nes(comm=None, info=False, projection=None, create_nes=True, parallel_method='X',\n", + "points_grid = create_nes(comm=None, info=False, projection=None, parallel_method='X',\n", " lat=lat, lon=lon, time=time)" ] }, @@ -2211,11 +2213,11 @@ "name": "stderr", "output_type": "stream", "text": [ - "/esarchive/scratch/avilanova/software/NES/nes/nc_projections/points_nes.py:362: UserWarning: WARNING!!! Different data types for variable station_nameInput dtype=, data dtype=object\n", + "/esarchive/scratch/avilanova/software/NES/nes/nc_projections/points_nes.py:396: UserWarning: WARNING!!! Different data types for variable station_nameInput dtype=, data dtype=object\n", " warnings.warn(msg)\n", - "/esarchive/scratch/avilanova/software/NES/nes/nc_projections/points_nes.py:362: UserWarning: WARNING!!! Different data types for variable station_codeInput dtype=, data dtype=object\n", + "/esarchive/scratch/avilanova/software/NES/nes/nc_projections/points_nes.py:396: UserWarning: WARNING!!! Different data types for variable station_codeInput dtype=, data dtype=object\n", " warnings.warn(msg)\n", - "/esarchive/scratch/avilanova/software/NES/nes/nc_projections/points_nes.py:362: UserWarning: WARNING!!! Different data types for variable pm10Input dtype=, data dtype=object\n", + "/esarchive/scratch/avilanova/software/NES/nes/nc_projections/points_nes.py:396: UserWarning: WARNING!!! Different data types for variable pm10Input dtype=, data dtype=object\n", " warnings.warn(msg)\n" ] } @@ -2595,15 +2597,15 @@ " lat (station) float64 nan nan nan nan nan ... nan nan nan nan nan\n", " lon (station) float64 nan nan nan nan nan ... nan nan nan nan nan\n", "Attributes:\n", - " Conventions: CF-1.7
  • Conventions :
    CF-1.7
  • " ], "text/plain": [ "\n", @@ -2706,6 +2708,453 @@ "xr.open_dataset('points_grid_2.nc')" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## 4. Create LCC grid" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": {}, + "outputs": [], + "source": [ + "lat_1 = 37\n", + "lat_2 = 43\n", + "lon_0 = -3\n", + "lat_0 = 40\n", + "nx = 397\n", + "ny = 397\n", + "inc_x = 4000\n", + "inc_y = 4000\n", + "x_0 = -807847.688\n", + "y_0 = -797137.125\n", + "lcc_grid = create_nes(comm=None, info=False, projection='lcc',\n", + " lat_1=lat_1, lat_2=lat_2, lon_0=lon_0, lat_0=lat_0, \n", + " nx=nx, ny=ny, inc_x=inc_x, inc_y=inc_y, x_0=x_0, y_0=y_0)" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Rank 000: Creating lcc_grid.nc\n", + "Rank 000: NetCDF ready to write\n", + "Rank 000: Dimensions done\n" + ] + } + ], + "source": [ + "lcc_grid.to_netcdf('lcc_grid.nc', info=True)" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
    \n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "
    <xarray.Dataset>\n",
    +       "Dimensions:            (time: 1, lev: 1, y: 397, x: 397)\n",
    +       "Coordinates:\n",
    +       "  * time               (time) datetime64[ns] 1996-12-31\n",
    +       "  * lev                (lev) float64 0.0\n",
    +       "  * y                  (y) float64 -7.951e+05 -7.911e+05 ... 7.849e+05 7.889e+05\n",
    +       "  * x                  (x) float64 -8.058e+05 -8.018e+05 ... 7.742e+05 7.782e+05\n",
    +       "Data variables:\n",
    +       "    lat                (y, x) float64 ...\n",
    +       "    lon                (y, x) float64 ...\n",
    +       "    Lambert_conformal  |S1 b''\n",
    +       "Attributes:\n",
    +       "    Conventions:  CF-1.7
    " + ], + "text/plain": [ + "\n", + "Dimensions: (time: 1, lev: 1, y: 397, x: 397)\n", + "Coordinates:\n", + " * time (time) datetime64[ns] 1996-12-31\n", + " * lev (lev) float64 0.0\n", + " * y (y) float64 -7.951e+05 -7.911e+05 ... 7.849e+05 7.889e+05\n", + " * x (x) float64 -8.058e+05 -8.018e+05 ... 7.742e+05 7.782e+05\n", + "Data variables:\n", + " lat (y, x) float64 ...\n", + " lon (y, x) float64 ...\n", + " Lambert_conformal |S1 ...\n", + "Attributes:\n", + " Conventions: CF-1.7" + ] + }, + "execution_count": 4, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "xr.open_dataset('lcc_grid.nc')" + ] + }, { "cell_type": "code", "execution_count": null, diff --git a/Jupyter_notebooks/2.1-create_nes_port.ipynb b/Jupyter_notebooks/2.1-create_nes_port.ipynb new file mode 100644 index 0000000000000000000000000000000000000000..081015ab4ab93101c2156f07cc88d844a5ee5149 --- /dev/null +++ b/Jupyter_notebooks/2.1-create_nes_port.ipynb @@ -0,0 +1,1951 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# How to create monthly observations datasets (Port Barcelona)" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": {}, + "outputs": [], + "source": [ + "import xarray as xr\n", + "import pandas as pd\n", + "import numpy as np\n", + "from datetime import datetime, timedelta\n", + "from nes import *" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
    \n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
    SO2-DarsenaSO2-UMNO2-UMNO2-ZAL Prat
    Horario: UTC
    2017-01-01 00:00:00.0000000.18NaN63.3846.01
    2017-01-01 01:00:00.0000030.20NaN64.6449.08
    2017-01-01 01:59:59.9999970.18NaN68.1653.00
    2017-01-01 03:00:00.0000000.04NaN68.2946.75
    2017-01-01 04:00:00.0000030.00NaN62.9139.65
    ...............
    2021-12-31 13:59:59.9999970.77NaN35.3824.96
    2021-12-31 15:00:00.0000000.37NaN35.8024.16
    2021-12-31 16:00:00.0000030.23NaN29.1025.79
    2021-12-31 16:59:59.9999970.14NaN9.2429.82
    2021-12-31 18:00:00.0000000.20NaN12.7628.66
    \n", + "

    43819 rows × 4 columns

    \n", + "
    " + ], + "text/plain": [ + " SO2-Darsena SO2-UM NO2-UM NO2-ZAL Prat\n", + "Horario: UTC \n", + "2017-01-01 00:00:00.000000 0.18 NaN 63.38 46.01\n", + "2017-01-01 01:00:00.000003 0.20 NaN 64.64 49.08\n", + "2017-01-01 01:59:59.999997 0.18 NaN 68.16 53.00\n", + "2017-01-01 03:00:00.000000 0.04 NaN 68.29 46.75\n", + "2017-01-01 04:00:00.000003 0.00 NaN 62.91 39.65\n", + "... ... ... ... ...\n", + "2021-12-31 13:59:59.999997 0.77 NaN 35.38 24.96\n", + "2021-12-31 15:00:00.000000 0.37 NaN 35.80 24.16\n", + "2021-12-31 16:00:00.000003 0.23 NaN 29.10 25.79\n", + "2021-12-31 16:59:59.999997 0.14 NaN 9.24 29.82\n", + "2021-12-31 18:00:00.000000 0.20 NaN 12.76 28.66\n", + "\n", + "[43819 rows x 4 columns]" + ] + }, + "execution_count": 2, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "file_path = '/esarchive/scratch/avilanova/software/NES/Jupyter_notebooks/input/Dades_Port_Barcelona_2017-2021_corr.xlsx'\n", + "df_data = pd.read_excel(file_path, header=3, index_col='Horario: UTC')\n", + "df_data" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "DatetimeIndex(['2017-01-01 00:00:00', '2017-01-01 01:00:00',\n", + " '2017-01-01 02:00:00', '2017-01-01 03:00:00',\n", + " '2017-01-01 04:00:00', '2017-01-01 05:00:00',\n", + " '2017-01-01 06:00:00', '2017-01-01 07:00:00',\n", + " '2017-01-01 08:00:00', '2017-01-01 09:00:00',\n", + " ...\n", + " '2021-12-31 09:00:00', '2021-12-31 10:00:00',\n", + " '2021-12-31 11:00:00', '2021-12-31 12:00:00',\n", + " '2021-12-31 13:00:00', '2021-12-31 14:00:00',\n", + " '2021-12-31 15:00:00', '2021-12-31 16:00:00',\n", + " '2021-12-31 17:00:00', '2021-12-31 18:00:00'],\n", + " dtype='datetime64[ns]', length=43819, freq=None)" + ] + }, + "execution_count": 3, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "df_data.index = pd.Index([datetime(year=2017, month=1, day=1, minute=0, second=0, microsecond=0) + timedelta(hours=i) for i in range(len(df_data))])\n", + "df_data.index " + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
    \n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
    station.codelatlonstandardised_network_provided_area_classification
    0Dàrsena sud41.3328892.140807NaN
    1Unitat Mobil41.3737772.184514NaN
    2ZAL Prat41.3172772.134501NaN
    \n", + "
    " + ], + "text/plain": [ + " station.code lat lon \\\n", + "0 Dàrsena sud 41.332889 2.140807 \n", + "1 Unitat Mobil 41.373777 2.184514 \n", + "2 ZAL Prat 41.317277 2.134501 \n", + "\n", + " standardised_network_provided_area_classification \n", + "0 NaN \n", + "1 NaN \n", + "2 NaN " + ] + }, + "execution_count": 4, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "file_path = '/esarchive/scratch/avilanova/software/NES/Jupyter_notebooks/input/estaciones.csv'\n", + "df_stations = pd.read_csv(file_path)\n", + "df_stations" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Create dataset with all timesteps" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "array([datetime.datetime(2017, 1, 1, 0, 0),\n", + " datetime.datetime(2017, 1, 1, 1, 0),\n", + " datetime.datetime(2017, 1, 1, 2, 0), ...,\n", + " datetime.datetime(2021, 12, 31, 16, 0),\n", + " datetime.datetime(2021, 12, 31, 17, 0),\n", + " datetime.datetime(2021, 12, 31, 18, 0)], dtype=object)" + ] + }, + "execution_count": 5, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "time = df_data.index.to_pydatetime()\n", + "time" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "array([41.3737771 , 41.31727665])" + ] + }, + "execution_count": 6, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "lat = df_stations['lat'][1:3].to_numpy()\n", + "lat" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "array([2.1845141 , 2.13450079])" + ] + }, + "execution_count": 7, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "lon = df_stations['lon'][1:3].to_numpy()\n", + "lon" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": {}, + "outputs": [], + "source": [ + "metadata = {'station_name': {'data': df_data.columns[2:4].to_numpy(),\n", + " 'dimensions': ('station',),\n", + " 'dtype': str},\n", + " 'NO2': {'data': df_data.iloc[:, 2:4].to_numpy().T,\n", + " 'dimensions': ('station', 'time',),\n", + " 'dtype': float}}" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "metadata": {}, + "outputs": [], + "source": [ + "points_grid = create_nes(comm=None, info=False, projection=None, parallel_method='X',\n", + " lat=lat, lon=lon, time=time)" + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "metadata": {}, + "outputs": [], + "source": [ + "points_grid.variables = metadata" + ] + }, + { + "cell_type": "code", + "execution_count": 11, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Rank 000: Creating points_grid_no2.nc\n", + "Rank 000: NetCDF ready to write\n", + "Rank 000: Dimensions done\n", + "Rank 000: Writing station_name var (1/2)\n", + "Rank 000: Var station_name created (1/2)\n", + "Rank 000: Var station_name data (1/2)\n", + "Rank 000: Var station_name completed (1/2)\n", + "Rank 000: Writing NO2 var (2/2)\n", + "Rank 000: Var NO2 created (2/2)\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "/esarchive/scratch/avilanova/software/NES/nes/nc_projections/points_nes.py:400: UserWarning: WARNING!!! Different data types for variable station_nameInput dtype=, data dtype=object\n", + " warnings.warn(msg)\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Rank 000: Var NO2 data (2/2)\n", + "Rank 000: Var NO2 completed (2/2)\n" + ] + } + ], + "source": [ + "points_grid.to_netcdf('points_grid_no2.nc', info=True)\n", + "del points_grid" + ] + }, + { + "cell_type": "code", + "execution_count": 12, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
    \n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "
    <xarray.Dataset>\n",
    +       "Dimensions:       (time: 43819, station: 2)\n",
    +       "Coordinates:\n",
    +       "  * time          (time) datetime64[ns] 2017-01-01 ... 2021-12-31T18:00:00\n",
    +       "  * station       (station) float64 0.0 1.0\n",
    +       "Data variables:\n",
    +       "    station_name  (station) object 'NO2-UM' 'NO2-ZAL Prat'\n",
    +       "    NO2           (station, time) float64 63.38 64.64 68.16 ... 29.82 28.66\n",
    +       "    lat           (station) float64 41.37 41.32\n",
    +       "    lon           (station) float64 2.185 2.135\n",
    +       "Attributes:\n",
    +       "    Conventions:  CF-1.7
    " + ], + "text/plain": [ + "\n", + "Dimensions: (time: 43819, station: 2)\n", + "Coordinates:\n", + " * time (time) datetime64[ns] 2017-01-01 ... 2021-12-31T18:00:00\n", + " * station (station) float64 0.0 1.0\n", + "Data variables:\n", + " station_name (station) object ...\n", + " NO2 (station, time) float64 ...\n", + " lat (station) float64 ...\n", + " lon (station) float64 ...\n", + "Attributes:\n", + " Conventions: CF-1.7" + ] + }, + "execution_count": 12, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "xr.open_dataset('points_grid_no2.nc')" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Create one dataset per month (Ready for Providentia)" + ] + }, + { + "cell_type": "code", + "execution_count": 13, + "metadata": {}, + "outputs": [], + "source": [ + "df_data['month'] = df_data.index.month\n", + "df_data['year'] = df_data.index.year" + ] + }, + { + "cell_type": "code", + "execution_count": 14, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
    \n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
    SO2-DarsenaSO2-UMNO2-UMNO2-ZAL Pratmonthyear
    2017-01-01 00:00:000.18NaN63.3846.0112017
    2017-01-01 01:00:000.20NaN64.6449.0812017
    2017-01-01 02:00:000.18NaN68.1653.0012017
    2017-01-01 03:00:000.04NaN68.2946.7512017
    2017-01-01 04:00:000.00NaN62.9139.6512017
    .....................
    2021-12-31 14:00:000.77NaN35.3824.96122021
    2021-12-31 15:00:000.37NaN35.8024.16122021
    2021-12-31 16:00:000.23NaN29.1025.79122021
    2021-12-31 17:00:000.14NaN9.2429.82122021
    2021-12-31 18:00:000.20NaN12.7628.66122021
    \n", + "

    43819 rows × 6 columns

    \n", + "
    " + ], + "text/plain": [ + " SO2-Darsena SO2-UM NO2-UM NO2-ZAL Prat month year\n", + "2017-01-01 00:00:00 0.18 NaN 63.38 46.01 1 2017\n", + "2017-01-01 01:00:00 0.20 NaN 64.64 49.08 1 2017\n", + "2017-01-01 02:00:00 0.18 NaN 68.16 53.00 1 2017\n", + "2017-01-01 03:00:00 0.04 NaN 68.29 46.75 1 2017\n", + "2017-01-01 04:00:00 0.00 NaN 62.91 39.65 1 2017\n", + "... ... ... ... ... ... ...\n", + "2021-12-31 14:00:00 0.77 NaN 35.38 24.96 12 2021\n", + "2021-12-31 15:00:00 0.37 NaN 35.80 24.16 12 2021\n", + "2021-12-31 16:00:00 0.23 NaN 29.10 25.79 12 2021\n", + "2021-12-31 17:00:00 0.14 NaN 9.24 29.82 12 2021\n", + "2021-12-31 18:00:00 0.20 NaN 12.76 28.66 12 2021\n", + "\n", + "[43819 rows x 6 columns]" + ] + }, + "execution_count": 14, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "df_data" + ] + }, + { + "cell_type": "code", + "execution_count": 15, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Done sconcno2_201701.nc\n", + "Done sconcno2_201702.nc\n", + "Done sconcno2_201703.nc\n", + "Done sconcno2_201704.nc\n", + "Done sconcno2_201705.nc\n", + "Done sconcno2_201706.nc\n", + "Done sconcno2_201707.nc\n", + "Done sconcno2_201708.nc\n", + "Done sconcno2_201709.nc\n", + "Done sconcno2_201710.nc\n", + "Done sconcno2_201711.nc\n", + "Done sconcno2_201712.nc\n", + "Done sconcno2_201801.nc\n", + "Done sconcno2_201802.nc\n", + "Done sconcno2_201803.nc\n", + "Done sconcno2_201804.nc\n", + "Done sconcno2_201805.nc\n", + "Done sconcno2_201806.nc\n", + "Done sconcno2_201807.nc\n", + "Done sconcno2_201808.nc\n", + "Done sconcno2_201809.nc\n", + "Done sconcno2_201810.nc\n", + "Done sconcno2_201811.nc\n", + "Done sconcno2_201812.nc\n", + "Done sconcno2_201901.nc\n", + "Done sconcno2_201902.nc\n", + "Done sconcno2_201903.nc\n", + "Done sconcno2_201904.nc\n", + "Done sconcno2_201905.nc\n", + "Done sconcno2_201906.nc\n", + "Done sconcno2_201907.nc\n", + "Done sconcno2_201908.nc\n", + "Done sconcno2_201909.nc\n", + "Done sconcno2_201910.nc\n", + "Done sconcno2_201911.nc\n", + "Done sconcno2_201912.nc\n", + "Done sconcno2_202001.nc\n", + "Done sconcno2_202002.nc\n", + "Done sconcno2_202003.nc\n", + "Done sconcno2_202004.nc\n", + "Done sconcno2_202005.nc\n", + "Done sconcno2_202006.nc\n", + "Done sconcno2_202007.nc\n", + "Done sconcno2_202008.nc\n", + "Done sconcno2_202009.nc\n", + "Done sconcno2_202010.nc\n", + "Done sconcno2_202011.nc\n", + "Done sconcno2_202012.nc\n", + "Done sconcno2_202101.nc\n", + "Done sconcno2_202102.nc\n", + "Done sconcno2_202103.nc\n", + "Done sconcno2_202104.nc\n", + "Done sconcno2_202105.nc\n", + "Done sconcno2_202106.nc\n", + "Done sconcno2_202107.nc\n", + "Done sconcno2_202108.nc\n", + "Done sconcno2_202109.nc\n", + "Done sconcno2_202110.nc\n", + "Done sconcno2_202111.nc\n", + "Done sconcno2_202112.nc\n" + ] + } + ], + "source": [ + "for (year, month), current in df_data.groupby(['year', 'month']):\n", + " \n", + " # Transform station names into S75 type\n", + " station_names_S75 = []\n", + " for x in current.columns[2:4].to_numpy():\n", + " station_name_S75 = [x[i:i + 1] for i in range(0, 75, 1)]\n", + " station_names_S75.append(station_name_S75)\n", + " station_name = np.array(station_names_S75).astype('S1')\n", + " \n", + " # Read time\n", + " time = current.index.to_pydatetime()\n", + " \n", + " # Read metadata\n", + " metadata = {'station_name': {'data': station_name,\n", + " 'dimensions': ('station','strlen'),\n", + " 'standard_name': '',\n", + " 'dtype': 'S1'},\n", + " 'sconcno2': {'data': current.iloc[:, 2:4].to_numpy().T,\n", + " 'units': 'µg m-3',\n", + " 'dimensions': ('station', 'time',),\n", + " 'long_name': '',\n", + " 'dtype': float}}\n", + " \n", + " # Create object\n", + " points_grid = create_nes(comm=None, info=False, projection=None, parallel_method='X',\n", + " lat=lat, lon=lon, time=time)\n", + " \n", + " # Assign metadata\n", + " points_grid.variables = metadata\n", + " \n", + " # Save files\n", + " points_grid.to_netcdf('/esarchive/obs/generalitat/port-barcelona/hourly/sconcno2/sconcno2_{0}{1}.nc'.format(year, str(month).zfill(2)))\n", + " \n", + " del points_grid\n", + " print('Done sconcno2_{0}{1}.nc'.format(year, str(month).zfill(2)))" + ] + }, + { + "cell_type": "code", + "execution_count": 16, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
    \n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "
    <xarray.Dataset>\n",
    +       "Dimensions:       (time: 744, station: 2)\n",
    +       "Coordinates:\n",
    +       "  * time          (time) datetime64[ns] 2017-05-01 ... 2017-05-31T23:00:00\n",
    +       "  * station       (station) float64 0.0 1.0\n",
    +       "Data variables:\n",
    +       "    station_name  (station) |S75 b'NO2-UM' b'NO2-ZAL Prat'\n",
    +       "    sconcno2      (station, time) float64 6.88 8.77 1.76 ... 41.2 26.42 27.11\n",
    +       "    lat           (station) float64 41.37 41.32\n",
    +       "    lon           (station) float64 2.185 2.135\n",
    +       "Attributes:\n",
    +       "    Conventions:  CF-1.7
    " + ], + "text/plain": [ + "\n", + "Dimensions: (time: 744, station: 2)\n", + "Coordinates:\n", + " * time (time) datetime64[ns] 2017-05-01 ... 2017-05-31T23:00:00\n", + " * station (station) float64 0.0 1.0\n", + "Data variables:\n", + " station_name (station) |S75 ...\n", + " sconcno2 (station, time) float64 ...\n", + " lat (station) float64 ...\n", + " lon (station) float64 ...\n", + "Attributes:\n", + " Conventions: CF-1.7" + ] + }, + "execution_count": 16, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "xr.open_dataset('/esarchive/obs/generalitat/port-barcelona/hourly/sconcno2/sconcno2_201705.nc')" + ] + }, + { + "cell_type": "code", + "execution_count": 17, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
    \n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "
    <xarray.Dataset>\n",
    +       "Dimensions:       (time: 744, station: 2)\n",
    +       "Coordinates:\n",
    +       "  * time          (time) datetime64[ns] 2019-12-01 ... 2019-12-31T23:00:00\n",
    +       "  * station       (station) float64 0.0 1.0\n",
    +       "Data variables:\n",
    +       "    station_name  (station) |S75 b'NO2-UM' b'NO2-ZAL Prat'\n",
    +       "    sconcno2      (station, time) float64 65.22 63.97 57.43 ... 25.97 20.7 16.95\n",
    +       "    lat           (station) float64 41.37 41.32\n",
    +       "    lon           (station) float64 2.185 2.135\n",
    +       "Attributes:\n",
    +       "    Conventions:  CF-1.7
    " + ], + "text/plain": [ + "\n", + "Dimensions: (time: 744, station: 2)\n", + "Coordinates:\n", + " * time (time) datetime64[ns] 2019-12-01 ... 2019-12-31T23:00:00\n", + " * station (station) float64 0.0 1.0\n", + "Data variables:\n", + " station_name (station) |S75 ...\n", + " sconcno2 (station, time) float64 ...\n", + " lat (station) float64 ...\n", + " lon (station) float64 ...\n", + "Attributes:\n", + " Conventions: CF-1.7" + ] + }, + "execution_count": 17, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "xr.open_dataset('/esarchive/obs/generalitat/port-barcelona/hourly/sconcno2/sconcno2_201912.nc')" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.7.4" + } + }, + "nbformat": 4, + "nbformat_minor": 4 +} diff --git a/Jupyter_notebooks/Jupyter_bash_nord3v2.cmd b/Jupyter_notebooks/Jupyter_bash_nord3v2.cmd index cb065a6ec60513f6321e83cfe626c810e7a93e8a..450b725909ac10e129173fbfb3b2a4e7d3cff40a 100644 --- a/Jupyter_notebooks/Jupyter_bash_nord3v2.cmd +++ b/Jupyter_notebooks/Jupyter_bash_nord3v2.cmd @@ -29,9 +29,11 @@ module load netcdf4-python/1.5.3-foss-2019b-Python-3.7.4 module load xarray/0.19.0-foss-2019b-Python-3.7.4 module load cftime/1.0.1-foss-2019b-Python-3.7.4 module load cfunits/1.8-foss-2019b-Python-3.7.4 +module load filelock/3.7.1-foss-2019b-Python-3.7.4 +module load pyproj/2.5.0-foss-2019b-Python-3.7.4 -export PYTHONPATH=/gpfs/scratch/bsc32/bsc32538/NES_tests/NES:${PYTHONPATH} -# export PYTHONPATH=/esarchive/scratch/avilanova/software/NES:${PYTHONPATH} +# export PYTHONPATH=/gpfs/scratch/bsc32/bsc32538/NES_tests/NES:${PYTHONPATH} +export PYTHONPATH=/esarchive/scratch/avilanova/software/NES:${PYTHONPATH} # DON'T USE ADDRESS BELOW. # DO USE TOKEN BELOW diff --git a/Jupyter_notebooks/input/Dades_Port_Barcelona_2017-2021_corr.xlsx b/Jupyter_notebooks/input/Dades_Port_Barcelona_2017-2021_corr.xlsx new file mode 100644 index 0000000000000000000000000000000000000000..387c74b075e319b2cc2df2560b69d647d83761ef Binary files /dev/null and b/Jupyter_notebooks/input/Dades_Port_Barcelona_2017-2021_corr.xlsx differ diff --git a/Jupyter_notebooks/input/estaciones.csv b/Jupyter_notebooks/input/estaciones.csv new file mode 100644 index 0000000000000000000000000000000000000000..ea01b3a0489c8a1a0699114db579c675d3492f03 --- /dev/null +++ b/Jupyter_notebooks/input/estaciones.csv @@ -0,0 +1,4 @@ +station.code,lat,lon,standardised_network_provided_area_classification +Dàrsena sud,41.332889028571,2.1408072098364, +Unitat Mobil,41.3737770961323,2.18451410008966, +ZAL Prat,41.3172766511896,2.13450079021309, diff --git a/nes/create_nes.py b/nes/create_nes.py index 814f692e8ba5c5a8313d3084bc72155cd56797e9..9147418eaa65659eaad5269600588a4cd565c32e 100644 --- a/nes/create_nes.py +++ b/nes/create_nes.py @@ -8,9 +8,10 @@ from mpi4py import MPI from nes.nc_projections.rotated_nes import RotatedNes from nes.nc_projections.latlon_nes import LatLonNes from nes.nc_projections.points_nes import PointsNes +from nes.nc_projections.lcc_nes import LCCNes -def create_nes(comm=None, info=False, projection=None, create_nes=True, parallel_method='Y', balanced=False, **kwargs): +def create_nes(comm=None, info=False, projection=None, parallel_method='Y', balanced=False, times=None, **kwargs): if comm is None: comm = MPI.COMM_WORLD @@ -22,7 +23,7 @@ def create_nes(comm=None, info=False, projection=None, create_nes=True, parallel for name, value in kwargs.items(): kwargs_list.append(name) - if projection==None: + if projection is None: required_vars = ['lat', 'lon'] elif projection == 'regular': required_vars = ['lat_orig', 'lon_orig', 'inc_lat', 'inc_lon', 'n_lat', 'n_lon'] @@ -39,20 +40,26 @@ def create_nes(comm=None, info=False, projection=None, create_nes=True, parallel msg += 'Variable {0} has not been defined.'.format(var) warnings.warn(msg) - if projection == None: + if projection is None: if parallel_method != 'X': raise ValueError("Parallel method must be 'X' to create points NES.") nessy = PointsNes(comm=comm, dataset=None, xarray=None, info=info, parallel_method=parallel_method, avoid_first_hours=0, avoid_last_hours=0, first_level=0, last_level=None, balanced=balanced, - create_nes=create_nes, **kwargs) + create_nes=True, times=times, **kwargs) elif projection == 'regular': nessy = LatLonNes(comm=comm, dataset=None, xarray=None, info=info, parallel_method=parallel_method, avoid_first_hours=0, avoid_last_hours=0, first_level=0, last_level=None, balanced=balanced, - create_nes=create_nes, **kwargs) + create_nes=True, times=times, **kwargs) elif projection == 'rotated': nessy = RotatedNes(comm=comm, dataset=None, xarray=None, info=info, parallel_method=parallel_method, avoid_first_hours=0, avoid_last_hours=0, first_level=0, last_level=None, balanced=balanced, - create_nes=create_nes, **kwargs) + create_nes=True, times=times, **kwargs) + elif projection == 'lcc': + nessy = LCCNes(comm=comm, dataset=None, xarray=None, info=info, parallel_method=parallel_method, + avoid_first_hours=0, avoid_last_hours=0, first_level=0, last_level=None, balanced=balanced, + create_nes=True, times=times, **kwargs) + else: + raise NotImplementedError(projection) return nessy \ No newline at end of file diff --git a/nes/interpolation/__init__.py b/nes/interpolation/__init__.py index 7b7fede8f2755d4b0b211d5e6d856202d3223802..22c351a85dec0724f58fe1b70502c171b5286c7a 100644 --- a/nes/interpolation/__init__.py +++ b/nes/interpolation/__init__.py @@ -1,2 +1,3 @@ from .vertical_interpolation import add_4d_vertical_info from .vertical_interpolation import interpolate_vertical +from .horizontal_interpolation import interpolate_horizontal diff --git a/nes/interpolation/horizontal_interpolation.py b/nes/interpolation/horizontal_interpolation.py new file mode 100644 index 0000000000000000000000000000000000000000..ab6d774bb92c7d1496b9da56269589b9f6bb5ddd --- /dev/null +++ b/nes/interpolation/horizontal_interpolation.py @@ -0,0 +1,183 @@ +#!/usr/bin/env python + +import sys +import numpy as np +import os +import nes +from mpi4py import MPI +from scipy import spatial +from filelock import FileLock +from datetime import datetime +from warnings import warn + + +def interpolate_horizontal(self, dst_grid, weight_matrix_path=None, kind='NearestNeighbour', n_neighbours=4, + info=False): + """ + + Parameters + ---------- + self : nes.Nes + + dst_grid : nes.Nes + + + """ + # Obtain weight matrix + weights, idx = get_weights_idx(self, dst_grid, weight_matrix_path, kind, n_neighbours) + + # Apply weights + final_dst = dst_grid.copy() + # return final_dst + final_dst.lev = self.lev + final_dst._lev = self._lev + final_dst.time = self.time + final_dst._time = self._time + final_dst.hours_start = self.hours_start + final_dst.hours_end = self.hours_end + + for var_name, var_info in self.variables.items(): + if info and self.master: + print("\t{var} horizontal interpolation".format(var=var_name)) + sys.stdout.flush() + src_shape = var_info['data'].shape + dst_shape = (src_shape[0], src_shape[1], idx.shape[-2], idx.shape[-1]) + # Creating new variable without data + final_dst.variables[var_name] = {attr_name: attr_value for attr_name, attr_value in var_info.items() + if attr_name != 'data'} + # Creating empty data + final_dst.variables[var_name]['data'] = np.empty(dst_shape) + + src_data = var_info['data'].reshape((src_shape[0], src_shape[1], src_shape[2] * src_shape[3])) + for time in range(dst_shape[0]): + for lev in range(dst_shape[1]): + src_aux = np.take(src_data[time, lev], idx) + final_dst.variables[var_name]['data'][time, lev] = np.sum(weights * src_aux, axis=1) + + return final_dst + + +def get_weights_idx(self, dst_grid, weight_matrix_path, kind, n_neighbours): + if self.parallel_method != 'T': + raise NotImplemented("Parallel method {0} is not implemented yet for horizontal interpolations. Use 'T'".format( + self.parallel_method)) + if weight_matrix_path is not None: + with FileLock(weight_matrix_path.replace('.nc', '.lock')): + if self.master: + if os.path.isfile(weight_matrix_path): + weight_matrix = read_weight_matrix(weight_matrix_path, comm=MPI.COMM_SELF) + if len(weight_matrix.lev['data']) != n_neighbours: + warn("The selected weight matrix does not have the same number of nearest neighbours." + + "Re-calculating again but not saving it.") + if kind in ['NearestNeighbour', 'NearestNeighbours', 'nn', 'NN']: + weight_matrix = create_nn_weight_matrix(self, dst_grid, n_neighbours=n_neighbours) + else: + raise NotImplementedError(kind) + else: + if kind in ['NearestNeighbour', 'NearestNeighbours', 'nn', 'NN']: + weight_matrix = create_nn_weight_matrix(self, dst_grid, n_neighbours=n_neighbours) + else: + raise NotImplementedError(kind) + if weight_matrix_path is not None: + weight_matrix.to_netcdf(weight_matrix_path) + else: + weight_matrix = None + else: + if kind in ['NearestNeighbour', 'NearestNeighbours', 'nn', 'NN']: + if self.master: + weight_matrix = create_nn_weight_matrix(self, dst_grid, n_neighbours=n_neighbours) + else: + weight_matrix = None + else: + raise NotImplementedError(kind) + + # Normalize to 1 + if self.master: + weights = np.array(np.array(weight_matrix.variables['inverse_dists']['data'], dtype=np.float64) / + np.array(weight_matrix.variables['inverse_dists']['data'], dtype=np.float64).sum(axis=1), + dtype=np.float64) + idx = np.array(weight_matrix.variables['idx']['data'][0], dtype=int) + else: + weights = None + idx = None + + weights = self.comm.bcast(weights, root=0) + idx = self.comm.bcast(idx, root=0) + + return weights, idx + + +def read_weight_matrix(weight_matrix_path, comm=None, parallel_method='T'): + weight_matrix = nes.open_netcdf(path=weight_matrix_path, comm=comm, parallel_method=parallel_method, balanced=True) + weight_matrix.load() + + return weight_matrix + + +def create_nn_weight_matrix(self, dst_grid, n_neighbours=4, info=False): + if info and self.master: + print("\tCreating Nearest Neighbour Weight Matrix with {0} neighbours".format(n_neighbours)) + sys.stdout.flush() + # Source + src_lat = np.array(self.lat['data'], dtype=np.float32) + src_lon = np.array(self.lon['data'], dtype=np.float32) + + # 1D to 2D coordinates + if len(src_lon.shape) == 1: + src_lon, src_lat = np.meshgrid(src_lon, src_lat) + + # Destination + dst_lat = np.array(dst_grid.lat['data'], dtype=np.float32) + dst_lon = np.array(dst_grid.lon['data'], dtype=np.float32) + + # 1D to 2D coordinates + if len(dst_lon.shape) == 1: + dst_lon, dst_lat = np.meshgrid(dst_lon, dst_lat) + + # calculate N nearest neighbour inverse distance weights (and indices) + # from gridcells centres of model 1 to each gridcell centre of model 2 + # model geographic longitude/latitude coordinates are first converted + # to cartesian ECEF (Earth Centred, Earth Fixed) coordinates, before + # calculating distances. + + src_mod_xy = lon_lat_to_cartesian(src_lon.flatten(), src_lat.flatten()) + dst_mod_xy = lon_lat_to_cartesian(dst_lon.flatten(), dst_lat.flatten()) + + # generate KDtree using model 1 coordinates (i.e. the model grid you are + # interpolating from) + src_tree = spatial.cKDTree(src_mod_xy) + + # get n-neighbour nearest distances/indices (ravel form) of model 1 gridcell + # centres from each model 2 gridcell centre + + dists, idx = src_tree.query(dst_mod_xy, k=n_neighbours) + # self.nearest_neighbour_inds = \ + # np.column_stack(np.unravel_index(idx, lon.shape)) + + weight_matrix = dst_grid.copy() + weight_matrix.time = [datetime(year=2000, month=1, day=1, hour=0, second=0, microsecond=0)] + weight_matrix._time = [datetime(year=2000, month=1, day=1, hour=0, second=0, microsecond=0)] + weight_matrix.set_communicator(MPI.COMM_SELF) + # take the reciprocals of the nearest neighbours distances + inverse_dists = np.reciprocal(dists) + inverse_dists_transf = inverse_dists.T.reshape((1, n_neighbours, dst_lon.shape[0], dst_lon.shape[1])) + weight_matrix.variables['inverse_dists'] = {'data': inverse_dists_transf, 'units': 'm'} + idx_transf = idx.T.reshape((1, n_neighbours, dst_lon.shape[0], dst_lon.shape[1])) + weight_matrix.variables['idx'] = {'data': idx_transf, 'units': ''} + weight_matrix.lev = {'data': np.arange(inverse_dists_transf.shape[1]), 'units': ''} + weight_matrix._lev = {'data': np.arange(inverse_dists_transf.shape[1]), 'units': ''} + return weight_matrix + + +def lon_lat_to_cartesian(lon, lat, R=1): + """ + calculates lon, lat coordinates of a point on a sphere with + radius R + """ + lon_r = np.radians(lon) + lat_r = np.radians(lat) + + x = R * np.cos(lat_r) * np.cos(lon_r) + y = R * np.cos(lat_r) * np.sin(lon_r) + z = R * np.sin(lat_r) + return np.column_stack([x, y, z]) diff --git a/nes/load_nes.py b/nes/load_nes.py index 57f9016d8e354be70c2d56d736e84d7d9ff7275e..229168e6563e256bf701d7018a56b0554375318c 100644 --- a/nes/load_nes.py +++ b/nes/load_nes.py @@ -9,6 +9,8 @@ from nes.nc_projections.rotated_nes import RotatedNes from nes.nc_projections.latlon_nes import LatLonNes from nes.nc_projections.points_nes import PointsNes from nes.nc_projections.points_nes_ghost import PointsNesGHOST +from nes.nc_projections.lcc_nes import LCCNes + from nes.nc_projections import * @@ -40,6 +42,7 @@ def open_netcdf(path, comm=None, xarray=False, info=False, parallel_method='Y', Nes Nes object. Variables read in lazy mode (only metadata) """ + if comm is None: comm = MPI.COMM_WORLD else: @@ -70,6 +73,11 @@ def open_netcdf(path, comm=None, xarray=False, info=False, parallel_method='Y', nessy = PointsNes(comm=comm, dataset=dataset, xarray=xarray, info=info, parallel_method=parallel_method, avoid_first_hours=avoid_first_hours, avoid_last_hours=avoid_last_hours, first_level=first_level, last_level=last_level, create_nes=False, balanced=balanced,) + elif __is_lcc(dataset): + # Lambert conformal conic grids + nessy = LCCNes(comm=comm, dataset=dataset, xarray=xarray, info=info, parallel_method=parallel_method, + avoid_first_hours=avoid_first_hours, avoid_last_hours=avoid_last_hours, + first_level=first_level, last_level=last_level, create_nes=False, balanced=balanced,) else: # Regular grids nessy = LatLonNes(comm=comm, dataset=dataset, xarray=xarray, info=info, parallel_method=parallel_method, @@ -114,6 +122,12 @@ def __is_points_GHOST(dataset): else: return False +def __is_lcc(dataset): + + if 'x' in dataset.dimensions and 'y' in dataset.dimensions: + return True + else: + return False def concatenate_netcdfs(nessy_list, comm=None): if not isinstance(nessy_list, list) or len(nessy_list) < 2: diff --git a/nes/nc_projections/default_nes.py b/nes/nc_projections/default_nes.py index 74b85d6c77a56445fcab82246a1a72aa5adfd5c5..2575513135c67aef351a32367f4ece7fd86091f8 100644 --- a/nes/nc_projections/default_nes.py +++ b/nes/nc_projections/default_nes.py @@ -82,7 +82,7 @@ class Nes(object): """ def __init__(self, comm=None, path=None, info=False, dataset=None, xarray=False, parallel_method='Y', avoid_first_hours=0, avoid_last_hours=0, first_level=0, last_level=None, create_nes=False, - balanced=False, **kwargs): + balanced=False, times=None, **kwargs): """ Initialize the Nes class @@ -141,7 +141,10 @@ class Nes(object): self.variables = {} # Complete dimensions - self._time = self.__get_time(create_nes, **kwargs) + if times is None: + self._time = self.__get_time(create_nes, **kwargs) + else: + self._time = times self._time_bnds = self.__get_time_bnds(create_nes) self._lev = {'data': np.array([0]), 'units': '', @@ -1414,7 +1417,10 @@ class Nes(object): # LEVELS lev = netcdf.createVariable('lev', np.float64, ('lev',), zlib=self.zip_lvl > 0, complevel=self.zip_lvl) - lev.units = Units(self._lev['units'], formatted=True).units + if 'units' in self._lev.keys(): + lev.units = Units(self._lev['units'], formatted=True).units + else: + lev.units = '' lev.positive = 'up' if self.size > 1: lev.set_collective(True) @@ -1795,5 +1801,6 @@ class Nes(object): # Methods -Nes.interpolate_vertical = interpolate_vertical Nes.add_4d_vertical_info = add_4d_vertical_info +Nes.interpolate_vertical = interpolate_vertical +Nes.interpolate_horizontal = interpolate_horizontal diff --git a/nes/nc_projections/latlon_nes.py b/nes/nc_projections/latlon_nes.py index e119533e8ae285d39d00ef5d5a725b6d9d25003e..ccfc63217d5424eca9cf191558caa309a2072732 100644 --- a/nes/nc_projections/latlon_nes.py +++ b/nes/nc_projections/latlon_nes.py @@ -21,7 +21,7 @@ class LatLonNes(Nes): """ def __init__(self, comm=None, path=None, info=False, dataset=None, xarray=False, parallel_method='Y', avoid_first_hours=0, avoid_last_hours=0, first_level=0, last_level=None, create_nes=False, - balanced=False, **kwargs): + balanced=False, times=None, **kwargs): """ Initialize the LatLonNes class @@ -49,7 +49,7 @@ class LatLonNes(Nes): xarray=xarray, parallel_method=parallel_method, balanced=balanced, avoid_first_hours=avoid_first_hours, avoid_last_hours=avoid_last_hours, first_level=first_level, last_level=last_level, create_nes=create_nes, - **kwargs) + times=times, **kwargs) if create_nes: # Dimensions screening @@ -141,7 +141,7 @@ class LatLonNes(Nes): return None - def _set_crs(self, netcdf): + def _create_metadata(self, netcdf): """ Create the 'crs' variable for the rotated latitude longitude grid_mapping. @@ -158,18 +158,3 @@ class LatLonNes(Nes): mapping.inverse_flattening = 0 return None - - def _create_metadata(self, netcdf): - """ - Create metadata variables - - Parameters - ---------- - netcdf : Dataset - NetCDF object. - """ - - # Set crs - self._set_crs(netcdf) - - return None \ No newline at end of file diff --git a/nes/nc_projections/lcc_nes.py b/nes/nc_projections/lcc_nes.py new file mode 100644 index 0000000000000000000000000000000000000000..4eb0da862555b83b7988034119d5a80a7599d249 --- /dev/null +++ b/nes/nc_projections/lcc_nes.py @@ -0,0 +1,258 @@ +#!/usr/bin/env python + +import numpy as np +from cfunits import Units +from pyproj import Proj +from nes.nc_projections.default_nes import Nes + + +class LCCNes(Nes): + """ + + Attributes + ---------- + _var_dim : tuple + Tuple with the name of the Y and X dimensions for the variables. + ('lat', 'lon') for a regular latitude-longitude projection. + _lat_dim : tuple + Tuple with the name of the dimensions of the Latitude values. + ('lat',) for a regular latitude-longitude projection. + _lon_dim : tuple + Tuple with the name of the dimensions of the Longitude values. + ('lon',) for a regular latitude-longitude projection. + """ + def __init__(self, comm=None, path=None, info=False, dataset=None, xarray=False, parallel_method='Y', + avoid_first_hours=0, avoid_last_hours=0, first_level=0, last_level=None, create_nes=False, + balanced=False, times=None, **kwargs): + """ + Initialize the LCCNes class + + Parameters + ---------- + comm: MPI.COMM + Path to the CSV file that contains all the information. + path: str + Path to the NetCDF to initialize the object + info: bool + Indicates if you want to get reading/writing info + dataset: Dataset + NetCDF4-python Dataset to initialize the class + xarray: bool: + (Not working) Indicates if you want to use xarray as default + parallel_method : str + Indicates the parallelization method that you want. Default over Y axis + accepted values: ['X', 'Y', 'T'] + avoid_first_hours : int + Number of hours to remove from first time steps. + avoid_last_hours : int + Number of hours to remove from last time steps. + """ + super(LCCNes, self).__init__(comm=comm, path=path, info=info, dataset=dataset, + xarray=xarray, parallel_method=parallel_method, balanced=balanced, + avoid_first_hours=avoid_first_hours, avoid_last_hours=avoid_last_hours, + first_level=first_level, last_level=last_level, create_nes=create_nes, + times=times, **kwargs) + + if create_nes: + # Dimensions screening + self.lat = self._get_coordinate_values(self._lat, 'Y') + self.lon = self._get_coordinate_values(self._lon, 'X') + else: + # Complete dimensions + self._y = self._get_coordinate_dimension('y') + self._x = self._get_coordinate_dimension('x') + + # Dimensions screening + self.y = self._get_coordinate_values(self._y, 'Y') + self.x = self._get_coordinate_values(self._x, 'X') + + # Get projection details + self.projection_data = self.get_projection_data(create_nes, **kwargs) + + # Set axis limits for parallel writing + self.write_axis_limits = self.get_write_axis_limits() + + self._var_dim = ('y', 'x') + self._lat_dim = ('y', 'x') + self._lon_dim = ('y', 'x') + + self.free_vars('crs') + + @staticmethod + def new(comm=None, path=None, info=False, dataset=None, xarray=False, create=False, balanced=False, + parallel_method='Y', avoid_first_hours=0, avoid_last_hours=0, first_level=0, last_level=None): + """ + Initialize the Nes class + + Parameters + ---------- + comm: MPI.COMM + MPI Communicator + path: str + Path to the NetCDF to initialize the object + info: bool + Indicates if you want to get reading/writing info + dataset: Dataset + NetCDF4-python Dataset to initialize the class + xarray: bool: + (Not working) Indicates if you want to use xarray as default + avoid_first_hours : int + Number of hours to remove from first time steps. + avoid_last_hours : int + Number of hours to remove from last time steps. + parallel_method : str + Indicates the parallelization method that you want. Default over Y axis + accepted values: ['Y', 'T'] + """ + new = LCCNes(comm=comm, path=path, info=info, dataset=dataset, xarray=xarray, balanced=balanced, + parallel_method=parallel_method, avoid_first_hours=avoid_first_hours, + avoid_last_hours=avoid_last_hours, first_level=first_level, last_level=last_level) + return new + + def get_projection_data(self, create_nes, **kwargs): + """ + Read the projection data + + Returns + ------- + projection : dict + Dictionary with the projection data + """ + + if create_nes: + projection = {'data': None, + 'dimensions': (), + 'grid_mapping_name': 'lambert_conformal_conic', + 'standard_parallel': [kwargs['lat_2'], kwargs['lat_1']], + 'longitude_of_central_meridian': kwargs['lon_0'], + 'latitude_of_projection_origin': kwargs['lat_0'], + } + + else: + projection = self.variables['Lambert_conformal'] + self.free_vars('Lambert_conformal') + + return projection + + def _create_dimensions(self, netcdf): + """ + Create the 'y', 'x' dimensions and the super dimensions ('lev', 'time'). + + Parameters + ---------- + netcdf : Dataset + NetCDF object. + """ + super(LCCNes, self)._create_dimensions(netcdf) + + netcdf.createDimension('y', len(self._y['data'])) + netcdf.createDimension('x', len(self._x['data'])) + + return None + + def _create_dimension_variables(self, netcdf): + """ + Create the 'y' and 'x' variables. + + Parameters + ---------- + netcdf : Dataset + NetCDF object. + """ + + super(LCCNes, self)._create_dimension_variables(netcdf) + + # LCC LATITUDES + y = netcdf.createVariable('y', self._y['data'].dtype, ('y',)) + y.long_name = "y coordinate of projection" + y.units = Units("m", formatted=True).units + y.standard_name = "projection_y_coordinate" + if self.size > 1: + y.set_collective(True) + y[:] = self._y['data'] + + # LCC LONGITUDES + x = netcdf.createVariable('x', self._x['data'].dtype, ('x',)) + x.long_name = "x coordinate of projection" + x.units = Units("m", formatted=True).units + x.standard_name = "projection_x_coordinate" + if self.size > 1: + x.set_collective(True) + x[:] = self._x['data'] + + return None + + def _create_centroids(self, **kwargs): + """ + Calculate center latitudes and longitudes from grid details. + + Parameters + ---------- + netcdf : Dataset + NetCDF object. + """ + + # Create a regular grid in metres (1D) + self._x = {'data': np.linspace(kwargs['x_0'] + (kwargs['inc_x'] / 2), + kwargs['x_0'] + (kwargs['inc_x'] / 2) + + (kwargs['inc_x'] * (kwargs['nx'] - 1)), kwargs['nx'], + dtype=np.float)} + self._y = {'data': np.linspace(kwargs['y_0'] + (kwargs['inc_y'] / 2), + kwargs['y_0'] + (kwargs['inc_y'] / 2) + + (kwargs['inc_y'] * (kwargs['ny'] - 1)), kwargs['ny'], + dtype=np.float)} + + # Create a regular grid in metres (1D to 2D) + x = np.array([self._x['data']] * len(self._y['data'])) + y = np.array([self._y['data']] * len(self._x['data'])).T + + projection = Proj( + proj='lcc', + ellps='WGS84', + R=6370000.00, + lat_1=kwargs['lat_1'], + lat_2=kwargs['lat_2'], + lon_0=kwargs['lon_0'], + lat_0=kwargs['lat_0'], + to_meter=1, + x_0=0, + y_0=0, + a=6370000.00, + k_0=1.0) + + # Calculate center latitudes and longitudes (UTM to LCC) + self.center_lons, self.center_lats = projection(x, y, inverse=True) + + return {'data': self.center_lats}, {'data': self.center_lons} + + @staticmethod + def _set_var_crs(var): + """ + Set the grid_mapping to 'Lambert_conformal'. + + Parameters + ---------- + var : Variable + netCDF4-python variable object. + """ + var.grid_mapping = 'Lambert_conformal' + + return None + + def _create_metadata(self, netcdf): + """ + Create the 'crs' variable for the lamber conformal latitude longitude grid_mapping. + + Parameters + ---------- + netcdf : Dataset + netcdf4-python Dataset + """ + + mapping = netcdf.createVariable('Lambert_conformal', 'c') + mapping.grid_mapping_name = self.projection_data['grid_mapping_name'] + mapping.standard_parallel = self.projection_data['standard_parallel'] + mapping.longitude_of_central_meridian = self.projection_data['longitude_of_central_meridian'] + mapping.latitude_of_projection_origin = self.projection_data['latitude_of_projection_origin'] + + return None diff --git a/nes/nc_projections/points_nes.py b/nes/nc_projections/points_nes.py index 20c9517d5923157ece90d77d5382ce4d052c7714..34521f0ff881467a57138d516042354de9a2dd35 100644 --- a/nes/nc_projections/points_nes.py +++ b/nes/nc_projections/points_nes.py @@ -17,17 +17,20 @@ class PointsNes(Nes): ---------- _var_dim : tuple Tuple with the name of the Y and X dimensions for the variables. - ('lat', 'lon') for a regular latitude-longitude projection. + ('lat', 'lon') for a points grid. _lat_dim : tuple Tuple with the name of the dimensions of the Latitude values. - ('lat',) for a regular latitude-longitude projection. + ('lat',) for a points grid. _lon_dim : tuple Tuple with the name of the dimensions of the Longitude values. - ('lon',) for a regular latitude-longitude projection. + ('lon',) for a points grid. + _station : tuple + Tuple with the name of the dimensions of the station values. + ('station',) for a points grid. """ def __init__(self, comm=None, path=None, info=False, dataset=None, xarray=False, parallel_method='X', avoid_first_hours=0, avoid_last_hours=0, first_level=0, last_level=None, create_nes=False, - **kwargs): + times=None, **kwargs): """ Initialize the PointsNes class @@ -56,7 +59,7 @@ class PointsNes(Nes): xarray=xarray, parallel_method=parallel_method, avoid_first_hours=avoid_first_hours, avoid_last_hours=avoid_last_hours, first_level=first_level, last_level=last_level, create_nes=create_nes, - **kwargs) + times=times, **kwargs) if create_nes: # Complete dimensions @@ -69,7 +72,8 @@ class PointsNes(Nes): else: self._station = self._get_coordinate_dimension(['station']) self.station = self._get_coordinate_values(self._station, 'X') - self.strlen = self._get_strlen() + + self.strlen = self._get_strlen(create_nes) # Set axis limits for parallel writing self.write_axis_limits = self.get_write_axis_limits() @@ -281,7 +285,7 @@ class PointsNes(Nes): return variables - def _get_strlen(self): + def _get_strlen(self, create_nes): """ Read the string length dimension of some variables. @@ -291,10 +295,14 @@ class PointsNes(Nes): String length. """ - if 'strlen' in self.netcdf.dimensions: - strlen = self.netcdf.dimensions['strlen'].size + if not create_nes: + if 'strlen' in self.netcdf.dimensions: + strlen = self.netcdf.dimensions['strlen'].size + else: + strlen = None else: - strlen = None + # TODO: Check if strings are always divided into 75 in the real networks + strlen = 75 return strlen diff --git a/nes/nc_projections/points_nes_ghost.py b/nes/nc_projections/points_nes_ghost.py index 1642f7566b727ee041084258e2f5ff76b1c42bce..90349ee81a19ab8cbf4df72d746c1b30025cbee7 100644 --- a/nes/nc_projections/points_nes_ghost.py +++ b/nes/nc_projections/points_nes_ghost.py @@ -14,21 +14,18 @@ class PointsNesGHOST(PointsNes): Attributes ---------- - _var_dim : tuple - Tuple with the name of the Y and X dimensions for the variables. - ('lat', 'lon') for a regular latitude-longitude projection. - _lat_dim : tuple - Tuple with the name of the dimensions of the Latitude values. - ('lat',) for a regular latitude-longitude projection. - _lon_dim : tuple - Tuple with the name of the dimensions of the Longitude values. - ('lon',) for a regular latitude-longitude projection. + _qa : tuple + Tuple with the name of the dimensions of the quality assurance (qa) flag values. + ('qa',) for a points grid. + _flag : tuple + Tuple with the name of the dimensions of the data flag values. + ('flag',) for a points grid. """ def __init__(self, comm=None, path=None, info=False, dataset=None, xarray=False, parallel_method='X', avoid_first_hours=0, avoid_last_hours=0, first_level=0, last_level=None, create_nes=False, - **kwargs): + times=None, **kwargs): """ - Initialize the PointsNes class + Initialize the PointsNesGHOST class Parameters ---------- @@ -44,7 +41,7 @@ class PointsNesGHOST(PointsNes): (Not working) Indicates if you want to use xarray as default parallel_method : str Indicates the parallelization method that you want. Default over Y axis - accepted values: ['Y', 'T'] + accepted values: ['X'] avoid_first_hours : int Number of hours to remove from first time steps. avoid_last_hours : int @@ -55,7 +52,7 @@ class PointsNesGHOST(PointsNes): xarray=xarray, parallel_method=parallel_method, avoid_first_hours=avoid_first_hours, avoid_last_hours=avoid_last_hours, first_level=first_level, last_level=last_level, create_nes=create_nes, - **kwargs) + times=times, **kwargs) self._flag = self._get_coordinate_dimension(['flag']) self.flag = self._get_coordinate_values(self._flag, 'X') diff --git a/nes/nc_projections/rotated_nes.py b/nes/nc_projections/rotated_nes.py index ff4c1940294da0ff88c91ab94c897c4c9adb434f..0d0ba72700b4d974193ca67c0e1d4f9993e825ee 100644 --- a/nes/nc_projections/rotated_nes.py +++ b/nes/nc_projections/rotated_nes.py @@ -34,7 +34,7 @@ class RotatedNes(Nes): """ def __init__(self, comm=None, path=None, info=False, dataset=None, xarray=False, parallel_method='Y', avoid_first_hours=0, avoid_last_hours=0, first_level=0, last_level=None, create_nes=False, - balanced=False, **kwargs): + balanced=False, times=None, **kwargs): """ Initialize the RotatedNes class @@ -63,7 +63,7 @@ class RotatedNes(Nes): xarray=xarray, parallel_method=parallel_method, avoid_first_hours=avoid_first_hours, avoid_last_hours=avoid_last_hours, first_level=first_level, last_level=last_level, create_nes=create_nes, - **kwargs) + times=times, **kwargs) if create_nes: # Dimensions screening @@ -269,7 +269,7 @@ class RotatedNes(Nes): netcdf : Dataset NetCDF object. """ - + # Complete dimensions self._rlat, self._rlon = self._create_rotated_coordinates(**kwargs) @@ -294,7 +294,7 @@ class RotatedNes(Nes): return None - def _set_crs(self, netcdf): + def _create_metadata(self, netcdf): """ Create the 'crs' variable for the rotated latitude longitude grid_mapping. diff --git a/requirements.txt b/requirements.txt index 7935a2bbf051937d90bee16eccf10596a361dbf1..177f449ed12b759e767de38a4947fb11f2db1b1a 100644 --- a/requirements.txt +++ b/requirements.txt @@ -8,4 +8,5 @@ pyproj~=3.2.1 setuptools~=47.1.0 pytest~=6.2.5 Shapely~=1.8.0 -scipy \ No newline at end of file +scipy +filelock \ No newline at end of file diff --git a/tests/2-nes_tests_by_projection.py b/tests/2-nes_tests_by_projection.py index e3a6dd51a43246999d5d21e107c56ff2be0aca95..da542f42122247e62ccf1d43478ddd8d7a999b8c 100644 --- a/tests/2-nes_tests_by_projection.py +++ b/tests/2-nes_tests_by_projection.py @@ -15,12 +15,17 @@ paths = {'regular_file': {'path': '/gpfs/scratch/bsc32/bsc32538/mr_multiplyby/or 'parallel_methods': ['X', 'Y', 'T']}, 'points_file': {'path': '/esarchive/obs/eea/eionet/hourly/pm10/pm10_202107.nc', 'projection': 'points', - 'variables': [], + 'variables': [], # all 'parallel_methods': ['X']}, 'points_ghost_file': {'path': '/gpfs/projects/bsc32/AC_cache/obs/ghost/EANET/1.4/daily/sconcso4/sconcso4_201911.nc', 'projection': 'points_ghost', - 'variables': [], - 'parallel_methods': ['X']}} + 'variables': [], # all + 'parallel_methods': ['X']}, + 'lcc_file': {'path': '/esarchive/exp/wrf-hermes-cmaq/b075/eu/hourly/pm10/pm10_2022062600.nc', + 'projection': 'lcc', + 'variables': [], # all + 'parallel_methods': ['X', 'Y', 'T']} + } results = [] diff --git a/tests/scalability_test_nord3v2.bash b/tests/scalability_test_nord3v2.bash index 57758ebf130547995dab8246b0fcd9d412c1f0c9..bfde337f0556b5daa4d55ace8c12bcd0c6867586 100644 --- a/tests/scalability_test_nord3v2.bash +++ b/tests/scalability_test_nord3v2.bash @@ -11,6 +11,8 @@ module load cfunits/1.8-foss-2019b-Python-3.7.4 module load xarray/0.17.0-foss-2019b-Python-3.7.4 module load pandas/1.2.4-foss-2019b-Python-3.7.4 module load mpi4py/3.0.3-foss-2019b-Python-3.7.4 +module load filelock/3.7.1-foss-2019b-Python-3.7.4 +module load pyproj/2.5.0-foss-2019b-Python-3.7.4 for nprocs in 1 2 4 8 do diff --git a/tests/test_bash_mn4.cmd b/tests/test_bash_mn4.cmd index 9710c5b9d210f0f88f769a1957960e3dfca57ad4..27c3bbde7d8886d8621e3f8b14ce3b2167b4680e 100644 --- a/tests/test_bash_mn4.cmd +++ b/tests/test_bash_mn4.cmd @@ -20,6 +20,7 @@ module load netcdf4-python/1.5.3-foss-2019b-Python-3.7.4 module load cfunits/1.8-foss-2019b-Python-3.7.4 module load xarray/0.17.0-foss-2019b-Python-3.7.4 module load OpenMPI/4.0.5-GCC-8.3.0-mn4 +module load filelock/3.7.1-foss-2019b-Python-3.7.4 export PYTHONPATH=/gpfs/scratch/bsc32/bsc32538/NES_tests/NES:${PYTHONPATH} cd /gpfs/scratch/bsc32/bsc32538/NES_tests/NES/tests diff --git a/tests/test_bash_nord3v2.cmd b/tests/test_bash_nord3v2.cmd index 3b570f96ccafe041944f901219d1004af823a073..bf10ffa29694355ea53151c82cf8db54979c1d58 100644 --- a/tests/test_bash_nord3v2.cmd +++ b/tests/test_bash_nord3v2.cmd @@ -20,6 +20,7 @@ module load cfunits/1.8-foss-2019b-Python-3.7.4 module load xarray/0.17.0-foss-2019b-Python-3.7.4 module load pandas/1.2.4-foss-2019b-Python-3.7.4 module load mpi4py/3.0.3-foss-2019b-Python-3.7.4 +module load filelock/3.7.1-foss-2019b-Python-3.7.4 export PYTHONPATH=/esarchive/scratch/avilanova/software/NES:${PYTHONPATH} cd /esarchive/scratch/avilanova/software/NES/tests