From eef466dc1ff98cc12acc803db72730753e05cd16 Mon Sep 17 00:00:00 2001 From: Alba Vilanova Date: Wed, 24 Aug 2022 10:04:57 +0200 Subject: [PATCH] Complete implementation of read and write Providentia experiments --- Jupyter_notebooks/1-introduction.ipynb | 22 +- Jupyter_notebooks/1.1-regular_grids.ipynb | 58 +- Jupyter_notebooks/1.2-rotated_grids.ipynb | 32 +- Jupyter_notebooks/1.3-points_grids.ipynb | 1172 +- Jupyter_notebooks/1.4-lcc_grids.ipynb | 392 +- Jupyter_notebooks/1.5-mercator_grids.ipynb | 28 +- Jupyter_notebooks/2-create_nes.ipynb | 249 +- Jupyter_notebooks/4-providentia.ipynb | 9782 +++++++++++++---- .../4.1-to_providentia_latlon.ipynb | 2009 ++++ .../4.2-to_providentia_rotated.ipynb | 2473 +++++ .../4.3-to_providentia_lcc.ipynb | 2098 ++++ Jupyter_notebooks/Jupyter_bash_nord3v2.cmd | 3 +- nes/create_nes.py | 31 +- nes/interpolation/horizontal_interpolation.py | 104 +- nes/interpolation/vertical_interpolation.py | 18 +- nes/load_nes.py | 85 +- nes/nc_projections/__init__.py | 1 + nes/nc_projections/default_nes.py | 477 +- nes/nc_projections/latlon_nes.py | 128 +- nes/nc_projections/lcc_nes.py | 145 +- nes/nc_projections/mercator_nes.py | 137 +- nes/nc_projections/points_nes.py | 363 +- nes/nc_projections/points_nes_ghost.py | 516 +- nes/nc_projections/points_nes_providentia.py | 592 + nes/nc_projections/rotated_nes.py | 157 +- tests/2-nes_tests_by_projection.py | 2 +- tests/test_bash_mn4.cmd | 2 +- tests/test_bash_nord3v2.cmd | 3 +- 28 files changed, 17448 insertions(+), 3631 deletions(-) create mode 100644 Jupyter_notebooks/4.1-to_providentia_latlon.ipynb create mode 100644 Jupyter_notebooks/4.2-to_providentia_rotated.ipynb create mode 100644 Jupyter_notebooks/4.3-to_providentia_lcc.ipynb create mode 100644 nes/nc_projections/points_nes_providentia.py diff --git a/Jupyter_notebooks/1-introduction.ipynb b/Jupyter_notebooks/1-introduction.ipynb index 615860d..ad512f3 100644 --- a/Jupyter_notebooks/1-introduction.ipynb +++ b/Jupyter_notebooks/1-introduction.ipynb @@ -32,8 +32,8 @@ "name": "stdout", "output_type": "stream", "text": [ - "CPU times: user 175 ms, sys: 159 ms, total: 335 ms\n", - "Wall time: 15.7 s\n" + "CPU times: user 156 ms, sys: 52.8 ms, total: 209 ms\n", + "Wall time: 15.2 s\n" ] } ], @@ -50,7 +50,7 @@ { "data": { "text/plain": [ - "" + "" ] }, "execution_count": 3, @@ -341,8 +341,8 @@ "text": [ "Rank 000: Loading O3 var (1/1)\n", "Rank 000: Loaded O3 var ((109, 24, 361, 467))\n", - "CPU times: user 1.21 s, sys: 7.1 s, total: 8.32 s\n", - "Wall time: 42 s\n" + "CPU times: user 1.15 s, sys: 6.44 s, total: 7.6 s\n", + "Wall time: 39.5 s\n" ] } ], @@ -379,8 +379,8 @@ "name": "stdout", "output_type": "stream", "text": [ - "CPU times: user 723 ms, sys: 719 ms, total: 1.44 s\n", - "Wall time: 14.3 s\n" + "CPU times: user 708 ms, sys: 497 ms, total: 1.2 s\n", + "Wall time: 14.5 s\n" ] } ], @@ -405,8 +405,8 @@ "name": "stdout", "output_type": "stream", "text": [ - "CPU times: user 403 ms, sys: 206 ms, total: 609 ms\n", - "Wall time: 611 ms\n" + "CPU times: user 340 ms, sys: 482 ms, total: 822 ms\n", + "Wall time: 823 ms\n" ] } ], @@ -442,8 +442,8 @@ "name": "stdout", "output_type": "stream", "text": [ - "CPU times: user 49.2 ms, sys: 30.3 ms, total: 79.4 ms\n", - "Wall time: 837 ms\n" + "CPU times: user 39.4 ms, sys: 29.8 ms, total: 69.2 ms\n", + "Wall time: 715 ms\n" ] } ], diff --git a/Jupyter_notebooks/1.1-regular_grids.ipynb b/Jupyter_notebooks/1.1-regular_grids.ipynb index c6733d6..3104f0c 100644 --- a/Jupyter_notebooks/1.1-regular_grids.ipynb +++ b/Jupyter_notebooks/1.1-regular_grids.ipynb @@ -1050,16 +1050,16 @@ " Domain: Global\n", " Conventions: None\n", " history: MONARCHv1.0 netcdf file.\n", - " comment: Generated on marenostrum4
  • Domain :
    Global
    Conventions :
    None
    history :
    MONARCHv1.0 netcdf file.
    comment :
    Generated on marenostrum4
  • " ], "text/plain": [ "\n", @@ -1271,7 +1271,7 @@ { "data": { "text/plain": [ - "" + "" ] }, "execution_count": 5, @@ -1895,7 +1895,7 @@ { "data": { "text/plain": [ - "" + "" ] }, "execution_count": 14, @@ -2281,14 +2281,14 @@ " Domain: Global\n", " Conventions: CF-1.7\n", " history: MONARCHv1.0 netcdf file.\n", - " comment: Generated on marenostrum4
    • O3
      (time, lev, lat, lon)
      float32
      ...
      long_name :
      O3
      units :
      unknown
      standard_name :
      O3
      grid_mapping :
      crs
      [20095344 values with dtype=float32]
    • crs
      ()
      |S1
      ...
      grid_mapping_name :
      latitude_longitude
      semi_major_axis :
      6371000.0
      inverse_flattening :
      0
      array(b'', dtype='|S1')
  • Domain :
    Global
    Conventions :
    CF-1.7
    history :
    MONARCHv1.0 netcdf file.
    comment :
    Generated on marenostrum4
  • " ], "text/plain": [ "\n", diff --git a/Jupyter_notebooks/1.2-rotated_grids.ipynb b/Jupyter_notebooks/1.2-rotated_grids.ipynb index 4cff1df..4116ba2 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
    • time_bnds
      (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", @@ -483,7 +483,7 @@ { "data": { "text/plain": [ - "" + "" ] }, "execution_count": 4, @@ -810,7 +810,7 @@ { "data": { "text/plain": [ - "" + "" ] }, "execution_count": 12, @@ -1198,14 +1198,14 @@ " 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", diff --git a/Jupyter_notebooks/1.3-points_grids.ipynb b/Jupyter_notebooks/1.3-points_grids.ipynb index 966ab17..2457c7e 100644 --- a/Jupyter_notebooks/1.3-points_grids.ipynb +++ b/Jupyter_notebooks/1.3-points_grids.ipynb @@ -418,7 +418,7 @@ " station_end_date (station) |S75 b'nan' b'nan' ... b'nan' b'nan'\n", " station_rural_back (station) |S75 b'nan' b'nan' ... b'nan' b'nan'\n", " latitude (station) float32 46.81 47.48 ... 53.33 38.88\n", - " station_ozone_classification (station) |S75 b'rural' b'rural' ... b'nan'
  • " ], "text/plain": [ "\n", @@ -710,7 +710,7 @@ { "data": { "text/plain": [ - "" + "" ] }, "execution_count": 4, @@ -805,8 +805,7 @@ " 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33,\n", " 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50,\n", " 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67,\n", - " 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83]),\n", - " 'units': ''}" + " 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83])}" ] }, "execution_count": 7, @@ -1409,7 +1408,7 @@ { "data": { "text/plain": [ - "" + "" ] }, "execution_count": 14, @@ -1789,26 +1788,27 @@ " fill: currentColor;\n", "}\n", "
    <xarray.Dataset>\n",
    -       "Dimensions:                       (time: 31, station: 84)\n",
    +       "Dimensions:                       (time: 31, station: 84, strlen: 75)\n",
            "Coordinates:\n",
            "  * time                          (time) datetime64[ns] 2015-07-01 ... 2015-0...\n",
            "  * station                       (station) float64 0.0 1.0 2.0 ... 82.0 83.0\n",
    +       "Dimensions without coordinates: strlen\n",
            "Data variables: (12/19)\n",
    -       "    station_start_date            (station) |S75 b'1980-01-01' ... b'nan'\n",
    -       "    station_zone                  (station) |S75 b'nan' b'nan' ... b'nan' b'nan'\n",
    -       "    street_type                   (station) |S75 b'nan' b'nan' ... b'nan' b'nan'\n",
    -       "    country_code                  (station) |S75 b'CH' b'CH' ... b'NL' b'IT'\n",
    -       "    ccaa                          (station) |S75 b'nan' b'nan' ... b'nan' b'nan'\n",
    -       "    station_name                  (station) |S75 b'payerne' ... b'lamezia terme'\n",
    -       "    ...                            ...\n",
    -       "    station_code                  (station) |S75 b'CH0002R' ... b'IT0016R'\n",
    -       "    station_end_date              (station) |S75 b'nan' b'nan' ... b'nan' b'nan'\n",
    -       "    station_rural_back            (station) |S75 b'nan' b'nan' ... b'nan' b'nan'\n",
    -       "    station_ozone_classification  (station) |S75 b'rural' b'rural' ... b'nan'\n",
            "    lat                           (station) float64 46.81 47.48 ... 53.33 38.88\n",
            "    lon                           (station) float64 6.944 8.905 ... 6.277 16.23\n",
    +       "    station_start_date            (station, strlen) object '1' '9' '8' ... '' ''\n",
    +       "    station_zone                  (station, strlen) object 'n' 'a' 'n' ... '' ''\n",
    +       "    street_type                   (station, strlen) object 'n' 'a' 'n' ... '' ''\n",
    +       "    country_code                  (station, strlen) object 'C' 'H' '' ... '' ''\n",
    +       "    ...                            ...\n",
    +       "    country                       (station, strlen) object 's' 'w' 'i' ... '' ''\n",
    +       "    altitude                      (station) float32 489.0 538.0 ... 1.0 6.0\n",
    +       "    station_code                  (station, strlen) object 'C' 'H' '0' ... '' ''\n",
    +       "    station_end_date              (station, strlen) object 'n' 'a' 'n' ... '' ''\n",
    +       "    station_rural_back            (station, strlen) object 'n' 'a' 'n' ... '' ''\n",
    +       "    station_ozone_classification  (station, strlen) object 'r' 'u' 'r' ... '' ''\n",
            "Attributes:\n",
    -       "    Conventions:  CF-1.7
  • Conventions :
    CF-1.7
  • " ], "text/plain": [ "\n", - "Dimensions: (time: 31, station: 84)\n", + "Dimensions: (time: 31, station: 84, strlen: 75)\n", "Coordinates:\n", " * time (time) datetime64[ns] 2015-07-01 ... 2015-0...\n", " * station (station) float64 0.0 1.0 2.0 ... 82.0 83.0\n", + "Dimensions without coordinates: strlen\n", "Data variables: (12/19)\n", - " station_start_date (station) |S75 ...\n", - " station_zone (station) |S75 ...\n", - " street_type (station) |S75 ...\n", - " country_code (station) |S75 ...\n", - " ccaa (station) |S75 ...\n", - " station_name (station) |S75 ...\n", - " ... ...\n", - " station_code (station) |S75 ...\n", - " station_end_date (station) |S75 ...\n", - " station_rural_back (station) |S75 ...\n", - " station_ozone_classification (station) |S75 ...\n", " lat (station) float64 ...\n", " lon (station) float64 ...\n", + " station_start_date (station, strlen) object ...\n", + " station_zone (station, strlen) object ...\n", + " street_type (station, strlen) object ...\n", + " country_code (station, strlen) object ...\n", + " ... ...\n", + " country (station, strlen) object ...\n", + " altitude (station) float32 ...\n", + " station_code (station, strlen) object ...\n", + " station_end_date (station, strlen) object ...\n", + " station_rural_back (station, strlen) object ...\n", + " station_ozone_classification (station, strlen) object ...\n", "Attributes:\n", " Conventions: CF-1.7" ] @@ -2501,7 +2411,7 @@ " source: Surface observations\n", " creator_name: Dene R. Bowdalo\n", " creator_email: dene.bowdalo@bsc.es\n", - " version: 1.4