[Thread Prev][Thread Next][Index]

Re: [ferret_users] Masking a file variable and append

Hi Danny,
You want to change the values of the variable that are 0 to -1.e34, and make -1.e34 the missing-value flag for the variable, is that correct?  Ferret doesn't let you overwrite the values of a variable in an existing file, but you could create a new variable with the mask and append it to your file. (see below)

Even simpler would be to add a new attribute to the variable in your file, which you can do outside of Ferret with nco operators such as ncatted (see http://nco.sourceforge.net/nco.html)  or from inside Ferret with the nco_attr function;

To append a masked variable to your file with standard Ferret commands, you would create a new, masked for "missing if depth_t is 0". The commands would be:

let/bad=-1.e34  depth_t_masked = if depth_t NE 0 THEN depth_t
save/file=grid_spec.nc/append depth_t_masked

To assign the other attributes of depth_t  to your new variable, you can do one of two things

1) use qualifiers on the LET command, such as
let/bad=-1.e34/units=`depth_t,RETURN=units`/title=`depth_t,return=title` depth_t_mask = ...
let/bad=-1.e34  depth_t_mask = if depth_t NE 0 THEN depth_t
set att/like=depth_t depth_t_mask

Now, there's another option, which is to use something like the NC

Dumont Dany wrote:
Dear ferreters,

I want to apply a mask to a variable where it is equal to zero and then append the change to the same file. I use the following script, but the resulting file remains unchanged. What do I do wrong and what should I do?

use grid_spec.nc
set list/format=cdf
set memory/size=100
set variable/bad=0 depth_t
define att/type=float depth_t.missing_value = -1.e34

The change is done after the line 'define attribute/...', i.e. the attribute is correctly shown when I type 'show data/attr' and the variable is effectively masked. However, the change is not saved to the file. The original file has a lot of variables (about a hundred) and I don't want to list them all.



[Thread Prev][Thread Next][Index]

Contact Us
Dept of Commerce / NOAA / OAR / PMEL / TMAP

Privacy Policy | Disclaimer | Accessibility Statement