4 Getting Started with Climate Data
The intention with this information and scripts is to provide a basic understanding of how you can use CDO to speed-up your netCDF file data manipulation. More info go directly to the Max Planck Institute CDO website
4.1 Installation Process
4.1.1 MacOS
Follow the instruction and downloaded MacPorts. MacPorts is an open-source community initiative to design an easy-to-use system for compiling, installing, and upgrading the command-line on the Mac operating system.
MacPorts website MacPorts download
After the installation (if you have admin rights) open the terminal and type:
port install cdo
If you don’t have admin rights, open the terminal and type:
sudo port install cdo
and write your password
4.1.2 Windows 10
In the current windows 10 version(s) Microsoft includes an Ubuntu 16.04 LTS embedded Linux. This environment offers a clean integration with the windows file systems and and the opportunity to install CDO via the native package manager of Ubuntu.
Install the Ubuntu app from the Microsoft Store application. Then open the Ubuntu terminal and type:
sudo apt-get install cdo
and write your password
4.1.3 Linux
For Linux go to: Linux
4.2 Ncview: a netCDF visual browser
Ncview is quick visual browser that allows you to explore netCDF files very easily: ncview
. ncview
is an easy to use netCDF file viewer for linux and OS X. It can read any netCDF file.
To install ncview, open the terminal and type:
- OS X:
port install ncview
- Linux:
sudo apt-get install ncview
4.3 Working with CDO and ncview
To work with CDO and ncview you will need to use the terminal command line. Open the Ubuntu app in Windows and the Terminal on OS X. Let’s check a folder in your desktop:
In your command line type:
cd ESM_240/data/
(this will establish data as your primary directory)
If your are using Windows your desktop path should be located at /mnt/c/
.
Because you have setting ESM_240/data/
as your directory in the terminal, we can use ncview to get a quick view of the front data
- type
ls -l
to see if the front data is in your directory. - to view the model with ncview, in the terminal type
ncview tos_Omon_GFDL-ESM4_ssp585_r1i1p1f1_gr_201501-203412.nc
.
We can check the file details using cdo. In the terminal type:
cdo -sinfov tos_Omon_GFDL-ESM4_ssp585_r1i1p1f1_gr_201501-203412.nc
The model details are:
- Variable: tos (sea surface temperature)
- Horizontal component: resolution 360x180
- Vertical component: 1 level (i.e., surface)
- Time component: 240 steps
4.4 CDO extra functions
There are several things that you can explore. Some interesting functions that I’ve used a lot are:
cdo -yearmean
calculates the annual mean of a monthly data input netCDF filecdo -yearmin
calculates the annual min of a monthly data input netCDF filecdo -yearmax
calculates the annual max of a monthly data input netCDF filecdo -ensmean
calculates the ensemble mean of several netCDF files. If your input files are different models, this function will estimate a mean of all those modelscdo -vertmean
calculates the vertical mean for netCDF with olevel (i.e., depth)cdo -mergetime
merge all the netCDF files in your directory
To use those argument remember just type in the terminal:
- cdo -[function] input_file output_file
4.5 Workflow for using climate model outputs
For those seeking to incorporate climate models into their professional work to address climate change, understanding the starting point can be challenging. Here is a framework, detailed in our recently published paper online (Schoeman et al. 2023).