Project

General

Profile

Replace values

Added by Neeldip Barman over 4 years ago

I want to replace all the values <= 0.005 of a variable to 0.005 in a grib file. How should I proceed? I didnt get much idea from the manual.

Regards
Neeldip


Replies (7)

RE: Replace values - Added by Ralf Mueller over 4 years ago

Hi!
it depends on what you exactly want to do. Replace with a constant, replace with another variable's values...

cheers
ralf

RE: Replace values - Added by Karin Meier-Fleischer over 4 years ago

Hi Neeldip,

assuming the name of the variable is var

cdo -expr,'var = ((var > 0.005)) ? var : 0.05' infile outfile

-Karin

RE: Replace values - Added by Neeldip Barman over 4 years ago

Hi Ralf,
I want to replace with a constant.

Thanks for the help Karin. But unfortunately it didn't work.
Maybe I didn't explain it properly.

The input file is a multivariate file. I want to replace the values of a variable "SM000007" having values <=0.005 to 0.005. The output file should contain the other variables also along with the replaced values of SM000007.

The solution only extracts the variable to a new file along with the new values.

Regards
Neeldip

RE: Replace values - Added by Ralf Mueller over 4 years ago

you might upload the input file for further help I think

RE: Replace values - Added by Ralf Mueller over 4 years ago

try

 cdo  -aexpr,'SM007028=(SM007028 < 0.005) ? 0.005 : SM007028;' <input-file> <output-file>
this call worked for me

hth
ralf

RE: Replace values - Added by Neeldip Barman over 4 years ago

Thanks:)
Its working!

    (1-7/7)