[ncl-talk] How to plot t-test figure, involve multiinput file?

Steven Kong kongksk at gmail.com
Tue Nov 3 19:54:32 MST 2015


Hi all,

I would like to plot t-test figure, between the average of future and the
average of the present periods. Both period consist of 2 continuous days as
follow:

Future: 01 to 02 January 2100
Present: 01 to 02 Janaury 2010

Could anyone help me on this? Your help is highly appreciated.


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;script;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/wrf/WRFUserARW.ncl"

begin
   a1 = addfile("./JAN2100/01-05/wrfout_d02_2100-01-01_00:00:00","r")
   a2 = addfile("./JAN2100/01-05/wrfout_d02_2100-01-02_00:00:00","r")

   b1 = addfile("./JAN2010/01-05/wrfout_d02_2010-01-01_00:00:00","r")
   b2 = addfile("./JAN2010/01-05/wrfout_d02_2010-01-02_00:00:00","r")

  wks = gsn_open_wks("x11","T-test1-90%")
        gsn_define_colormap(wks,"BlAqGrYeOrReVi200")            ; Create a
plot workstation

  opts = True                                      ; Set some Basic Plot
options
  opts at MainTitle = "GEOGRID FIELDS"
  opts at InitTime = False                            ; Do not plot time or
footers
  opts at Footer = False

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;Get the
Variables;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

tempa1 = a1->T2
tempa2 = a2->T2

tempb1 = b1->T2
tempb2 = b2->T2

;;;;;;;;;;;;;;;;;;;;;;;;;;;Calculate average and variance for
Future;;;;;;;;;;;;;;;;;;;;

aveX1 = dim_avg_n_Wrap(tempa1,0)  ; average over the 0th dim
varX1 = dim_variance_n_Wrap(tempa1,0) ; compute variance

aveX2 = dim_avg_n_Wrap(tempa2,0)  ; average over the 0th dim
varX2 = dim_variance_n_Wrap(tempa2,0) ; compute variance

;;;;;;;;;;;;;;;;;;;;;;;;;;;Calculate average and variance for
Present;;;;;;;;;;;;;;;;;;;;

aveY1 = dim_avg_n_Wrap(tempb1,0)  ; average over the 0th dim
varY1 = dim_variance_n_Wrap(tempb1,0) ; compute variance

aveY2 = dim_avg_n_Wrap(tempb2,0)  ; average over the 0th dim
varY2 = dim_variance_n_Wrap(tempb2,0) ; compute variance

;;;;;;;;;;;;;;;;;;;;;;;;;;Do T-Test for 1st day and 2nd
day;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

alphat1 = 100.*(1. - ttest(aveX1,varX1,24, aveY1,varY1,24, True, False))
aveX1 = where(alphat1.lt.90.,aveX1 at _FillValue, aveX1)

alphat2 = 100.*(1. - ttest(aveX2,varX2,24, aveY2,varY2,24, True, False))
aveX2 = where(alphat2.lt.90.,aveX2 at _FillValue, aveX2)

;;;;;;;;;;;;;;;;;;;;;;;;;;Do T-Test for the average of 1st and 2nd
days;;;;;;;;;;;;;;;;;;

result = (alphat1 + alphat2)/2
;result = (aveX1 + aveX2)/2
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20151104/cd0f856d/attachment.html 


More information about the ncl-talk mailing list