如何使用 expr cdo-climate 基于间隔条件计算变量
我正在尝试根据两个离散条件计算 fsa 变量值。最后,我想要一个带有变量 fsa 的输出文件。第一个条件是当tas大于275.15时fsa等于1。在第二个条件中,当 tas 在 273.15 和 275.15 之间时,我希望 fsa 等于 (1-0.5*( tas -273.15))。这是我第一次尝试使用 expr,感谢任何帮助。任何方法都可以,不必是 expr。我的文件很大,所以首选简洁的方法。
cdo -expr, 'fsa = ((tas>275.15)) ? 1.0 : 0; fsa = ((tas<=275.15 & tas>273.15)) ? (1-0.5*(tas-273.15)) : fsa; <infile> <outfile>
I am trying to calculate fsa variable values based on two discrete conditions. In the end, I want one output file with variable fsa. The first condition is fsa equals 1 when tas is greater than 275.15. In the second condition, I want fsa to be equal to (1-0.5*( tas -273.15)) when tas is between 273.15 and 275.15. Here is my first try using expr, any help is appreciated. any approach will be ok it doesn't have to be expr. my file size is big so a concise method is preferred.
cdo -expr, 'fsa = ((tas>275.15)) ? 1.0 : 0; fsa = ((tas<=275.15 & tas>273.15)) ? (1-0.5*(tas-273.15)) : fsa; <infile> <outfile>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是 CDO 社区主论坛 Ralf 的回答。
您可以像这样使用嵌套三元运算符:
逻辑 OR 是 && !
Here is the answer by Ralf from CDO community main forum.
You can use nest the ternary operators like this:
The logical OR is && !