Project

General

Profile

Understanding behaviour of 'expr' with missing data values

Added by Pablo Larraondo over 5 years ago

Hi,

I'm trying to combine two variables representing two time steps in a way that if there is missing data in the most recent step, the grid point is filled with the value in the previous step.

I was thinking of using expr to do this:

cdo expr,'out=(new!=9999)?new:old' steps.nc out.nc

Where the file steps contains both variables 'new' and 'old' and the missing value of these variables is 9999.

However, this approach does not work, the conditional expression seems to not be evaluated for missing data, which results in an output variable identical to 'new'.

Is there a way of evaluating equality to missing value in an expression?

Also, if anyone can think about an alternative approach to do this, please let me know.

Thank you for for help,
Pablo


Replies (2)

RE: Understanding behaviour of 'expr' with missing data values - Added by Karin Meier-Fleischer over 5 years ago

Hi Pablo,

using the missing value as a constant value you have to change it with the setmisstoc operator.

cdo expr,'out=(new!=9999)?new:old' -setmisstoc,9999 steps.nc out.nc

-Karin

RE: Understanding behaviour of 'expr' with missing data values - Added by Pablo Larraondo over 5 years ago

Thanks Karin, I've managed to make it work now.

In fact, I had to define a constant with a different value, as I was getting this warning message and the expr was not working:
cdo setmisstoc (Warning): Missing value and constant have the same value!

Luckily in my case, the data has a defined range and I was able to set a value outside this range.

Anyway, I've been using CDO for a couple of months and I think it's a fantastic tool. Much more efficient and effective than the Python libraries that I was used to. Awesome work!

Pablo

    (1-2/2)