[ncl-talk] confused about plotting t-values (manually)

Hoffman Cheung hoffmancheung at gmail.com
Thu Oct 20 08:26:11 MDT 2016


Hi Noelia,

Let me try to answer this question briefly.

If you use gsn_contour_shade, you have to make sure the "contour" you are
plotting is there, i.e. 0.05 and 1.960 in your case. Otherwise, the program
may not work "properly". Say, when you want to shade the parts smaller than
0.05, but

case 1: if the program only generates contours greater than 0.05, the plot
will not be shaded;
case 2: if the program generates contours smaller than 0.05, then only part
(not all) of the values smaller than 0.05 is shaded.

By default, the contour levels are set automatically, such that the 0.05
might not be there. To solve the problem, you have to set
cnLevelSelectionMode, e.g.
res at cnLevelSelectionMode = "ExplicitLevels"
res at cnLevels = (/0., 0.05/) ; depending on which contour intervals want to
draw
res at cnLinesOn = False ; turn the resource off if you do not want to draw
the line (similar for the two resources below)
res at cnLineLabelsOn = False
res at cnInfoLabelOn = False

Hope my answer helps you solve the problem.

Best,
Hoffman




2016-10-20 9:26 GMT+02:00 Noelia otero <noeli1680 at gmail.com>:

> Hi Mary,
>
>
>
> I sent a couple of questions few days ago (from gmail) , and I was reading
> about some problems regarding the mail list, so I thought that maybe my
> mail has not been received …(I can not see it in the mail list). That's why
> I also added your email addressee  (sorry for the inconvenience).
>
>
> I just wanted to re-send my question (see below), in case you can give me
> a suggestion.
>
>
>
> Thanks in advance!
>
>
>
>
>
> I'm doing a composite and I'm plotting significant areas (of anomalies).
> For that, I computed the t-values manually, and then I was trying to add
> contour for those significant values. However, I'm a bit confused..since if
> I used gsn_contour_shade for the values greater that the critical value (in
> my case) it seems not to work well...so, I 'd like to ask if anyone have a
> suggestion. This is part of my code:
>
>
>
>
>
>      ;Average over the period
>
>       compos_mera = dim_avg(compos_era(lat|:,lon|:,time|:)) ;reordering
>
>       compos_mera!0 = "lat"
>
>       compos_mera!1 = "lon"
>
>       compos_mera&lat = lat
>
>       compos_mera&lon = lon
>
>
>
>       ;std
>
>       composStd = dim_stddev_Wrap(compos_era(lat|:, lon|:, time|:)) ;
>
>       composStd at _FillValue = -999
>
>       composVar = dim_variance_n (compos_era,0)
>
>       composVar at _FillValue = -999
>
>       n = dimsizes(timeE) ;number of observations
>
>
>
>       ;Compute t-student val for significant
>
>       Scom = composStd/(sqrt(n))
>
>       Scom at _FillValue=-999
>
>       mu = 0 ; set the value to see how anomalies are significantly
> different from zero
>
>       tval = (compos_mera - mu)/where(Scom.ne.0, Scom, Scom at _FillValue)
> ;avoid diving by zero
>
>      abstval= abs(tval)
>
>     ;see table ttest 0.05 2-tailed
>
>       cv = 1.960 ;critival value according to the tables
>
>
>
>
>
>     ;-------Starting plot------
>
>
>
>       res                = True              ; plot mods desired
>
>       res at mpProjection   = "LambertConformal"; choose projection
>
>       res at mpFillOn       = False             ; turn off map fill
>
>       res at cnFillOn       = True              ; turn on color
>
>       res at cnLinesOn      = False             ; turn off contour lines
>
>       res at lbLabelBarOn   = True
>
>       res at gsnDraw        = False
>
>       res at gsnFrame       = False
>
>       res at gsnAddCyclic = False             ; regional plot
>
>       res at gsnMaximize  = True              ; enlarge plot
>
>       res at mpMinLatF    = 30                ; min lat to mask
>
>       res at mpMaxLatF    = 75                ; max lat to mask
>
>       res at mpMinLonF    = -20               ; min lon to mask
>
>       res at mpMaxLonF    = 40                ; max lon to mask
>
>       res at gsnMaskLambertConformal = True            ; turn on lc masking
>
>       res at gsnMaskLambertConformalOutlineOn  = False ; turns off outline
>
>
>
>   ;----Plot 2plot (significant values )----
>
>       ; generate shadow plot to overlay
>
>       res2 = True
>
>       res2 at gsnAddCyclic = False
>
>       res2 at gsnDraw = False
>
>       res2 at gsnFrame = False
>
>       res2 at cnInfoLabelOn = False
>
>       res2 at cnLinesOn      = False       ; do not draw contour lines
>
>       res2 at cnFillScaleF = 0.9
>
>
>
>       opt = True
>
>       opt at gsnShadeFillType = "pattern"
>
>       opt at gsnShadeHigh = 10
>
>
>
>
>
>       plot= gsn_csm_contour_map(wks, compos_mera,res)
>
>       plot2 = gsn_csm_contour(wks,abstval,res2)
>
>       plot2= gsn_contour_shade(plot2,-999,cv,opt)
>
>
>
>       overlay (plot, plot2)
>
>
>
>
>
> I also tried to computed the p-values and then make the plot, as follows:
>
>
>
>       dim_s = dimsizes(tval) ;lat x lon
>
>       df = new((/dim_s(0),dim_s(1)/),"integer")
>
>       df = n-1
>
>       beta_b = new((/dim_s(0),dim_s(1)/),"float")    ; preallocate space
> for beta_b
>
>       beta_b = 0.5                                                    ;
> set entire beta_b array to 0.5, the      suggested value of beta_b
>
>       ; according to betainc documentation
>
>
>
>       prob = betainc( df/(df+tval^2), df/2.0, beta_b)
>
>       ; Now set up for significant at 0.05
>
>
>
>
>
>       opt = True
>
>       opt at gsnShadeFillType = "pattern"
>
>       opt at gsnShadeLow = 10
>
>
>
>       plot= gsn_csm_contour_map(wks,compos_mera,res)
>
>       plot2 = gsn_csm_contour(wks,prob,res2)
>
>       plot2= gsn_contour_shade(plot2,0.05,-999,opt)
>
>
>
> Both ways should be OK, am I wrong? What am I missing here, because
> looking at the values, there are significant values, but I don't know why I
> can't see it.
>
>
>
>
>
> Also, regarding my other question, if I want to use bootstrap for showing
> significant anomalies…anyone could give an idea about how to use it? I was
> wondering if there would be any example about that.
>
>
>
>
> Thanks again!
>
>
>
> Best
>
>
>
> Noelia.
>
>
>
> _______________________________________________
> 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/20161020/49369b57/attachment.html 


More information about the ncl-talk mailing list