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; http://ferret.pmel.noaa.gov/Ferret/documentation/users-guide/appendix-a-external-functions/NCO_ATTR 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 = ...or 2) use SET ATTRIBUTE/LIKE= 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 list/file=grid_spec.nc/append exit ' 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. Thanks, Dany |