Commit 217e2a3d authored by Marco Kulüke's avatar Marco Kulüke
Browse files

start climate station notebook

parent bab16516
This diff is collapsed.
......@@ -198,7 +198,120 @@
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
"source": [
"import intake\n",
"import xarray as xr\n",
"#from import Basemap, cm\n",
"import matplotlib.pyplot as plt\n",
"from netCDF4 import Dataset as open_ncfile\n",
"import numpy as np"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Path to catalog descriptor on the DKRZ server\n",
"col_url = \"/work/ik1017/Catalogs/mistral-cmip6.json\"\n",
"\n",
"# Open the catalog with the intake package and name it \"col\" as short for \"collection\"\n",
"col = intake.open_esm_datastore(col_url)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Store the name of the model we chose in a variable named \"climate_model\"\n",
"\n",
"climate_model = \"MPI-ESM1-2-HR\" # here we choose Max-Plack Institute's Earth Sytem Model in high resolution\n",
"\n",
"# This is how we tell intake what data we want\n",
"\n",
"query = dict(\n",
" source_id = \"MPI-ESM1-2-HR\", # the model \n",
" variable_id = \"tasmax\", # temperature at surface, maximum\n",
" table_id = \"day\", # daily maximum\n",
" experiment_id = \"historical\", # what we selected in the drop down menu,e.g. SSP2.4-5 2015-2100\n",
" member_id = \"r10i1p1f1\", # \"r\" realization, \"i\" initialization, \"p\" physics, \"f\" forcing\n",
" time_range =\"20100101-20141231\",\n",
")\n",
"\n",
"# Intake looks for the query we just defined in the catalog of the CMIP6 data pool at DKRZ\n",
"cat = col.search(**query)\n",
"\n",
"# Show query results\n",
"cat.df"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"ds = xr.open_dataset(cat.df['path'][0])\n",
"ds"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"var = ds.variables['tasmax'][0,:,:]\n",
"lat = ds.variables['lat'][:]\n",
"lon = ds.variables['lon'][:]\n",
"\n",
"#-- create figure and axes instadses\n",
"dpi = 100\n",
"fig = plt.figure(figsize=(1100/dpi, 1100/dpi), dpi=dpi)\n",
"ax = fig.add_axes([0.1,0.1,0.8,0.9])\n",
"\n",
"#-- create map\n",
"map = Basemap(projection='cyl',llcrnrlat= -90.,urcrnrlat= 90.,\\\n",
" resolution='c', llcrnrlon=-180.,urcrnrlon=180.)\n",
"\n",
"#-- draw coastlines, state and country boundaries, edge of map\n",
"map.drawcoastlines()\n",
"map.drawstates()\n",
"map.drawcountries()\n",
"\n",
"#-- create and draw meridians and parallels grid lines\n",
"map.drawparallels(np.arange( -90., 90.,30.),labels=[1,0,0,0],fontsize=10)\n",
"map.drawmeridians(np.arange(-180.,180.,30.),labels=[0,0,0,1],fontsize=10)\n",
"\n",
"#-- convert latitude/longitude values to plot x/y values\n",
"x, y = map(*np.meshgrid(lon,lat))\n",
"\n",
"#-- contour levels\n",
"clevs = np.arange(210,320,5)\n",
"\n",
"#-- draw filled contours\n",
"cnplot = map.contourf(x,y,var,clevs,cmap=plt.cm.jet)\n",
"\n",
"#-- add colorbar\n",
"cbar = map.colorbar(cnplot,location='bottom',pad=\"10%\") #-- pad: distadse between map and colorbar\n",
"cbar.set_label('deg K') #-- add colorbar title string\n",
"\n",
"#-- add plot title\n",
"plt.title('Temperature')\n",
"\n",
"#-- displa on screen\n",
"#plt.show()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# <font color='darkred'>Now use Jacobi Operator in parallel</font>"
]
},
{
"cell_type": "markdown",
......@@ -206,20 +319,27 @@
"source": [
"# <font color='darkgreen'>Take home message</font>\n",
"\n",
"Prallelism brings extra complexiity and often it is not necessary for your problems. Before using Dask you may want try alternatives:\n",
"Parallelism brings extra complexiity and often it is not necessary for your problems. Before using Dask you may want try alternatives:\n",
"- use better algorithms or data structures\n",
"- better file formats\n",
"- compiled code\n",
"- sampling\n",
"- profile your code"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "test_env",
"display_name": "Python 3 unstable (using the module python3/unstable)",
"language": "python",
"name": "test_env"
"name": "python3_unstable"
},
"language_info": {
"codemirror_mode": {
......@@ -231,7 +351,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.5"
"version": "3.7.8"
}
},
"nbformat": 4,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment