Downloading MERRA2 data

I tried to download some MERRA2 data, and realised that I’d deleted all my old scripts! So, here I go again…

Preliminary steps:

  1. Register / Log in to the NASA EARTHDATA site:
  2. Follow the steps to link GES DISC with your account:
  3. Verify by downloading this example data file URL

Go to the NASA Goddard Earth Sciences (GES) Data and Information Services Center (DISC) page:

  • Source: Models/Analyses MERRA-2
  • Temporal Resolution: 1 hour

Choose “Subset / Get data” for the instantaneous ‘Single-Level Diagnostics’ file.

Under “Download Method” there are two relevant options, as we want to download a spatial domain:

  • Subset using OPeNDAP
  • Subset using GES DISC. This option seems to also allow regridding.

I selected OPeNDAP, as I don’t need to regrid the data.

I didn’t change the dates under ‘Refine Date Range’: 1980-01-01 to 2021-08-31

I used ‘Refine Region’ to select a region around Ireland: -11,51,-5,56 and I kept the ‘Use ‘Refine Region’ box checked.

Under ‘Variables’ I selected surface wind speed, and I kept output format as netCDF.

Click ‘Get Data’ and download the links list

Follow the steps to set up wget or curl here:

I downloaded the data to the mccdata server using curl.


Using conda install on a server

conda is great, it makes installing lots of packages easy. However, if you have an account on a server which already has conda installed, you should use conda to only install packages for your own user, not system-wide. To do this, you should make use of conda environments.

For example, let’s say you want to use cdo on your server. First, create a conda environment, I’ve called it cdo-env:

conda create -y -n cdo-env

Now activate your environment, so you can work within it:

conda activate cdo-env

When you’re in the environment, the shell prompt may include the name of the environment, as a handy reminder:

(cdo-env) [sweeneyc@login ~]$

Now you can install cdo within your cdo-env environment:

conda install -c conda-forge cdo

If all goes well, this should install cdo within your cdo-env enviroment, and you can use it whenever you like!

To close/exit your conda environment, use the command:

conda deactivate

That’s it!


Downloading ERA5 data

Install Climate Data Store API on linux:

I’ve installed mine on the mccdata server in UCD.

The great thing about using a script, instead of downloading directly from the CDS, is that it gives you more control. The ERA5 CDS page for ERA5 monthly averaged data on single levels from 1979 to present doesn’t let you change the grid or domain. I wanted data at a lower resolution, and only for 20-90N. I was able to specify this in my retrieval script:

import cdsapi

c = cdsapi.Client()

        'area':[90, -180, 20, 180], # North, West, South, East. Default: global
        'grid':[1.0, 1.0], # Latitude/longitude grid: east-west (longitude) and north-south resolution (latitude). Default: 0.25 x 0.25

Then I ran this from the command line:

python ERA5.mslp.CDS

And this quickly retrieved the required data!


Easy way to install cdo!

There is a wonderfully easy way to install cdo, which takes care of all the libraries for you, and you can do it within your user directory, so don’t need special privileges: use conda!

conda config --add channels conda-forge
conda update --all
conda install cdo

This cdo seems to work happily with GRIB and NetCDF data, and also installs lots of other useful tools, in particular


To convert IFS from GRIB to NetCDF, I think the best command to use may be:

grib_to_netcdf -T /pithos/shared/ESIPP/ECMWF/IFS/IFS_IT00_20180101_20180107.grib -o IFS.cdf

The “-T” option is good here, as it converts the data using the dimensions:

longitude = 80 ;
latitude = 58 ;
step = 49 ;
date = 7 ;

where date is when the forecast started (initialisation time, IT), and step is the forecast time (0 to 48).