将低于阈值的值设置为netcdf文件中的阈值 [英] setting values below a threshold to the threshold in a netcdf file

查看:158
本文介绍了将低于阈值的值设置为netcdf文件中的阈值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在netcdf文件中将所有低于常数c的值设置为c本身:file.nc

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

使用气候数据运算符(CDO)的解决方案应该是

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?

推荐答案

您可以使用 NCO的ncap2 轻松做到这一点.

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

例如,在file.nc中将所有x的值都设置为100以下,并在file2.nc中输出:

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 

这篇关于将低于阈值的值设置为netcdf文件中的阈值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆