0

I am dealing with slight negative values (after de-accumulate a cumulative precipitation array), which I suppose are numerical artifacts due to precision, and I want to truncate all values x<0 and assign them as 0.

Is there any function to truncate values in CDO/NCO? I cannot find them.

Many thanks in advance!

ClimateUnboxed
  • 7,106
  • 3
  • 41
  • 86
  • 1
    You want to use either expr or aexpr in CDO, which lets you do simple arithmetic to create new variables – Robert Wilson Mar 10 '23 at 20:25
  • this is a duplicate of https://stackoverflow.com/questions/37164297/setting-values-below-a-threshold-to-the-threshold-in-a-netcdf-file - please use cdo-climate to tag future "climate data operator" questions - cdo is ambiguous as there are at least 3 "cdo"s out there... – ClimateUnboxed Mar 10 '23 at 22:43

1 Answers1

1

A concise way to truncate is with ncap2's clipping operator >> documented here:

ncap2 -s 'precip = precip >> 0' in.nc out.nc
Charlie Zender
  • 5,929
  • 14
  • 19