Project

General

Profile

Problems with eqc

Added by Anna marra over 6 years ago

Hi,
I am trying to use eqc to create a 0/1 mask. Specifically I would like to find where a variable (rr) is equal to 0.001. I do know that this value occur, but I am not able to find it (my mask is always zero!). rr is f32 and I run the command
cdo eqc,0.001 infile.nc outfile.nc.
Where am I wrong?
Thank you in advance for your help.
Anna


Replies (6)

RE: Problems with eqc - Added by Karin Meier-Fleischer over 6 years ago

Hi Anna,

I think the value must fit exactly, if not all values will be 0.

A simple test to demonstrate this is to create a mask file where the topography values are equal to 4000

cdo -b F32 -eqc,4000 -topo topo_4000.grb

cdo info topo_4000.grb

    -1 :       Date     Time   Level Gridsize    Miss :     Minimum        Mean     Maximum : Parameter ID
     1 : 0000-00-00 00:00:00       0   259200       0 :      0.0000      0.0000      0.0000 : 1             
cdo info: Processed 259200 values from 1 variable over 1 timestep ( 0.00s )

-Karin

RE: Problems with eqc - Added by Anna marra over 6 years ago

Hi Karin,
thank you for your reply. I am not sure what you mean by "the value must fit exactly". How can I check on my nc file attached? It seems the value 0.001 actually fits for rr.
Thank you in advance.
Anna

pr.nc (4.37 MB) pr.nc

RE: Problems with eqc - Added by Karin Meier-Fleischer over 6 years ago

Ok, there is really something strange because I also get 0 instead of 1.

Maybe Uwe can have a look at this:

The file pr.nc has no time dimension and it seems to be that the value -9.99 is the missing value. First step was to add a time dimension to the file and set the missing value.

cdo -setctomiss,-9.99 -settaxis,2000-01-01,,1day  pr.nc pr_time.nc

Next to create a mask when value equal 0.001.

cdo -eqc,0.001 pr_time.nc pr_time_001.nc

The result contains only 0.

OK let us try another way - retrieve data in a range to see where the 0.001 values are.

cdo -expr,'rr = ((rr >= 0.0009 && rr <= 0.0011)) ? rr : (rr/0.0)' pr_time.nc pr_expr.nc

The result is:

...
    _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, 
    _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, 
    _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, 
    _, _, _, _, _, _, _, _, 0.001, 0.001, 0.001, 0.001, 0.001, 0.001, 0.001, 
    0.001, 0.001, 0.001, 0.001, 0.001, 0.001, _, _, _, _, _, _, _, _, _, _, 
    _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, 
    _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, 
    _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, 
    _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, 
    _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _,
  _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, 
    _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, 
    _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, 
    _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, 
    _, _, _, _, _, _, _, 0.001, 0.001, 0.001, 0.001, 0.001, 0.001, 0.001, 
    0.001, 0.001, 0.001, 0.001, 0.001, 0.001, 0.001, 0.001, _, _, _, _, _, _, 
    _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, 
    _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, 
    _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, 
    _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, 
...

The values are now 0.001 but when we create the mask with

cdo -eqc,0.001 pr_expr.nc pr_001.nc

The value for 0.001 have to be 1 but they are 0

...
 _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, 
    _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, 
    _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, 
    _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, 
    _, _, _, _, _, _, _, _, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, _, _, _, 
    _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, 
    _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, 
    _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, 
    _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, 
    _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, 
    _, _,
  _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, 
    _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, 
    _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, 
    _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, 
    _, _, _, _, _, _, _, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, _, _, 
    _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, 
    _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, 
    _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, 
    _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, 
    _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, 
    _, _,
  _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, 
    _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, 
    _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, 
    _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, 0, 0, _, _, 
    _, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, _, _, 
    _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, 
    _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, 
    _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, 
    _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, 
    _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, 
    _, _,
...

-Karin

RE: Problems with eqc - Added by Anna marra over 6 years ago

Hi Karin,
thank you very much for the time you spent on my question. Yes, the file I attached has no time dimension because I extracted only the rr variable from the original one. Actually the missing value for rr should be -9.99. I attach here the complete file, too. Anyway, as you can see, I get only 0 and never 1.
Thank you again.
Anna

RE: Problems with eqc - Added by Uwe Schulzweida over 6 years ago

This is a bug in CDO! CDO is doing all calculation in 64-bit float. The data has been stored as 32-bit float, these will be converted to 64-bit float. The data representation of 32-bit and 64-bit float is not always 100% identical. We will fix this rounding error in the next CDO release!

ncdump shows only the first 7 significant digits of 32-bit float data. Use ncdump -p 9 to print all digits:

  _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, 
    _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, 
    _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, 
    _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, 
    _, _, _, _, _, _, _, _, 0.00100000005, 0.00100000005, 0.00100000005, 
    0.00100000005, 0.00100000005, 0.00100000005, 0.00100000005, 
    0.00100000005, 0.00100000005, 0.00100000005, 0.00100000005, 
    0.00100000005, 0.00100000005, _, _, _, _, _, _, _, _, _, _, _, _, _, _, 
    _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, 
    _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, 
    _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, 
    _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, 
The 64-bit representation of 0.00100000005 with all digits is 0.0010000000474974513. You can use this number as a workaround to get the correct result.

Cheers,
Uwe

RE: Problems with eqc - Added by Anna marra over 6 years ago

Thank you very much, Uwe! I will do as you suggest.
Cheers,
Anna

    (1-6/6)