Project

General

Profile

maxc overwriting missing

Added by Brendan DeTracey 8 months ago

Hi,
I am having an issue with the maxc operator because it does not respect missing values. For example,

cdo -maxc,1000 land.nc test.nc
fills all missing values with 1000. Is this the expected behavior for the arithc operators? Is this bug?
Is there any immediate solution to this issue? In my case I am operating on a glob of files and am hoping for a "one-liner" solution.
Thanks.

Edit: I created a temporary mask file using -expr,'!isMissval(x)' to solve my problem, but I still wonder if the arithc behavior is a bug or a feature.

land.nc (1.01 MB) land.nc

Replies (6)

RE: maxc overwriting missing - Added by Karin Meier-Fleischer 8 months ago

Hi Brendan,

that's right, maxc sets all values less than the constant to the value of the constant, which is probably the intention. To set the values below the constant to missing value, I would rather do the following

cdo -expr,'topo = ((topo >= 1000)) ? topo : topo/0.0' land.nc outfile.nc

RE: maxc overwriting missing - Added by Uwe Schulzweida 8 months ago

Or:

cdo expr,"topo=max(topo,1000)" land.nc outfile.nc

RE: maxc overwriting missing - Added by Uwe Schulzweida 8 months ago

Since maxc and expr/max give different results, I think there is an error in maxc/minc. We will correct this bug in the next CDO release.

RE: maxc overwriting missing - Added by Karin Meier-Fleischer 8 months ago

@Uwe

The results of

cdo expr,"topo=max(topo,1000)" land.nc outfile.nc

and

cdo -expr,'topo = ((topo >= 1000)) ? topo : topo/0.0' land.nc outfile.nc

are different. Shouldn't it be the same?

RE: maxc overwriting missing - Added by Karin Meier-Fleischer 8 months ago

Forget it, I should pay attention to what I wrote myself above. And it's not even Monday yet...

RE: maxc overwriting missing - Added by Uwe Schulzweida 8 months ago

You are right this is not the same. The function max() does the same as:

cdo -expr,'topo = ((topo >= 1000)) ? topo : 1000' land.nc outfile.nc

    (1-6/6)