Categories
Reanalysis

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: https://urs.earthdata.nasa.gov/home
  2. Follow the steps to link GES DISC with your account: https://disc.gsfc.nasa.gov/earthdata-login
  3. Verify by downloading this example data file URL

Go to the NASA Goddard Earth Sciences (GES) Data and Information Services Center (DISC) page: https://disc.gsfc.nasa.gov/

  • 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: https://disc.gsfc.nasa.gov/data-access#mac_linux_wget

I downloaded the data to the mccdata server using curl.

Categories
Uncategorized

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!

Categories
Uncategorized

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()

c.retrieve(
    'reanalysis-era5-single-levels-monthly-means',
    {
        'product_type':'monthly_averaged_reanalysis',
        'variable':'mean_sea_level_pressure',
        'year':[
            '1979','1980','1981',
            '1982','1983','1984',
            '1985','1986','1987',
            '1988','1989','1990',
            '1991','1992','1993',
            '1994','1995','1996',
            '1997','1998','1999',
            '2000','2001','2002',
            '2003','2004','2005',
            '2006','2007','2008',
            '2009','2010','2011',
            '2012','2013','2014',
            '2015','2016','2017',
            '2018','2019'
        ],
        'month':[
            '01','02','03',
            '04','05','06',
            '07','08','09',
            '10','11','12'
        ],
        'time':'00:00',
        '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
        'format':'netcdf'
    },
    'ERA5_mslp.nc')

Then I ran this from the command line:

python ERA5.mslp.CDS

And this quickly retrieved the required data!

Categories
Uncategorized

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
cdo

https://code.mpimet.mpg.de/projects/cdo/wiki/Anaconda

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

grib_to_netcdf

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

Fantastic!