Project

General

Profile

Announcing rcdo: a package to use cdo from R

Added by Elio Campitelli about 1 month ago

Hi folks,

a few months ago I developed the rcdo package (https://github.com/eliocamp/rcdo), which allows using cdo from R. I've been using it myself but it would be great if more people tried it out and found all the paint points that could be ironed out.

Now, you might want to ask, why create another package that wraps cdo in R if the ClimateOperators package still exists? Well, rcdo is designed to be more idiomatic. Instead of calling cdo commands using strings that you need to memorise, in rdo each operator its a function with parameters and documentation, so you can write `cdo_remap` and then use autocompletion to see all the available remap operators, such as `cdo_remapbil()` or `cdo_remapmean()`. rcdo is also built with piping in mind. cdo pipes fit really naturally with R pipe syntax, so with rcdo you can write chain operations using idiomatic R expressions like

sh_500_climatology <- file |> 
  cdo_sellonlatbox(lon1 = 0, lon2 = 360, lat1 = -90, lat2 = 0) |> 
  cdo_sellevel(level = 500) |> 
  cdo_ymonmean() |>
  cdo_execute()

Functions always check that the output of the previous operation is compatible with their input. You get an error if you try to chain an operation that returns 2 files into an operation than expects 1 file.

The output of `cdo_execute()` is a file or vector of files (depending on the number of outputs of the las operator) and defaults to a temporary file that is deleted if no longer accesible. This means less time manually managing intermediate files.

Anyway, I hope people find rcdo useful. As I said, I'd love to get feedback from the community, so don't hesitate to open an issue on the repository: https://github.com/eliocamp/rcdo/issues/