wiki:HowTo_cdo_netcdf

Version 1 (modified by zpoussi, 10 years ago) (diff)

--

ncap2

the most powerful and quickly evolving tool from the nco set of functions

See the file of exemples : {{:reunions_orchidee:ncap2.pdf| ncap2 file}} or search what you are looking on this growing list of answers forum nco

A simple exemple showing different capacities (creation of a variable, use of a mask, call to an attribute, count the total and the size of the field (we can restrict this operation to a dimension as shown on the second line)

<code>

ncap2 -O -s 'missing_flag[$y,$x]=0;where(t2m_daily!=t2m_daily@missing_value) missing_flag=1;missing_count=float(missing_flag.total())/missing_flag.size();print(missing_count)' stomate_restart.nc ~/foo.nc ncap2 -O -s 'missing_flag[$y,$x]=0;where(t2m_daily!=t2m_daily@missing_value) missing_flag=1;missing_count=float(missing_flag.total($x))/missing_flag.size($x);print(missing_count)' stomate_restart.nc ~/foo.nc

</code>

cdo

A command that handle many operations one would like to do when working on outputs of models of the Earth System :

  • changing of time axis
  • regridding (many grid are already implemented and it is an even more versatile tool)
  • complex operations...

See the website of the project {{https://code.zmaw.de/projects/cdo/wiki}} or the doc : {{:reunions_orchidee:cdo-manual.pdf| CDO Manual}} and the {{:reunions_orchidee:cdo_refcard.pdf | quickref}}

<code> cdo -v # print list of available operators cdo -V # version (if very old, think of downloading the source and install a new version, as it is a tool that is evolving quickly cdo -h remapcon # informations about a command cdo remapcon,my_grid my_climatology.nc my_regridded_climatology.nc # conservative regridding to an other resolution </code>

my_grid could be a file like :<code> gridtype = lonlat gridsize = 220 xname = longitude xunits = degrees_east yname = latitude yunits = degrees_north xsize = 20 ysize = 11 xfirst = -18.75 xinc = 3.75 yfirst = 20