Re: NCL masking error

From: Adam Phillips <asphilli_at_nyahnyahspammersnyahnyah>
Date: Mon Dec 17 2012 - 18:36:08 MST

Hi Prajjwal,
I prefer to use the where function as opposed to mask, as I find the
where function easier to understand. I think your coding was close. Try
this:
range_only =
mask(conform(cru_mon,basin,(/1,2/)).eq.9,cru_mon,cru_mon@_FillValue)
Note that the above line assumes that cru_mon@_FillValue is present.. If
it isn't, set it before calling where.
http://www.ncl.ucar.edu/Document/Functions/Built-in/where.shtml

If that doesn't help please let ncl-talk know..
Adam

On 12/14/12 2:00 PM, Panday, Prajjwal wrote:
> Hello all,
>
> I am trying to mask a netCDF file. The input file (cru_mon) dimensions
> is time(12)xlat(360)xlon(320) after subscripting. The mask file
> dimensions is lat(360)x lon(720).
> When I run the script, I am getting an error
> "warning:ContourPlotInitialize: no valid values in scalar field." and
> I get nothing in the output map. If I mask the input file by only
> sorting values greater than 100, I am able to map the data so I know
> that I am masking incorrectly. Any help is appreciated.
> Please see the program below for details.
>
> Thanks,
> Prajjwal
>
> ---------------------------------------------------------------------------------------------------------
>
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
>
> begin
>
> ; Read in input NetCDF files
> dir1 = "C:/Data/Documents/IBIS/reanalysis_data/cru/"
> file1 = "cru_pre.nc"
> cru_prec = addfile(dir1+file1,"r")
> cru_mon = cru_prec->pre(0:11,:,:) ; Dimensions time(12),
> lat(360), lon(720)
> printVarSummary(cru_mon)
>
> ; Open mask file
> dir2 = "C:/Data/Documents/IBIS/mask/"
> file2 = "union.nc"
> x2 = addfile(dir2+file2,"r")
> basin = x2->mask; Dimensions lat(360), lon(720)
>
> range_only = cru_mon
> ;range_only = mask(cru_mon,(cru_mon.ge.100),True) ; greater than
> 1mm/day precip
> ;range_only = mask(cru_mon,conform(cru_mon,basin,(/1,2/)),9) ; mask
> data by Xingu basin (mask value=9)
> range_only = mask(cru_mon,basin,9) ; there is no value in the output
> and I get an error
> printVarSummary(range_only)
>
> ;***************************************
> ; create individual plots
> ;***************************************
> wks = gsn_open_wks("pdf","cru_xingu") ; open a ps file
> gsn_define_colormap(wks,"BlAqGrYeOrRe") ; choose colormap
> res = True ; plot mods desired
> res@cnFillOn = True ; turn on color fill
> res@cnLinesOn = False ; turn off
> contour lines
> res@gsnSpreadColors = True ; use full
> range of color map
> plot = gsn_csm_contour_map_ce(wks,range_only(6,:,:),res) ;
> plotting only the 7th time
>
> en
>
>
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Mon Dec 17 18:36:21 2012

This archive was generated by hypermail 2.1.8 : Fri Dec 21 2012 - 10:43:23 MST