Created
January 11, 2024 07:40
-
-
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
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
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