Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

setting values below a threshold to the threshold in a netcdf file

I want to set all values below a constant c to c itself in a netcdf file: file.nc

A solution using climate data operators (CDO) would be

cdo mul -gec,$c file.nc file.nc t1.nc
cdo add -mulc,$c -ltc,$c file.nc t1.nc output.nc
rm -f t1.nc

But is there a neater/shorter way to do this?

like image 751
Adrian Tompkins Avatar asked Dec 07 '22 22:12

Adrian Tompkins


2 Answers

You can use NCO's ncap2 to do this easily.

For example, set all values of x below 100 to 100 in file.nc and output in file2.nc:

>>> ncap2 -s 'where(x<100.) x=100;' file.nc -O file2.nc 
like image 58
N1B4 Avatar answered Dec 28 '22 08:12

N1B4


ncap2's clipping operator is most concise:

ncap2 -s 'x=x>>100' in.nc out.nc
like image 33
Charlie Zender Avatar answered Dec 28 '22 07:12

Charlie Zender