[ncl-talk] ignore values greater than 1.0
Guido Cioni
guidocioni at gmail.com
Thu Aug 11 03:49:23 MDT 2016
Nitin, if you want to ignore the values in computations/plot you can easily mask the variable making use of the _FillValue attribute. NCL will ignore every missing value when computing stuff, e.g. averages or making contour plots.
I would do something like that
x=where(x .ge. 1, x at _FillValue, x)
that means, where x is greater than or equal to 1 put a _FillValue, otherwise preserve the original x value.
You need the _FillValue attribute to be already defined at the time of execution, but I thing that wouldn’t be a problem since x is already defined as float.
Guido Cioni
http://guidocioni.altervista.org <http://guidocioni.altervista.org/>
> On 11 Aug 2016, at 11:43, Nitin Patil <nitinpatil85 at gmail.com> wrote:
>
> Dear NCL usrs,
>
> In my script I want to ignore AOD values which are greater than 1.0, any idea where to put it?
>
> =================
> 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
>
> ;************************************************
> ; Specify geographical region and time span (year-month start and end
> ;************************************************
>
> latS = -90
> latN = 90
> lonL = 0
> lonR = 360
>
> ymStrt = 197101
> ymLast = 201012
>
> pltType = "ps"
> pltName = "regress"
> pltTitle = "Globe: "+(ymStrt/100)+"-"+(ymLast/100)
>
> ;************************************************
> ; Read from netCDF file: variable is type short...unpack
> ;************************************************
> diri = "/media/Work/3_LTS_echam6_Data/EACSST_ens_1971-2010/"
> fili = "EACSST_E1_1971-2010_AOD.nc"
> f = addfile(diri+fili,"r")
>
> YYYYMM = cd_calendar( f->time, -1)
>
> iStrt = ind(YYYYMM.eq.ymStrt)
> iLast = ind(YYYYMM.eq.ymLast)
>
> x = short2flt( f->tau_aod(iStrt:iLast,{latS:latN},{lonL:lonR}))
>
>
> x at units= "mm/day"
>
> printVarSummary(x) ; [time| 1344]x[lat| 91]x[lon| 180]
>
> yyyymm = cd_calendar(x&time, -1)
> yyyy = yyyymm/100
>
> dimx = dimsizes(x)
> ntim = dimx(0) ; all years and months
> nlat = dimx(1)
> mlon = dimx(2)
>
> year = ispan(yyyy(0), yyyy(ntim-1), 1)
> nyrs = dimsizes(year)
>
> ;************************************************
> ; Areal averages: cos(lat) is good enough
> ;************************************************
>
> xann = month_to_annual(x , 1) ; [year| 112]x[lat| 91]x[lon| 180]
> xann&year = year
> printVarSummary(xann)
>
> ;************************************************
> ; Calculate the regression coefficients (slopes)
> ;************************************************
> rc = regCoef(year,xann(lat|:,lon|:,year|:))
>
> rc at long_name = "Trend"
> rc at units = xann at units+"/year"
> copy_VarCoords(xann(0,:,:), rc) ; copy lat,lon coords
>
> printVarSummary(rc)
>
> ;************************************************
> ; for illustration: change units to degC/period-used
> ;************************************************
> rc = rc*nyrs ; (C/year)*(nyrs)
> rc at units = ""+nyrs+" year"
>
> ;************************************************
> ; plotting parameters
> ;************************************************
> wks = gsn_open_wks("eps","EACSST_trend_yearly_precip") ; specifies a ps plot
> gsn_define_colormap(wks,"precip2_15lev")
> res = True
> res at gsnMaximize = True ; make large
>
> res at cnFillOn = True ; turn on color
> res at cnLinesOn = False ; turn off contour lines
> res at cnLineLabelsOn = False ; turn off contour line labels
> ;;res at cnFillMode = "RasterFill"
>
> res at mpMinLatF = 5 ;-- sub-region minimum latitude
> res at mpMaxLatF = 40 ;-- sub-region maximum latitude
> res at mpMinLonF = 60 ;-- sub-region minimum longitude
> res at mpMaxLonF = 100 ;-- sub-region maximum longitude
>
>
> res at cnLevelSelectionMode = "ManualLevels" ; set manual contour levels
> res at cnMinLevelValF = -0.18 ; set min contour level
> res at cnMaxLevelValF = 0.18 ; set max contour level
> res at cnLevelSpacingF = 0.01 ; set contour interval
>
> res at mpFillOn = False ; turn off default background gray
> ;res at mpCenterLonF = 180
>
> res at gsnCenterString = year(0)+"-"+year(nyrs-1)
>
> res at tiMainString = "Yearly trend (precip EACSST)" ; fili
> plot = gsn_csm_contour_map_ce(wks,rc,res)
> end
> =================
>
> --
> Regards,
> Nitin Patil
>
> _______________________________________________
> ncl-talk mailing list
> ncl-talk at ucar.edu
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20160811/93d57ba3/attachment.html
More information about the ncl-talk
mailing list