diff --git a/.gitignore b/.gitignore index 695ff4b5c26c32a7ac8474a3eb79b412bf4de2d2..e5d46f5e2567228ab637f935c9d2dcdc3087f550 100644 --- a/.gitignore +++ b/.gitignore @@ -5,4 +5,5 @@ tests/test_bash_nord3v2-alba.cmd notebooks/.ipynb_checkpoints .ipynb_checkpoints nes/__pycache__ -nes/nc_projections/__pycache__ \ No newline at end of file +nes/nc_projections/__pycache__ +jupyter_notebooks \ No newline at end of file diff --git a/Jupyter_notebooks/Jupyter_bash_nord3v2.cmd b/Jupyter_notebooks/Jupyter_bash_nord3v2.cmd index 7b2fd04640aa2992d698f7e91096c94c676a4c83..e85ee59f905fc06300c118818690a3890e184b21 100644 --- a/Jupyter_notebooks/Jupyter_bash_nord3v2.cmd +++ b/Jupyter_notebooks/Jupyter_bash_nord3v2.cmd @@ -29,7 +29,8 @@ 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.19.0-foss-2019b-Python-3.7.4 -export PYTHONPATH=/gpfs/scratch/bsc32/bsc32538/NES_tests/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/NES_create_netcdf_test.ipynb b/Jupyter_notebooks/NES_create_netcdf_test.ipynb new file mode 100644 index 0000000000000000000000000000000000000000..188e4b21e641494213a19e4e2d9f98428b32d8b4 --- /dev/null +++ b/Jupyter_notebooks/NES_create_netcdf_test.ipynb @@ -0,0 +1,924 @@ +{ + "cells": [ + { + "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": [ + "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', create_nes=True,\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": [ + "
<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
array(['1996-12-31T00:00:00.000000000'], dtype='datetime64[ns]')
array([0.])
array([41.15, 41.25, 41.35, 41.45, 41.55, 41.65, 41.75, 41.85, 41.95, 42.05])
array([1.85, 1.95, 2.05, 2.15, 2.25, 2.35, 2.45, 2.55, 2.65, 2.75])
array(b'', dtype='|S1')
<xarray.Dataset>\n", + "Dimensions: (time: 1, lev: 1, rlat: 10, rlon: 10)\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 ... -25.6 -25.4 -25.2\n", + " * rlon (rlon) float64 -35.0 -34.8 -34.6 -34.4 ... -33.6 -33.4 -33.2\n", + "Data variables:\n", + " lat (rlat, rlon) float64 -27.0 -26.8 -26.6 ... -25.6 -25.4 -25.2\n", + " lon (rlat, rlon) float64 -35.0 -34.8 -34.6 ... -33.6 -33.4 -33.2\n", + " rotated_pole |S1 b''\n", + "Attributes:\n", + " Conventions: CF-1.7
array(['1996-12-31T00:00:00.000000000'], dtype='datetime64[ns]')
array([0.])
array([-27. , -26.8, -26.6, -26.4, -26.2, -26. , -25.8, -25.6, -25.4, -25.2])
array([-35. , -34.8, -34.6, -34.4, -34.2, -34. , -33.8, -33.6, -33.4, -33.2])
array([[-27. , -26.8, -26.6, -26.4, -26.2, -26. , -25.8, -25.6, -25.4, -25.2],\n", + " [-27. , -26.8, -26.6, -26.4, -26.2, -26. , -25.8, -25.6, -25.4, -25.2],\n", + " [-27. , -26.8, -26.6, -26.4, -26.2, -26. , -25.8, -25.6, -25.4, -25.2],\n", + " [-27. , -26.8, -26.6, -26.4, -26.2, -26. , -25.8, -25.6, -25.4, -25.2],\n", + " [-27. , -26.8, -26.6, -26.4, -26.2, -26. , -25.8, -25.6, -25.4, -25.2],\n", + " [-27. , -26.8, -26.6, -26.4, -26.2, -26. , -25.8, -25.6, -25.4, -25.2],\n", + " [-27. , -26.8, -26.6, -26.4, -26.2, -26. , -25.8, -25.6, -25.4, -25.2],\n", + " [-27. , -26.8, -26.6, -26.4, -26.2, -26. , -25.8, -25.6, -25.4, -25.2],\n", + " [-27. , -26.8, -26.6, -26.4, -26.2, -26. , -25.8, -25.6, -25.4, -25.2],\n", + " [-27. , -26.8, -26.6, -26.4, -26.2, -26. , -25.8, -25.6, -25.4, -25.2]])
array([[-35. , -34.8, -34.6, -34.4, -34.2, -34. , -33.8, -33.6, -33.4, -33.2],\n", + " [-35. , -34.8, -34.6, -34.4, -34.2, -34. , -33.8, -33.6, -33.4, -33.2],\n", + " [-35. , -34.8, -34.6, -34.4, -34.2, -34. , -33.8, -33.6, -33.4, -33.2],\n", + " [-35. , -34.8, -34.6, -34.4, -34.2, -34. , -33.8, -33.6, -33.4, -33.2],\n", + " [-35. , -34.8, -34.6, -34.4, -34.2, -34. , -33.8, -33.6, -33.4, -33.2],\n", + " [-35. , -34.8, -34.6, -34.4, -34.2, -34. , -33.8, -33.6, -33.4, -33.2],\n", + " [-35. , -34.8, -34.6, -34.4, -34.2, -34. , -33.8, -33.6, -33.4, -33.2],\n", + " [-35. , -34.8, -34.6, -34.4, -34.2, -34. , -33.8, -33.6, -33.4, -33.2],\n", + " [-35. , -34.8, -34.6, -34.4, -34.2, -34. , -33.8, -33.6, -33.4, -33.2],\n", + " [-35. , -34.8, -34.6, -34.4, -34.2, -34. , -33.8, -33.6, -33.4, -33.2]])
array(b'', dtype='|S1')
array(['2021-08-03T00:00:00.000000000'], dtype='datetime64[ns]')
array([ 0., 1., 2., 3., 4., 5., 6., 7., 8., 9., 10., 11., 12., 13.,\n", - " 14., 15., 16., 17., 18., 19., 20., 21., 22., 23.])
array([[16.350338, 16.43293 , 16.515146, ..., 16.515146, 16.43293 , 16.350338],\n", + " comment: Generated on marenostrum4
array(['2021-08-03T00:00:00.000000000'], dtype='datetime64[ns]')
array([ 0., 1., 2., 3., 4., 5., 6., 7., 8., 9., 10., 11., 12., 13.,\n", + " 14., 15., 16., 17., 18., 19., 20., 21., 22., 23.])
array([[16.350338, 16.43293 , 16.515146, ..., 16.515146, 16.43293 , 16.350338],\n", " [16.527426, 16.610239, 16.692677, ..., 16.692677, 16.610243, 16.527426],\n", " [16.704472, 16.787508, 16.870167, ..., 16.870167, 16.78751 , 16.704472],\n", " ...,\n", " [58.32095 , 58.472683, 58.62431 , ..., 58.62431 , 58.472683, 58.32095 ],\n", " [58.426285, 58.578201, 58.730026, ..., 58.730026, 58.578201, 58.426285],\n", - " [58.530792, 58.682899, 58.834919, ..., 58.834919, 58.682903, 58.530792]])
array([[-22.181265, -22.016672, -21.851799, ..., 41.851795, 42.016666,\n", + " [58.530792, 58.682899, 58.834919, ..., 58.834919, 58.682903, 58.530792]])
array([[-22.181265, -22.016672, -21.851799, ..., 41.851795, 42.016666,\n", " 42.181259],\n", " [-22.278179, -22.113186, -21.947905, ..., 41.947899, 42.113174,\n", " 42.278172],\n", @@ -655,10 +647,10 @@ " [-67.901878, -67.722473, -67.541939, ..., 87.541939, 87.722458,\n", " 87.901871],\n", " [-68.228035, -68.04982 , -67.870514, ..., 87.870506, 88.04982 ,\n", - " 88.228035]])
array([-27. , -26.799999, -26.6 , ..., 26.6 , 26.800001,\n", - " 27. ])
array([-35. , -34.799999, -34.599998, ..., 34.600002, 34.799999,\n", - " 35. ])
array([['2020-02-20T00:00:00.000000000', '2020-02-15T00:00:00.000000000']],\n", - " dtype='datetime64[ns]')
[2282904 values with dtype=float32]
array(b'', dtype='|S1')
array([-27. , -26.799999, -26.6 , ..., 26.6 , 26.800001,\n", + " 27. ])
array([-35. , -34.799999, -34.599998, ..., 34.600002, 34.799999,\n", + " 35. ])
array([['2020-02-20T00:00:00.000000000', '2020-02-15T00:00:00.000000000']],\n", + " dtype='datetime64[ns]')
[2282904 values with dtype=float32]
array(b'', dtype='|S1')