This is a parser for netcdf-files storing climate data for Europe and Germany. It currently supports reading files from 5 datasets (4 are actually netCDF):
- Regional Climate Projections from CORDEX climate models regarding the variable 'tas' (average daily temperature) for Europe
- a Heatwaves and Cold Spells dataset for Europe (climate projections)
- a Temperature Statistics dataset for Europe (climate projections)
- HOSTRADA, historical data (until present, still updated) for Germany
- TRY for Germany with a present and future representative year
The scripts named read_...
reads from netCDF or other data files, which you have to download from climate data stores. See the section on prerequisites below for datasets from Copernicus Climate Data Store. NOTE, that they write to outfiles and usually append to them! This is useful for collecting data from monthly datafiles into one outfile containing the data for a whole year.
Scripts names plot_...
work with data which have to be prepared beforehand by running the respective read...
-script. NOTE, that plots are evenly spaced on the x-axis rather than reading the x-values.
Some scripts have further instructions as a header comment within the script.
The script 'read_heatwaves_or_temperature_stats.py' works with netCDF files from 2 datasets, see header comment in script. This README is written for the script 'read_cordex_tas.py'.
If you are starting to work with .nc-files this is a good starting point for you. If you just want a small piece of code to read from .nc-files, you will find it here, too.
Climate Projection Data is a large field. If you are an end user, like me, you might want to keep searching for already processed datasets. Someone has already done the analysis you need. For example: From climate projection data one can analyse heat days and heat waves, because they contain a maximum daily temperature. Someone has already done this analysis, there is a heatwave dataset. See for example this gist.
The "Deutscher Wetterdienst" has some good advice about using climate projection data on their page (in german). The first 3 points are:
- Look for the information that suits your tasks and needs
- Don't use only ONE dataset
- Climate Projection computations are not forecasts
- ...
- you need an .nc-file, from the CORDEX. You can download one at Copernicus' Climate Data Store
- create a free account. Logged in, make selections in the form below (link)
- monthly data is recommended for testing, since it is smaller than daily data
- choose variable "2m air temperature" (called 'tas' in the dataset to download)
- Submit the form, download the file and unzip it
- https://cds.climate.copernicus.eu/cdsapp#!/dataset/projections-cordex-domains-single-levels?tab=form
- create a free account. Logged in, make selections in the form below (link)
pip install -r requirements.txt
- change this script, lines to change are marked with "<---"
- change filename to your downloaded .nc-file
- change the path or place it in the same location as this script
- change the location to the one you are interested in (lat, lon coordinates)
python read_cordex_tas.py
It contains some information about the structure of the data in the .nc file. You can reproduce the outputs (or get different ones) with the steps below, alternatively check out 'explore_netCDF_dataset.py'.
Since CORDEX-data have a standardized structure, you might get the same responses from your .nc-file.
It depends on the query.
-
Pip install netCDF as mentioned in the script.
-
Start the python interpreter from your terminal
python
- Import netCDF4 and your file. Replace 'path_to_file_and_name.nc' with your filename and location
>>> import netCDF4
>>> dataset = netCDF4.Dataset('path_to_file_and_name.nc')
- Then, try the commands from 'variables_values.md'
>>> dataset.dimensions.keys()
>>> dataset.variables.keys()
>>> dataset.variables['tas'] # if 'tas' was part of the variables.keys() above
We appreciate your contributions! In fact, we decided to open-source this simple script mainly to connect with others working on similar topics. Leave us a note in Discussions!
Just open a PR or an Issue. Make sure to give some context, WHY this change is useful and HOW your need for the change came to be. Thank you!!