[ncl-talk] Sub: Set lonL/lonR error
Mary Haley
haley at ucar.edu
Wed May 18 12:00:22 MDT 2016
The error is telling you what to do:
"You may want to set the gsnAddCyclic resource to False to avoid a warning
message from the spline function."
When you plot regional data, you don't want to add a longitude cyclic point.
Try setting:
res at gsnAddCyclic = False
--Mary
On Wed, May 18, 2016 at 10:14 AM, Adv <advita6 at gmail.com> wrote:
> Hi,
>
> I still get error.
>
> Output of PrintVarSummary command.
> Variable: xt
> Type: float
> Total Size: 128943360 bytes
> 32235840 values
> Number of Dimensions: 3
> Dimensions and sizes: [time | 1968] x [lat | 91] x [lon | 180]
> Coordinates:
> time: [447048..1883904]
> lat: [90..-90]
> lon: [ 0..358]
> Number Of Attributes: 19
> cell_methods : time: mean (monthly from 6-hourly values)
> long_name : Monthly Air Temperature at sigma level 0.995
> units : degK
> precision : 2
> GRIB_id : 11
> GRIB_name : TMP
> var_desc : Air temperature
> dataset : NOAA-CIRES 20th Century Reanalysis version 2c Monthly
> Averages
> level_desc : sigma level 0.995
> statistic : Ensemble Mean
> parent_stat : Individual Obs
> standard_name : air_temperature
> missing_value : -9.96921e+36
> valid_range : ( 100, 500 )
> statistic_method : Ensemble mean is calculated by averaging over all
> 56 ensemble members at each time step and then averaging mean over all time
> steps in a month
> GridType : Cylindrical Equidistant Projection Grid
> datum : wgs84
> actual_range : ( 215.7992, 318.2858 )
> _FillValue : -9.96921e+36
>
> Now I get error ::::::
>
> (0) gsn_add_cyclic: Warning: The range of your longitude data is not
> 360.
> (0) You may want to set the gsnAddCyclic resource to False to avoid a
> (0) warning message from the spline function.
> warning:_NhlCreateSplineCoordApprox: Attempt to create spline
> approximation for X axis failed: consider adjusting trXTensionF value
> warning:IrTransInitialize: error creating spline approximation for
> trXCoordPoints; defaulting to linear
>
>
> There is shift in the region too.
>
> Please help me to fix this.
>
> Thank you
>
>
> On Tue, May 17, 2016 at 6:07 PM, Adam Phillips <asphilli at ucar.edu> wrote:
>
>> Hello,
>> Please remember to always include ncl-talk on any responses, as that way
>> other users can assist.
>>
>> You responded to me stating that the error message occurs at this line:
>> x = f->air(iStrt:iLast,{latS:latN},{lonL:lonR}) ;;;;;{line
>> 51}:::::::::::
>>
>> The error message stated that the 2nd subscript is out of range. Thus,
>> your specified lonL and lonR coordinate subscripts are not within the range
>> of air's longitudes. You are setting lonL = -116 and lonR = -90. A
>> common ncl-talk phrase is to always look at your data.
>>
>> Try this:
>> xT = f->air
>> printVarSummary(xT)
>> With printVarSummary you will see the coordinate variables and their
>> range. I am guessing that your longitudes run from 0-360. Thus, when
>> coordinate subscripting you should specify longitudes from 0-360. (You
>> might want to check the latitude order as well, do they run from south to
>> north or north to south?)
>>
>> Now try this:
>> lonL = 244
>> lonR = 270
>> x = xT(iStrt:iLast,{latS:latN},{lonL:lonR})
>> delete(xT)
>> printVarSummary(x)
>>
>> Hopefully that all answers your query. If not, please respond to the
>> ncl-talk email list.
>> Adam
>>
>>
>>
>>
>>
>> On Tue, May 17, 2016 at 1:09 PM, Adv <advita6 at gmail.com> wrote:
>>
>>> Hi,
>>> I am getting this error. Could someone help me to fix this bug?
>>>
>>> Thanks
>>>
>>> fatal:["NclFile.c":2103]:Subscript out of range, error in subscript #2
>>> fatal:["Execute.c":8575]:Execute: Error occurred at or near line 51 in
>>> file regress_dennis.ncl
>>> load "./contributed.ncl_beta_640"
>>>
>>> begin
>>>
>>> ;************************************************
>>> ; Specify geographical region and time span (year-month start and end
>>> ;************************************************
>>>
>>> latS = 40
>>> ; latS = 0
>>> latN = 49
>>> lonL = -116
>>> lonR = -90
>>>
>>> ymStrt = 195101
>>> ymLast = 201012
>>>
>>> pltType = "x11"
>>> pltName = "regress"
>>> pltTitle = "Globe: "+(ymStrt/100)+"-"+(ymLast/100)
>>>
>>> ;************************************************
>>> ; Read from netCDF file: variable is type short...unpack
>>> ;************************************************
>>> version= "v2" ; "v2", "v2c"
>>>
>>> diri = "./"
>>> ; fili = "air.sig995.mon.mean."+version+".nc"
>>> fili = "air.sig995.mon.mean.nc"
>>> f = addfile(diri+fili,"r")
>>>
>>> YYYYMM = cd_calendar( f->time, -1)
>>> yyy = 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
>>> ;************************************************
>>> wgt = cos(0.01745329*x&lat)
>>> xann = month_to_annual(x , 1) ; [year| 60]x[lat|
>>> 91]x[lon| 180]
>>> xavg = wgt_areaave_Wrap(xann , wgt, 1.0, 1) ; [year| 110]
>>>
>>> xann&year = year
>>> xann at long_name = "Annual Air Temperature ("+version+": sigma=0.995)"
>>> printVarSummary(xann)
>>> printMinMax(xann,0)
>>> ;return
>>> ;************************************************
>>> ; Calculate the regression coefficients (slopes)
>>> ;************************************************
>>> rc = regCoef(year,xann(lat|:,lon|:,year|:))
>>>
>>> rc at long_name = "Trend"
>>> rc at units = "degC/"+nyrs+"_year"
>>> printMinMax(rc,0)
>>>
>>>
>>> ;************************************************
>>> ; plotting parameters
>>> ;************************************************
>>> wks = gsn_open_wks("x11","regress_4_"+version) ; specifies a
>>> ps plot
>>>
>>> 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 cnLevelSelectionMode = "ManualLevels" ; set manual contour
>>> levels
>>> ; res at cnMinLevelValF = -2.0 ; set min contour level
>>> res at cnMinLevelValF = -3.0 ; set min contour level
>>> ; res at cnMaxLevelValF = 2.0 ; set max contour level
>>> res at cnMaxLevelValF = 5.0 ; set max contour level
>>> ; res at cnLevelSpacingF = 0.2 ; set contour interval
>>> res at cnLevelSpacingF = 0.5 ; 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 = "20th Century Reanalysis ("+version+"):
>>> sig995" ; fili
>>> plot = gsn_csm_contour_map_ce(wks,rc,res)
>>>
>>>
>>> ;************************************************
>>> ; Perform linear regression on selected annual mean
>>> ;************************************************
>>>
>>>
>>> rcTest = regline_stats(year, xavg) ; degC/year
>>> ; rcTest at long_name = "trend: ("+toint(LAT)+","+toint(LON)+")"
>>> rcTest at long_name = "trend:"
>>> rcTest at units = "degC/year"
>>> rcTest = rcTest*nyrs ; (C/year)*(nyrs)
>>> rcTest at units = "degC/"+nyrs+"_year"
>>>
>>> pltarry = new ( (/2,nyrs/), typeof(xann))
>>> pltarry(0,:) = xavg ; use markers
>>> pltarry(1,:) = rcTest at Yest ; regression
>>> values
>>>
>>> resxy = True ; plot mods desired
>>> resxy at xyMarkLineModes = (/"Markers","Lines"/); choose which have
>>> markers
>>> resxy at xyMarkerColors = (/"Red", "Blue" /); choose which have
>>> markers
>>> resxy at xyMarkers = 16 ; choose type of
>>> marker
>>> resxy at xyMarkerSizeF = 0.0075 ; Marker size
>>> (default 0.01)
>>>
>>> resxy at xyDashPatterns = 0 ; solid line
>>> resxy at xyLineThicknesses = (/2,3/)
>>> resxy at xyLineColors = (/ "blue" , "black" /)
>>> resxy at tmYLFormat = "f" ; not necessary
>>> but nicer labels
>>>
>>> ;;resxy at trXMinF = min(year)
>>> resxy at trXMaxF = max(year)
>>> resxy at tiMainString = "regline: 20th Renalysis
>>> ("+version+"): trend="+sprintf("%5.2f", rcTest)
>>>
>>> ;---Make legend smaller and move into plot
>>> resxy at pmLegendDisplayMode = "Always" ; turn on legend
>>> resxy at pmLegendSide = "Top" ; Change location
>>> of
>>> resxy at pmLegendParallelPosF = 0.225 ; move units Leftt
>>> resxy at pmLegendOrthogonalPosF = -0.30 ; move units down
>>> resxy at pmLegendWidthF = 0.10 ; Change width and
>>> resxy at pmLegendHeightF = 0.100 ; height of
>>> legend.
>>> resxy at lgPerimOn = True ; turn off/on box
>>> around
>>> resxy at lgLabelFontHeightF = .015 ; label font height
>>> resxy at xyExplicitLegendLabels = (/"data" , "regline" /)
>>> plot = gsn_csm_xy
>>> (wks,year,pltarry,resxy) ; create plot
>>>
>>> end
>>>
>>>
>>> _______________________________________________
>>> ncl-talk mailing list
>>> ncl-talk at ucar.edu
>>> List instructions, subscriber options, unsubscribe:
>>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>>
>>>
>>
>>
>> --
>> Adam Phillips
>> Associate Scientist, Climate and Global Dynamics Laboratory, NCAR
>> www.cgd.ucar.edu/staff/asphilli/ 303-497-1726
>>
>> <http://www.cgd.ucar.edu/staff/asphilli>
>>
>
>
> _______________________________________________
> 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/20160518/f5d4e7e8/attachment.html
More information about the ncl-talk
mailing list