diff --git a/CHANGELOG.md b/CHANGELOG.md index 16777801e873500ffb73768bfadaac2700d660ff..28733133b81841ea706b37a6be2cd195c7f51d97 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,7 @@ # NES CHANGELOG -### 0.9.0 -* Release date: 2022/08/12 +### 1.0.0 +* Release date: 2022/11/24 * Changes and new features: * First beta release * Open: @@ -11,8 +11,8 @@ * Lambert Conformal Conic * Mercator * Points - * Points * Points in GHOST format + * Points in Providentia format * Parallelization: * Balanced / Unbalanced * By time axis @@ -25,13 +25,17 @@ * Lambert Conformal Conic * Mercator * Points + * Shapefile * Write: * NetCDF + * CAMS REANALYSIS format * Grib2 + * Shapefile * Interpolation: * Vertical interpolation * Horizontal interpolation * Nearest Neighbours + * Providentia interpolation * Statistics: * Daily_mean * Daily_max diff --git a/Jupyter_notebooks/2-create_nes.ipynb b/Jupyter_notebooks/2-create_nes.ipynb deleted file mode 100644 index e69ddcb5f9f1492aeac2196540200ca6cd3d85cc..0000000000000000000000000000000000000000 --- a/Jupyter_notebooks/2-create_nes.ipynb +++ /dev/null @@ -1,3655 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# How to create regular, rotated, points, LCC and Mercator grids" - ] - }, - { - "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 nes import *" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## 1. Create regular grid" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": {}, - "outputs": [], - "source": [ - "lat_orig = 41.1\n", - "lon_orig = 1.8\n", - "inc_lat = 0.1\n", - "inc_lon = 0.1\n", - "n_lat = 10\n", - "n_lon = 10\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)" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Rank 000: Creating regular_grid.nc\n", - "Rank 000: NetCDF ready to write\n", - "Rank 000: Dimensions done\n" - ] - } - ], - "source": [ - "regular_grid.to_netcdf('regular_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, lat: 10, lon: 10)\n",
-       "Coordinates:\n",
-       "  * time     (time) datetime64[ns] 1996-12-31\n",
-       "  * lev      (lev) float64 0.0\n",
-       "  * lat      (lat) float64 41.15 41.25 41.35 41.45 ... 41.75 41.85 41.95 42.05\n",
-       "  * lon      (lon) float64 1.85 1.95 2.05 2.15 2.25 2.35 2.45 2.55 2.65 2.75\n",
-       "Data variables:\n",
-       "    crs      |S1 b''\n",
-       "Attributes:\n",
-       "    Conventions:  CF-1.7
" - ], - "text/plain": [ - "\n", - "Dimensions: (time: 1, lev: 1, lat: 10, lon: 10)\n", - "Coordinates:\n", - " * time (time) datetime64[ns] 1996-12-31\n", - " * lev (lev) float64 0.0\n", - " * lat (lat) float64 41.15 41.25 41.35 41.45 ... 41.75 41.85 41.95 42.05\n", - " * lon (lon) float64 1.85 1.95 2.05 2.15 2.25 2.35 2.45 2.55 2.65 2.75\n", - "Data variables:\n", - " crs |S1 ...\n", - "Attributes:\n", - " Conventions: CF-1.7" - ] - }, - "execution_count": 4, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "xr.open_dataset('regular_grid.nc')" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## 2. Create rotated grid" - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "metadata": {}, - "outputs": [], - "source": [ - "centre_lat = 51\n", - "centre_lon = 10\n", - "west_boundary = -35\n", - "south_boundary = -27\n", - "inc_rlat = 0.2\n", - "inc_rlon = 0.2\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)" - ] - }, - { - "cell_type": "code", - "execution_count": 6, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Rank 000: Creating rotated_grid.nc\n", - "Rank 000: NetCDF ready to write\n", - "Rank 000: Dimensions done\n" - ] - } - ], - "source": [ - "rotated_grid.to_netcdf('rotated_grid.nc', info=True)" - ] - }, - { - "cell_type": "code", - "execution_count": 7, - "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, 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",
-       "Data variables:\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
" - ], - "text/plain": [ - "\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", - "Data variables:\n", - " lat (rlat, rlon) float64 ...\n", - " lon (rlat, rlon) float64 ...\n", - " rotated_pole |S1 ...\n", - "Attributes:\n", - " Conventions: CF-1.7" - ] - }, - "execution_count": 7, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "xr.open_dataset('rotated_grid.nc')" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## 3. Create grid from points" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### File 1" - ] - }, - { - "cell_type": "code", - "execution_count": 8, - "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", - "
station.codelatlonstandardised_network_provided_area_classification
0ES0266A41.3793222.086140urban-centre
1ES0392A41.7277041.838531urban-suburban
2ES0395A41.5678242.014598urban-centre
3ES0559A41.3874242.164918urban-centre
4ES0567A41.3849062.119574urban-centre
...............
129ES2087A41.9292832.257302NaN
130ES2091A40.5799000.553500NaN
131ES2088A41.7710602.250647NaN
132ES1908A41.2390691.856564NaN
133ES9994A42.3583631.459455NaN
\n", - "

134 rows × 4 columns

\n", - "
" - ], - "text/plain": [ - " station.code lat lon \\\n", - "0 ES0266A 41.379322 2.086140 \n", - "1 ES0392A 41.727704 1.838531 \n", - "2 ES0395A 41.567824 2.014598 \n", - "3 ES0559A 41.387424 2.164918 \n", - "4 ES0567A 41.384906 2.119574 \n", - ".. ... ... ... \n", - "129 ES2087A 41.929283 2.257302 \n", - "130 ES2091A 40.579900 0.553500 \n", - "131 ES2088A 41.771060 2.250647 \n", - "132 ES1908A 41.239069 1.856564 \n", - "133 ES9994A 42.358363 1.459455 \n", - "\n", - " standardised_network_provided_area_classification \n", - "0 urban-centre \n", - "1 urban-suburban \n", - "2 urban-centre \n", - "3 urban-centre \n", - "4 urban-centre \n", - ".. ... \n", - "129 NaN \n", - "130 NaN \n", - "131 NaN \n", - "132 NaN \n", - "133 NaN \n", - "\n", - "[134 rows x 4 columns]" - ] - }, - "execution_count": 8, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "file_path = '/esarchive/scratch/avilanova/software/NES/Jupyter_notebooks/input/XVPCA_info.csv'\n", - "df = pd.read_csv(file_path)\n", - "df" - ] - }, - { - "cell_type": "code", - "execution_count": 9, - "metadata": {}, - "outputs": [], - "source": [ - "lat = df['lat']\n", - "lon = df['lon']\n", - "metadata = {'station_code': {'data': df['station.code'],\n", - " 'dimensions': ('station',),\n", - " 'dtype': str},\n", - " 'area_classification': {'data': df['standardised_network_provided_area_classification'],\n", - " 'dimensions': ('station',),\n", - " 'dtype': str}}" - ] - }, - { - "cell_type": "code", - "execution_count": 10, - "metadata": {}, - "outputs": [], - "source": [ - "points_grid = create_nes(comm=None, info=False, projection=None, parallel_method='X',\n", - " lat=lat, lon=lon)" - ] - }, - { - "cell_type": "code", - "execution_count": 11, - "metadata": {}, - "outputs": [], - "source": [ - "points_grid.variables = metadata" - ] - }, - { - "cell_type": "code", - "execution_count": 12, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Rank 000: Creating points_grid_1.nc\n", - "Rank 000: NetCDF ready to write\n", - "Rank 000: Dimensions done\n", - "Rank 000: Writing station_code var (1/2)\n", - "Rank 000: Var station_code created (1/2)\n", - "Rank 000: Var station_code data (1/2)\n", - "Rank 000: Var station_code completed (1/2)\n", - "Rank 000: Writing area_classification var (2/2)\n", - "Rank 000: Var area_classification created (2/2)\n", - "Rank 000: Var area_classification data (2/2)\n", - "Rank 000: Var area_classification completed (2/2)\n" - ] - }, - { - "name": "stderr", - "output_type": "stream", - "text": [ - "/esarchive/scratch/avilanova/software/NES/nes/nc_projections/points_nes.py:411: 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:411: UserWarning: WARNING!!! Different data types for variable area_classificationInput dtype=, data dtype=object\n", - " warnings.warn(msg)\n" - ] - } - ], - "source": [ - "points_grid.to_netcdf('points_grid_1.nc', info=True)" - ] - }, - { - "cell_type": "code", - "execution_count": 13, - "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, station: 134)\n",
-       "Coordinates:\n",
-       "  * time                 (time) datetime64[ns] 1996-12-31\n",
-       "  * station              (station) float64 0.0 1.0 2.0 3.0 ... 131.0 132.0 133.0\n",
-       "Data variables:\n",
-       "    station_code         (station) object 'ES0266A' 'ES0392A' ... 'ES9994A'\n",
-       "    area_classification  (station) object 'urban-centre' ... 'nan'\n",
-       "    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
" - ], - "text/plain": [ - "\n", - "Dimensions: (time: 1, station: 134)\n", - "Coordinates:\n", - " * time (time) datetime64[ns] 1996-12-31\n", - " * station (station) float64 0.0 1.0 2.0 3.0 ... 131.0 132.0 133.0\n", - "Data variables:\n", - " station_code (station) object ...\n", - " area_classification (station) object ...\n", - " lat (station) float64 ...\n", - " lon (station) float64 ...\n", - "Attributes:\n", - " Conventions: CF-1.7" - ] - }, - "execution_count": 13, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "xr.open_dataset('points_grid_1.nc')" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### File 2" - ] - }, - { - "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", - " \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", - " \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", - "
EstacióPM10 Barcelona (Eixample)PM10 Badalona (guàrdia urbana)PM10 Badalona (Assamblea de Catalunya)PM10 Barcelona (Pl. de la Universitat)PM10 Barcelona (Poblenou)PM10 Barcelona (Zona Universitària)PM10 Barcelona (el Port Vell)PM10 Barcelona (IES Goya)PM10 Barcelona (IES Verdaguer)...PM10 Constantí (Gaudí)PM10 Vila-seca (RENFE)PM10 Sitges (Vallcarca-oficines)PM10 Sant Vicenç dels Horts (Àlaba)PM10 Montsec (OAM)PM10 Montseny (la Castanya)PM10 Caldes de Montbui (Ajuntament)PM10 Sant Feliu de Llobregat (Eugeni d'Ors)PM 10 La Seu d'Urgell (CC Les Monges)PM10 Vic (Centre Cívic Santa Anna)
0Codi europeuES1438AES1928AES2027AES0559AES0691AES0567AES1870AES1852AES1900A...ES1123AES1117AES2033AES2011AES1982AES1778AES1680AES1362AES9994AES1874A
1DiaValor (µg/m3)Valor (µg/m3)Valor (µg/m3)Valor (µg/m3)Valor (µg/m3)Valor (µg/m3)Valor (µg/m3)Valor (µg/m3)Valor (µg/m3)...Valor (µg/m3)Valor (µg/m3)Valor (µg/m3)Valor (µg/m3)Valor (µg/m3)Valor (µg/m3)Valor (µg/m3)Valor (µg/m3)Valor (µg/m3)Valor (µg/m3)
22017-01-01 00:00:0019.6NaN2020.225.616.529NaN23.8...12.97NaN1122.499.5002997.936455NaNNaNNaNNaN
32017-01-02 00:00:0027.220.862331.63522.82817.232.4...NaN25.382625.391.8296189.7870043222.06NaNNaN
42017-01-03 00:00:0035.7NaN323736.230.931NaN35.8...21.836.494830.658.09460716.978294335.84NaNNaN
..................................................................
3622017-12-27 00:00:0017.57.591016.91413.121NaN20.8...1222.95NaNNaN13.066751NaN10.3NaNNaN
3632017-12-28 00:00:0017NaN1417.915NaN1314.516...NaN6.5NaN9.97613.351872NaN26.81NaNNaN
3642017-12-29 00:00:0024.6212423.225.815.321NaN25.9...8.869.56NaN23.7614.219732NaN14.09NaNNaN
3652017-12-30 00:00:0027.4NaN1522.316.611.21610.718.8...NaNNaNNaN19.041.0911874.713029NaNNaNNaNNaN
3662017-12-31 00:00:0017.312.51316.317.69.914NaN17.4...12.77NaNNaN15.232.156595.024302NaNNaNNaNNaN
\n", - "

367 rows × 84 columns

\n", - "
" - ], - "text/plain": [ - " Estació PM10 Barcelona (Eixample) \\\n", - "0 Codi europeu ES1438A \n", - "1 Dia Valor (µg/m3) \n", - "2 2017-01-01 00:00:00 19.6 \n", - "3 2017-01-02 00:00:00 27.2 \n", - "4 2017-01-03 00:00:00 35.7 \n", - ".. ... ... \n", - "362 2017-12-27 00:00:00 17.5 \n", - "363 2017-12-28 00:00:00 17 \n", - "364 2017-12-29 00:00:00 24.6 \n", - "365 2017-12-30 00:00:00 27.4 \n", - "366 2017-12-31 00:00:00 17.3 \n", - "\n", - " PM10 Badalona (guàrdia urbana) PM10 Badalona (Assamblea de Catalunya) \\\n", - "0 ES1928A ES2027A \n", - "1 Valor (µg/m3) Valor (µg/m3) \n", - "2 NaN 20 \n", - "3 20.86 23 \n", - "4 NaN 32 \n", - ".. ... ... \n", - "362 7.59 10 \n", - "363 NaN 14 \n", - "364 21 24 \n", - "365 NaN 15 \n", - "366 12.5 13 \n", - "\n", - " PM10 Barcelona (Pl. de la Universitat) PM10 Barcelona (Poblenou) \\\n", - "0 ES0559A ES0691A \n", - "1 Valor (µg/m3) Valor (µg/m3) \n", - "2 20.2 25.6 \n", - "3 31.6 35 \n", - "4 37 36.2 \n", - ".. ... ... \n", - "362 16.9 14 \n", - "363 17.9 15 \n", - "364 23.2 25.8 \n", - "365 22.3 16.6 \n", - "366 16.3 17.6 \n", - "\n", - " PM10 Barcelona (Zona Universitària) PM10 Barcelona (el Port Vell) \\\n", - "0 ES0567A ES1870A \n", - "1 Valor (µg/m3) Valor (µg/m3) \n", - "2 16.5 29 \n", - "3 22.8 28 \n", - "4 30.9 31 \n", - ".. ... ... \n", - "362 13.1 21 \n", - "363 NaN 13 \n", - "364 15.3 21 \n", - "365 11.2 16 \n", - "366 9.9 14 \n", - "\n", - " PM10 Barcelona (IES Goya) PM10 Barcelona (IES Verdaguer) ... \\\n", - "0 ES1852A ES1900A ... \n", - "1 Valor (µg/m3) Valor (µg/m3) ... \n", - "2 NaN 23.8 ... \n", - "3 17.2 32.4 ... \n", - "4 NaN 35.8 ... \n", - ".. ... ... ... \n", - "362 NaN 20.8 ... \n", - "363 14.5 16 ... \n", - "364 NaN 25.9 ... \n", - "365 10.7 18.8 ... \n", - "366 NaN 17.4 ... \n", - "\n", - " PM10 Constantí (Gaudí) PM10 Vila-seca (RENFE) \\\n", - "0 ES1123A ES1117A \n", - "1 Valor (µg/m3) Valor (µg/m3) \n", - "2 12.97 NaN \n", - "3 NaN 25.38 \n", - "4 21.8 36.49 \n", - ".. ... ... \n", - "362 12 22.95 \n", - "363 NaN 6.5 \n", - "364 8.86 9.56 \n", - "365 NaN NaN \n", - "366 12.77 NaN \n", - "\n", - " PM10 Sitges (Vallcarca-oficines) PM10 Sant Vicenç dels Horts (Àlaba) \\\n", - "0 ES2033A ES2011A \n", - "1 Valor (µg/m3) Valor (µg/m3) \n", - "2 11 22.49 \n", - "3 26 25.39 \n", - "4 48 30.65 \n", - ".. ... ... \n", - "362 NaN NaN \n", - "363 NaN 9.976 \n", - "364 NaN 23.76 \n", - "365 NaN 19.04 \n", - "366 NaN 15.23 \n", - "\n", - " PM10 Montsec (OAM) PM10 Montseny (la Castanya) \\\n", - "0 ES1982A ES1778A \n", - "1 Valor (µg/m3) Valor (µg/m3) \n", - "2 9.500299 7.936455 \n", - "3 1.829618 9.787004 \n", - "4 8.094607 16.97829 \n", - ".. ... ... \n", - "362 1 3.066751 \n", - "363 1 3.351872 \n", - "364 1 4.219732 \n", - "365 1.091187 4.713029 \n", - "366 2.15659 5.024302 \n", - "\n", - " PM10 Caldes de Montbui (Ajuntament) \\\n", - "0 ES1680A \n", - "1 Valor (µg/m3) \n", - "2 NaN \n", - "3 32 \n", - "4 43 \n", - ".. ... \n", - "362 NaN \n", - "363 NaN \n", - "364 NaN \n", - "365 NaN \n", - "366 NaN \n", - "\n", - " PM10 Sant Feliu de Llobregat (Eugeni d'Ors) \\\n", - "0 ES1362A \n", - "1 Valor (µg/m3) \n", - "2 NaN \n", - "3 22.06 \n", - "4 35.84 \n", - ".. ... \n", - "362 10.3 \n", - "363 26.81 \n", - "364 14.09 \n", - "365 NaN \n", - "366 NaN \n", - "\n", - " PM 10 La Seu d'Urgell (CC Les Monges) PM10 Vic (Centre Cívic Santa Anna) \n", - "0 ES9994A ES1874A \n", - "1 Valor (µg/m3) Valor (µg/m3) \n", - "2 NaN NaN \n", - "3 NaN NaN \n", - "4 NaN NaN \n", - ".. ... ... \n", - "362 NaN NaN \n", - "363 NaN NaN \n", - "364 NaN NaN \n", - "365 NaN NaN \n", - "366 NaN NaN \n", - "\n", - "[367 rows x 84 columns]" - ] - }, - "execution_count": 14, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "file_path = '/esarchive/scratch/avilanova/software/NES/Jupyter_notebooks/input/Dades_2017.xlsx'\n", - "df_2 = pd.read_excel(file_path)\n", - "df_2" - ] - }, - { - "cell_type": "code", - "execution_count": 15, - "metadata": {}, - "outputs": [], - "source": [ - "times = df_2['Estació'].iloc[2:]\n", - "lat = np.full(len(df_2.iloc[0].values[1:]), np.nan)\n", - "lon = np.full(len(df_2.iloc[0].values[1:]), np.nan)\n", - "metadata = {'station_name': {'data': df_2.columns.str.replace('PM10 ', '').str.replace('PM 10 ', '').to_numpy()[1:],\n", - " 'dimensions': ('station',),\n", - " 'dtype': str},\n", - " 'station_code': {'data': df_2.iloc[0].values[1:],\n", - " 'dimensions': ('station',),\n", - " 'dtype': str},\n", - " 'pm10': {'data': df_2.iloc[2:, 1:].to_numpy().T,\n", - " 'dimensions': ('station', 'time',),\n", - " 'dtype': float}}" - ] - }, - { - "cell_type": "code", - "execution_count": 16, - "metadata": {}, - "outputs": [], - "source": [ - "points_grid = create_nes(comm=None, info=False, projection=None, parallel_method='X',\n", - " lat=lat, lon=lon, times=times)" - ] - }, - { - "cell_type": "code", - "execution_count": 17, - "metadata": {}, - "outputs": [], - "source": [ - "points_grid.variables = metadata" - ] - }, - { - "cell_type": "code", - "execution_count": 18, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Rank 000: Creating points_grid_2.nc\n", - "Rank 000: NetCDF ready to write\n", - "Rank 000: Dimensions done\n", - "Rank 000: Writing station_name var (1/3)\n", - "Rank 000: Var station_name created (1/3)\n", - "Rank 000: Var station_name data (1/3)\n", - "Rank 000: Var station_name completed (1/3)\n", - "Rank 000: Writing station_code var (2/3)\n", - "Rank 000: Var station_code created (2/3)\n", - "Rank 000: Var station_code data (2/3)\n", - "Rank 000: Var station_code completed (2/3)\n", - "Rank 000: Writing pm10 var (3/3)\n", - "Rank 000: Var pm10 created (3/3)\n", - "Rank 000: Var pm10 data (3/3)\n", - "Rank 000: Var pm10 completed (3/3)\n" - ] - }, - { - "name": "stderr", - "output_type": "stream", - "text": [ - "/esarchive/scratch/avilanova/software/NES/nes/nc_projections/points_nes.py:411: 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:411: 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:411: UserWarning: WARNING!!! Different data types for variable pm10Input dtype=, data dtype=object\n", - " warnings.warn(msg)\n" - ] - } - ], - "source": [ - "points_grid.to_netcdf('points_grid_2.nc', info=True)" - ] - }, - { - "cell_type": "code", - "execution_count": 19, - "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: 365, station: 83)\n",
-       "Coordinates:\n",
-       "  * time          (time) datetime64[ns] 2017-01-01 2017-01-02 ... 2017-12-31\n",
-       "  * station       (station) float64 0.0 1.0 2.0 3.0 4.0 ... 79.0 80.0 81.0 82.0\n",
-       "Data variables:\n",
-       "    station_name  (station) object 'Barcelona (Eixample)' ... 'Vic (Centre Cí...\n",
-       "    station_code  (station) object 'ES1438A' 'ES1928A' ... 'ES9994A' 'ES1874A'\n",
-       "    pm10          (station, time) float64 19.6 27.2 35.7 30.9 ... nan nan nan\n",
-       "    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
" - ], - "text/plain": [ - "\n", - "Dimensions: (time: 365, station: 83)\n", - "Coordinates:\n", - " * time (time) datetime64[ns] 2017-01-01 2017-01-02 ... 2017-12-31\n", - " * station (station) float64 0.0 1.0 2.0 3.0 4.0 ... 79.0 80.0 81.0 82.0\n", - "Data variables:\n", - " station_name (station) object ...\n", - " station_code (station) object ...\n", - " pm10 (station, time) float64 ...\n", - " lat (station) float64 ...\n", - " lon (station) float64 ...\n", - "Attributes:\n", - " Conventions: CF-1.7" - ] - }, - "execution_count": 19, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "xr.open_dataset('points_grid_2.nc')" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## 4. Create LCC grid" - ] - }, - { - "cell_type": "code", - "execution_count": 20, - "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": 21, - "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": 22, - "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": 22, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "xr.open_dataset('lcc_grid.nc')" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## 5. Create Mercator grid" - ] - }, - { - "cell_type": "code", - "execution_count": 23, - "metadata": {}, - "outputs": [], - "source": [ - "lat_ts = -1.5\n", - "lon_0 = -18.0\n", - "nx = 210\n", - "ny = 236\n", - "inc_x = 50000\n", - "inc_y = 50000\n", - "x_0 = -126017.5\n", - "y_0 = -5407460.0\n", - "mercator_grid = create_nes(comm=None, info=False, projection='mercator',\n", - " lat_ts=lat_ts, lon_0=lon_0, nx=nx, ny=ny, \n", - " inc_x=inc_x, inc_y=inc_y, x_0=x_0, y_0=y_0)" - ] - }, - { - "cell_type": "code", - "execution_count": 24, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Rank 000: Creating mercator_grid.nc\n", - "Rank 000: NetCDF ready to write\n", - "Rank 000: Dimensions done\n" - ] - } - ], - "source": [ - "mercator_grid.to_netcdf('mercator_grid.nc', info=True)" - ] - }, - { - "cell_type": "code", - "execution_count": 25, - "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: 236, x: 210)\n",
-       "Coordinates:\n",
-       "  * time      (time) datetime64[ns] 1996-12-31\n",
-       "  * lev       (lev) float64 0.0\n",
-       "  * y         (y) float64 -5.382e+06 -5.332e+06 ... 6.318e+06 6.368e+06\n",
-       "  * x         (x) float64 -1.01e+05 -5.102e+04 -1.018e+03 ... 1.03e+07 1.035e+07\n",
-       "Data variables:\n",
-       "    lat       (y, x) float64 -43.52 -43.52 -43.52 -43.52 ... 49.6 49.6 49.6 49.6\n",
-       "    lon       (y, x) float64 -18.91 -18.46 -18.01 -17.56 ... 74.22 74.67 75.12\n",
-       "    mercator  |S1 b''\n",
-       "Attributes:\n",
-       "    Conventions:  CF-1.7
" - ], - "text/plain": [ - "\n", - "Dimensions: (time: 1, lev: 1, y: 236, x: 210)\n", - "Coordinates:\n", - " * time (time) datetime64[ns] 1996-12-31\n", - " * lev (lev) float64 0.0\n", - " * y (y) float64 -5.382e+06 -5.332e+06 ... 6.318e+06 6.368e+06\n", - " * x (x) float64 -1.01e+05 -5.102e+04 -1.018e+03 ... 1.03e+07 1.035e+07\n", - "Data variables:\n", - " lat (y, x) float64 ...\n", - " lon (y, x) float64 ...\n", - " mercator |S1 ...\n", - "Attributes:\n", - " Conventions: CF-1.7" - ] - }, - "execution_count": 25, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "xr.open_dataset('mercator_grid.nc')" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] - } - ], - "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/4-providentia.ipynb b/Jupyter_notebooks/4-providentia.ipynb deleted file mode 100644 index 5e0303360a2221c26721ce15c7d648399a6d5e71..0000000000000000000000000000000000000000 --- a/Jupyter_notebooks/4-providentia.ipynb +++ /dev/null @@ -1,9953 +0,0 @@ -{ - "cells": [ - { - "cell_type": "code", - "execution_count": 1, - "metadata": {}, - "outputs": [], - "source": [ - "import xarray as xr\n", - "from netCDF4 import Dataset\n", - "from nes import *" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Observations dataset" - ] - }, - { - "cell_type": "code", - "execution_count": 20, - "metadata": {}, - "outputs": [], - "source": [ - "obs_path = '/gpfs/projects/bsc32/AC_cache/obs/ghost/EBAS/1.3.3/hourly/sconco3/sconco3_201804.nc'" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Read" - ] - }, - { - "cell_type": "code", - "execution_count": 21, - "metadata": {}, - "outputs": [ - { - "data": { - "text/html": [ - "
\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "
<xarray.Dataset>\n",
-       "Dimensions:                                                           (station: 168, time: 720, N_flag_codes: 186, N_qa_codes: 77)\n",
-       "Coordinates:\n",
-       "  * time                                                              (time) datetime64[ns] ...\n",
-       "Dimensions without coordinates: station, N_flag_codes, N_qa_codes\n",
-       "Data variables: (12/179)\n",
-       "    ASTER_v3_altitude                                                 (station) float32 ...\n",
-       "    EDGAR_v4.3.2_annual_average_BC_emissions                          (station) float32 ...\n",
-       "    EDGAR_v4.3.2_annual_average_CO_emissions                          (station) float32 ...\n",
-       "    EDGAR_v4.3.2_annual_average_NH3_emissions                         (station) float32 ...\n",
-       "    EDGAR_v4.3.2_annual_average_NMVOC_emissions                       (station) float32 ...\n",
-       "    EDGAR_v4.3.2_annual_average_NOx_emissions                         (station) float32 ...\n",
-       "    ...                                                                ...\n",
-       "    station_timezone                                                  (station) object ...\n",
-       "    street_type                                                       (station) object ...\n",
-       "    street_width                                                      (station) float32 ...\n",
-       "    terrain                                                           (station) object ...\n",
-       "    vertical_datum                                                    (station) object ...\n",
-       "    weekday_weekend_code                                              (station, time) uint8 ...\n",
-       "Attributes:\n",
-       "    title:                     Surface ozone data in the EBAS network in 2018...\n",
-       "    institution:               Barcelona Supercomputing Center\n",
-       "    source:                    Surface observations\n",
-       "    creator_name:              Dene R. Bowdalo\n",
-       "    creator_email:             dene.bowdalo@bsc.es\n",
-       "    conventions:               CF-1.7\n",
-       "    data_version:              1.3.3\n",
-       "    history:                   Tue Mar 30 12:38:43 2021: ncks -O --fix_rec_dm...\n",
-       "    NCO:                       4.7.2\n",
-       "    nco_openmp_thread_number:  1