Project

General

Profile

Create mask for positive values in vertical velocity (omega)

Added by Linda van Garderen almost 3 years ago

Dear sir/madam,

I am trying to create a mask that I can apply to other files (with the same grid) based on the negative values in vertical velocity data. This means the mask should mask out all positive values in the original file.

In this case a land-sea mask is not helpful, as I am interested in values anywhere in my data independent if they are over land or sea.

I have tried the following:

cdo setrtomiss,0,3 <infile.nc> <outfile.nc>

This will help mask out positive values, but does not create a 0 and 1 masking file.
I have also tried ncap2 for setting values (see below), but I keep having a range between 0 and 1 instead of only 0 and 1 values.

ncap2 -s 'where(var135>0.) var135=0;' <infile.nc> <outfile1.nc>
ncap2 -s 'where(var135<0.) var135=1;' <outfile1.nc> <outfile2.nc>

There must be a more elegant and successful way using cdo commands. Can you help me out?
I have put my data file in the appendix.

Thank you!

Linda


Replies (1)

RE: Create mask for positive values in vertical velocity (omega) - Added by Linda van Garderen almost 3 years ago

With some help from a colleague I found an easy solution (that you probably all know already, but here it goes anyway):

cdo setrtoc2,0,3,0,1 <infile.nc> <outfile.nc>

Meaning all values between 0 and 3 are put too 0 and the rest too 1. Perfect.

The tricky part was that I checked my data in ncview, and to see the absolute values I needed to click on:

bi-lin

and then noticed the absolute values were correct. Ncview tried to create a range between 0 and 1 artificially.

Best,

Linda

    (1-1/1)