This is a parser for netcdf-files that store climate projection data (long term forecasts) for Europe. It currently supports .nc-files from CORDEX climate models regarding the variable 'tas' (average daily temperature) and .nc-files from a "Heatwaves" dataset and a "Temperature Statistics dataset"
The script 'read_tas.py' reads from a netCDF file which belongs to climate models CORDEX. The variable read is the daily mean temperature 2m above the ground level, short 'tas'.
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_tas.py'.
If you are starting to work with .nc-files this is a good starting point for you.
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_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!!