r3leaf-earth / read-netcdf

Script to read variables from a netCDF which belongs to climate models CORDEX
MIT License
2 stars 0 forks source link
climate-data climate-projection cordex netcdf python

read-netcdf

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'.

For whom?

If you are starting to work with .nc-files this is a good starting point for you.

Am I Working with the Right Data?

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:

  1. Look for the information that suits your tasks and needs
  2. Don't use only ONE dataset
  3. Climate Projection computations are not forecasts
  4. ...

How to Run the Script

Prerequisites:

Usage:

What's up with that File 'variables_values_info.md'?

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.

Take a look into the Datastructure via the Python-shell

  1. Pip install netCDF as mentioned in the script.

  2. Start the python interpreter from your terminal

    python
  3. 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')
  4. 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

Contributing

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!

How to Contribute to the Code

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!!