Project

General

Profile

Setting all values except one to NaN

Added by Brendan DeTracey over 2 years ago

Hi everyone!
I am having difficulties with what should be a simple problem.
I want to convert my netcdf to a binary mask. I want to replace all values of mmask with NaN, except for 4. I then want to change all the 4 to 1. I am having difficulty thinking of the expr that will do this. :-(


Replies (2)

RE: Setting all values except one to NaN - Added by Karin Meier-Fleischer over 2 years ago

Hi Brendan,

cdo -f nc -expr,'mmask = ((mmask == 4.0)) ? 1.0 : 0.0' subsum_EM300_O2.nc outfile.nc

RE: Setting all values except one to NaN - Added by Brendan DeTracey over 2 years ago

Danke, Karin! :)
The elusive double parenthisis parenthesis...

    (1-2/2)