Skip to content

Instantly share code, notes, and snippets.

@dewomser
Created January 11, 2024 07:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dewomser/e7f179868b70078de52917b04cf51012 to your computer and use it in GitHub Desktop.
Save dewomser/e7f179868b70078de52917b04cf51012 to your computer and use it in GitHub Desktop.
Erzeugt einen Klimastreifen für Worms. Ein Pythonscript für die toolbox bei https://cds.climate.copernicus.eu
import cdstoolbox as ct
# Application plotting climate stripes of temperature anomaly.
@ct.application(title='Climate Stripes')
@ct.output.livefigure()
def plot_time_series():
# Retrieve surface temperature data between 1979 and 2022
data = ct.catalogue.retrieve(
'reanalysis-era5-single-levels',
{
'variable': '2m_temperature',
'grid': ['3', '3'],
'product_type': 'reanalysis',
'year': list(range(1979, 2023)),
'month': list(range(1, 13)),
'day': list(range(1, 32)),
'time': ['00:00'],
}
)
# Extract temperature data at point
data = ct.geo.extract_point(data, **{'lat': 49.6, 'lon': 8.4})
# Compute yearly average temperature at the defined location
data = ct.cube.resample(data, freq='year', how='mean')
# Calculate anomaly with respect to the 1981 - 2010 period
anomaly = ct.climate.anomaly(data, interval=['1979', '2022']) + 0.63
# Plot climate stripes of the anomaly
fig = ct.chart.warming_stripes(
anomaly,
height=200,
)
return fig
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment