generated from interTwin-eu/repository-template
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update workflow scripts and floodmap plotting; add notebook dt climat…
…e download
- Loading branch information
1 parent
12b31a8
commit 3bede11
Showing
7 changed files
with
11,137 additions
and
9,796 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,235 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"from polytope.api import Client\n", | ||
"import earthkit.data\n", | ||
"from earthkit.regrid import interpolate\n", | ||
"\n", | ||
"EMAIL = \"[email protected]\"\n", | ||
"KEY = \"f78021d45305407b702b541e3f22da99\"" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"request = {\n", | ||
" 'activity': 'ScenarioMIP',\n", | ||
" 'class': 'd1',\n", | ||
" 'dataset': 'climate-dt',\n", | ||
" 'date': '20241102/to/20241104',\n", | ||
" 'experiment': 'SSP3-7.0',\n", | ||
" 'expver': '0001',\n", | ||
" 'generation': '1',\n", | ||
" 'levtype': 'sfc',\n", | ||
" 'model': 'IFS-NEMO',\n", | ||
" 'param': '134/165/166',\n", | ||
" 'realization': '1',\n", | ||
" 'resolution': 'standard',\n", | ||
" 'stream': 'clte',\n", | ||
" 'time': '0000/0100/0200/0300/0400/0500/0600/0700/0800/0900/1000/1100/1200/1300/1400/1500/1600/1700/1800/1900/2000/2100/2200/2300', # '0100/0200/0300/0400/0500/0600'\n", | ||
" 'type': 'fc',\n", | ||
"}" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"c = Client(address='polytope.lumi.apps.dte.destination-earth.eu', user_email=EMAIL, user_key=KEY)\n", | ||
"c.revoke('all')\n", | ||
"c.retrieve('destination-earth', request, f'test_dt_climate_fetch_large.grib')" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"data = earthkit.data.from_source('file', \"test_dt_climate_fetch.grib\")" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"data.ls()" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"data_latlon = earthkit.regrid.interpolate(data, out_grid={\"grid\": [.1,.1]}, method='linear')\n", | ||
"ds = data_latlon.to_xarray()" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"## Read, interpolate and to netcdf" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"import hydromt" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"bounds = [-15.0, 43.0, 13.0, 63.0]" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"data = earthkit.data.from_source('file', \"dt-climate-winter-3839.grib\").sel(dataDate=slice(20390207,20390220))" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"data.ls()" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"data = interpolate(data, out_grid={\"grid\": [.1,.1]}, method=\"linear\")\n", | ||
"ds = data.to_xarray(xarray_open_dataset_kwargs={\"chunks\": {\"time\": 1}}).squeeze()" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"ds = ds.assign_coords(\n", | ||
" {\"longitude\": ((ds.longitude+180)%360)-180}\n", | ||
")\n", | ||
"\n", | ||
"ds = ds.sortby(\"longitude\")\n", | ||
"ds = ds.sortby(\"latitude\")\n", | ||
"\n", | ||
"ds = ds.rename(\n", | ||
" {\n", | ||
" \"longitude\": \"x\",\n", | ||
" \"latitude\": \"y\",\n", | ||
" \"sp\": \"press_msl\",\n", | ||
" \"u10\": \"wind10_u\",\n", | ||
" \"v10\": \"wind10_v\"\n", | ||
" }\n", | ||
")" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"ds.raster.set_crs(4326)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"ds = ds.sel(\n", | ||
" x = slice(bounds[0], bounds[2]),\n", | ||
" y = slice(bounds[1], bounds[3])\n", | ||
")" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"ds.to_netcdf(\"dt-climate_event_feb2039.nc\")" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"import xarray as xr" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"ds_new = xr.open_dataset(\"dt-climate_event_feb2039.nc\")" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "de372", | ||
"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.11.10" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 2 | ||
} |
Oops, something went wrong.