[ncl-talk] regarding the trend in depth and its significance

saurabh rathore rohitsrb2020 at gmail.com
Mon Jan 2 23:53:34 MST 2017


Dear NCL users,

i am quite new to ncl, so i having a problem in plotting the trend of ocean
heat. i am having my monthly data consists of time, latitude and level.
There is no longitudes in my data. so i want to calculate the trend i.e.
the map of regression coefficient in depth and latitudes and later on the
significance test of this trend.
This is my script i am using to calculate the RC value.

;*************************************************
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
;************************************************
; create pointer to file and read in temperature
;************************************************
   diri = "./"
   fili = "heat_gm.nc"
   in  = addfile(diri+fili,"r")

   tmp  = in->HEAT_G
   printVarSummary(tmp)
   ts   = tmp(LEV |:, LAT28_153 |:, TIME |:)

delete(tmp)                                  ; no longer needed

;************************************************
; create x and calculate the regression coefficients (slopes, trends)
;************************************************
   time         = ts&TIME                       ; days since 1850-01-01
   ;time=ispan(1, 1800, 1)
   rc           = regCoef(time,ts)

;************************************************
; for illustration: change units to j/m^2/year
;***********************************************

   rc at long_name = "regression coefficient (trend)"
   copy_VarCoords(ts(:,:,0), rc)          ; copy lat,lon coords
   rc           = rc*365                  ; (Pa/day)*(365_day/year)
   rc at units     = "j/m^2/year"

   tval = onedtond(rc at tval , dimsizes(rc))
   df   = onedtond(rc at nptxy, dimsizes(rc)) - 2
   b = tval    ; b must be same size as tval (and df)
   b = 0.5
   prob = 1-betainc(df/(df+tval^2),df/2.0,b)       ; prob(nlat,nlon)
   copy_VarCoords(rc, prob)

   rc at long_name   = "regression coefficient"
   prob at long_name = "probability"
   printVarSummary(prob)
   printVarSummary(rc)

;************************************************
; plotting parameters
;************************************************
   wks  = gsn_open_wks("png" ,"regress_t-test_test")
   ;gsn_define_colormap(wks,"ViBlGrWhYeOrRe")    ; choose colormap

   res                       = True
   res at gsnFrame=False
   res at gsnDraw=False
   ;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        =   -5          ; set min contour level
   res at cnMaxLevelValF        =   5           ; set max contour level
   res at cnLevelSpacingF       =   1           ; set contour interval

   ;res at mpFillOn              = False            ; turn off default
background gray
   ;res at mpCenterLonF          = 210

   res at tiMainString          = fili
   plot = gsn_csm_contour_map(wks,rc,res)

prob_p=where (prob.ge.0.95,1,0)
copy_VarCoords(prob, prob_p)
;print(prob_p)
rescn=True
rescn at gsnFrame=False
rescn at gsnDraw=False
rescn at cnLevelSelectionMode = "ManualLevels"
rescn at cnMinLevelValF       = -0.5
rescn at cnMaxLevelValF       = 1.5
rescn at cnLevelSpacingF      = 1.
rescn at cnFillOn             = True
  rescn at cnMonoFillColor      = True
  rescn at cnMonoFillPattern    = False
  rescn at cnConstFEnableFill   = False
  rescn at cnFillScaleF         = 0.55
  rescn at cnFillDotSizeF       = 0.002
  rescn at cnFillColor          = "black"
  rescn at cnFillPatterns       =  (/-1,-1,17,-1/)
  rescn at cnLinesOn            = False
  rescn at lbLabelBarOn          =False
  rescn at cnInfoLabelOn        = False
  ;rescn at cnInfoLabelFont      = 21

;rescn at mpCenterLonF          = 210
plotB=gsn_csm_contour(wks,prob_p,rescn)

overlay(plot, plotB)
draw(plot)
frame(wks)
end



After running this script i am getting this error



​Variable: tmp
Type: double
Total Size: 3864672 bytes
            483084 values
Number of Dimensions: 3
Dimensions and sizes:    [TIME | 142] x [LEV | 27] x [LAT28_153 | 126]
Coordinates:
            TIME: [731962..736253]
            LEV: [   0..2000]
            LAT28_153: [-62.5..62.5]
Number Of Attributes: 5
  missing_value :    -9.999999999999999e+33
  _FillValue :    -9.999999999999999e+33
  long_name :    HEAT_ANM_ALL[X=@DIN]/10^10
  long_name_mod :    X=0E:0E(360)
  history :    From heat_anm_all

Variable: prob
Type: double
Total Size: 27216 bytes
            3402 values
Number of Dimensions: 2
Dimensions and sizes:    [LEV | 27] x [LAT28_153 | 126]
Coordinates:
            LEV: [   0..2000]
            LAT28_153: [-62.5..62.5]
Number Of Attributes: 1
  long_name :    probability

Variable: rc
Type: double
Total Size: 27216 bytes
            3402 values
Number of Dimensions: 2
Dimensions and sizes:    [LEV | 27] x [LAT28_153 | 126]
Coordinates:
            LEV: [   0..2000]
            LAT28_153: [-62.5..62.5]
Number Of Attributes: 7
  units :    j/m^2/year
  long_name :    regression coefficient
  _FillValue :    -9.999999999999999e+33
  nptxy :    <ARRAY of 3402 elements>
  rstd :    <ARRAY of 3402 elements>
  yintercept :    <ARRAY of 3402 elements>
  tval :    <ARRAY of 3402 elements>
(0)    check_for_y_lat_coord: Warning: Data either does not contain a valid
latitude coordinate array or doesn't contain one at all.
(0)    A valid latitude coordinate array should have a 'units' attribute
equal to one of the following values:
(0)        'degrees_north' 'degrees-north' 'degree_north' 'degrees north'
'degrees_N' 'Degrees_north' 'degree_N' 'degreeN' 'degreesN' 'deg north'
(0)    check_for_lon_coord: Warning: Data either does not contain a valid
longitude coordinate array or doesn't contain one at all.
(0)    A valid longitude coordinate array should have a 'units' attribute
equal to one of the following values:
(0)        'degrees_east' 'degrees-east' 'degree_east' 'degrees east'
'degrees_E' 'Degrees_east' 'degree_E' 'degreeE' 'degreesE' 'deg east'
warning:ContourPlotDraw: out of range coordinates encountered; standard
AreaFill rendering method may be unreliable;
 consider setting the resource trGridType to "TriangularMesh" if
coordinates contain missing values​


​please help me out as there is no such link in ncl user list to get rid of
this problem. i want a plot of my regression coefficient variable in depth
and latitude .

regards, saurabh

-- 


*REGARDS*

*Saurabh Rathore*
*Research Scholar (PhD.)*
*Centre For Oceans, Rivers, Atmosphere & Land Science Technology*
*Indian Institute Of Technology, Kharagpur*
*contact :- 91- 8345984434*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20170103/94fa670b/attachment.html 


More information about the ncl-talk mailing list