Skip to content

Commit

Permalink
Adding jupyter notebook that mirrors run_all.py
Browse files Browse the repository at this point in the history
  • Loading branch information
Jan Wohland committed Nov 28, 2022
1 parent 6893836 commit 546f34a
Showing 1 changed file with 232 additions and 0 deletions.
232 changes: 232 additions & 0 deletions code/run_all.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,232 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"This notebook executes all data processing and plotting functions that are part of the publication.\n",
"It is structured in two blocks, the first one does the data processing, the second step does the plotting. \n",
"Running the first block on your machine might proove difficult if you do not have access to the DKRZ computing infrastructure. \n",
"Therefore, the first block can be bypassed by retrieving the intermediate outputs from zenodo (link) and only running the plotting scripts. "
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Start a dask client.\n",
"from dask.distributed import Client\n",
"client = Client(silence_logs=50)\n",
"client"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# prevent Figures from showing up here and cluttering this notebook\n",
"%matplotlib agg"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import compute_country_aggregates\n",
"import compute_signals\n",
"import plot_lu_maps\n",
"import plot_s10_maps\n",
"import plot_s10_scatter\n",
"import plot_s10_country_heatmaps\n",
"import plot_temperature_gradient\n",
"import compute_plot_pattern_correlation"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### **Calculations**"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Compute changes in 10m wind speeds\n",
"compute_signals.calculate_signals(time_aggregation=\"annual\", variable_id=\"sfcWind\")\n",
"compute_signals.calculate_signals(time_aggregation=\"monthly\", variable_id=\"sfcWind\")\n",
"compute_signals.calculate_signals(\"annual\", \"sfcWind\", full_ensemble=True)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# compute changes in near-surface air temperature (tas), skin temperature (ts) and sea ice cover (sic)\n",
"for variable in [\"tas\", \"ts\", \"sic\"]:\n",
" print(variable)\n",
" compute_signals.calculate_signals(time_aggregation=\"monthly\", variable_id=variable)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# compute tas changes for full ensemble\n",
"compute_signals.calculate_signals(\"annual\", \"tas\", full_ensemble=True)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# compute changes in tas - ts, a proxy for stability change\n",
"compute_signals.compute_monthly_stability_change()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Compute country aggregates\n",
"compute_country_aggregates.compute_all(True) # onshore\n",
"compute_country_aggregates.compute_all(False) # offshore"
]
},
{
"cell_type": "markdown",
"metadata": {
"tags": []
},
"source": [
"### **Plots**"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Maps of 10m wind speeds\n",
"plot_s10_maps.make_s10_maps()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"plot_s10_maps.make_aggregate_monthly_plots(\"tas-ts\", \"mean\", [\"historical\", \"rcp45\", \"rcp85\"])"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Scatter plots of wind change per country\n",
"plot_s10_scatter.make_s10_scatter(onshore=False)\n",
"plot_s10_scatter.make_s10_scatter(onshore=True)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Heatmaps of wind per country\n",
"plot_s10_country_heatmaps.make_s10_heatmaps(onshore=False)\n",
"plot_s10_country_heatmaps.make_s10_heatmaps(onshore=True)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Maps of land use change forcing data\n",
"plot_lu_maps.make_LUH_maps()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Scatter plot of land use forcing vs wind speed change\n",
"compute_plot_pattern_correlation.make_plot()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Temperature gradient plots\n",
"plot_temperature_gradient.make_all_plots()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Shutting down the dask client again\n",
"client.close()"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "cmip-processing",
"language": "python",
"name": "cmip-processing"
},
"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.9.9"
}
},
"nbformat": 4,
"nbformat_minor": 4
}

0 comments on commit 546f34a

Please sign in to comment.