[ncl-talk] Probability Calculation

Adam Phillips asphilli at ucar.edu
Fri Aug 28 09:36:31 MDT 2015


Hi Ipshita,
It looks to me like you cut and pasted different parts of your script for
the sake of emailing but I think the group would be hard pressed to
diagnose your issue with what you provided. What do you mean by "the
probability function is not working"? Are you getting any error messages?
As you don't show how you are forming your prob_djf array I don't think
anyone will be able to assist.You also pass a 3-dimensional array
(corr_djf) into gsn_csm_contour_map_ce but that plotting function expects a
2D array.

Please provide more information so that the group can assist. As always
please respond to the ncl-talk email list with any future inquiries.
Adam

On Thu, Aug 27, 2015 at 12:07 PM, Ipshita Majhi <ipmajhi at alaska.edu> wrote:

> Dear NCL,
>
> I have been working on creating a plot with correlation and probability
> function. I am able to do it with no lag between two variables, but when I
> introduce lag, the probability function is not working, I am not sure why
> that is, it will be great if you could guide me on this:-
>
> ;This is for correlating JJAS monthly precp with JJAS temperature with lag
>
> ;******************************************************
> 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"
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/shea_util.ncl"
> ;*******************************************************
>
> ;=============================================
> ; Reading data
> ;=============================================
>
> a=addfile("~/Documents/SST/Monthly/sst.mnmean.v4.nc","r")
>
> ;==============================================
>
> JJAS_1871_2012
> =asciiread("~/Documents/SST/Monthly/jjas_1871_2012.txt",(/142,1/),"float")
> ;Extracting JJAS for 1967 to 2012
>
> JJAS_1967_2012=JJAS_1871_2012(96:141,0)
> print(dimsizes(JJAS_1967_2012))
>
> e=transpose(transpose(JJAS_1967_2012))
> ;print(dimsizes(e))
>
> ;=============================================
>
> ;For some months around september it is better to
> ;=============================================
>  ;The dataset goes from 1854-2015
>   sst=a->sst
> ; copy meta data and coordinate variables using contributed functions
>  copy_VarAtts(a,sst)
>  copy_VarCoords_1(a,sst)
> ;============================================
>
> ;Extracting 1967-2012 for SST
> sst_1967_2012=sst(1367:1918,:,:)
>
>
> copy_VarAtts(sst,sst_1967_2012)
> copy_VarCoords_1(a,sst_1967_2012)
>
> ;============================================
> ;Seasonal three month average
>
>
>  sst_djf=month_to_season(sst_1967_2012, "DJF")
>
> ;==============================================
> ;Copying Attributes and Coordinates
>
> copy_VarAtts(sst_1967_2012,sst_djf)
> copy_VarCoords_1(sst_1967_2012,sst_djf)
> ;Calculating correlation
>
>
>
> djf_reorder=sst_djf(lat|:,lon|:,time|:)
>
> ;Calculating Correlation Coefficient
>
> ;Months with Lag
> corr_djf=esccr(JJAS_1967_2012,djf_reorder,1)
>
> ;========================================
> ;Probability
> x=corr_djf(:,:,1)
> print(dimsizes(x))
> ;==============================
> ; Now plotting the correlation
>
> ;===========================================
>
> ; Now plotting the correlation
>
>
>     wks  = gsn_open_wks("pdf","DJF_sst_jjas_cor_prob_sig_lag")
>   gsn_define_colormap(wks,"BlWhRe")              ; choose colormap
>
>   res                      = True                ; make plot mods
>   res at gsnDraw = False
>   res at gsnFrame = False
>   res at cnFillOn             = True                ; turn on color
>   res at gsnSpreadColors      = True                ; use full colormap
>   res at lbLabelAutoStride    = True         ; automatic lb label stride
>
>   res at cnLinesOn            = False               ; turn off contour lines
>   res at cnLevelSelectionMode = "ManualLevels" ; manually set cnlev
>   res at cnMinLevelValF       = -1.                 ; min level
>   res at cnMaxLevelValF       =  1.                 ; max level
>   res at cnLevelSpacingF      = .1                  ; contour level spacing
>
>   lag                      = 0
>   res at tiMainString         = "DJF SST with JJAS rainfall"
>   plotA = gsn_csm_contour_map_ce(wks,corr_djf,res)
>
>  ; Significance plot on top of correlation plot
>  ;========================= PLOT 2 =========
>   res2 = True                            ; res2 probability plots
>
>   res2 at gsnDraw             = False       ; Do not draw plot
>   res2 at gsnFrame            = False       ; Do not advance frome
>   res2 at cnFillOn = True                   ; turn on color/pattern fill
>   res2 at cnMonoFillPattern = False   ; allow different patterns
>   res2 at cnMonoFillColor = True       ; only use one color (black)
>
>   res2 at cnLevelSelectionMode = "ExplicitLevels" ; set explicit cnlev
>   res2 at cnLevels   = (/.90/)    ; only have 1 contour level
>   res2 at cnFillPatterns = (/-1,17/) ; don't fill <0.95, stipple >=0.95
>
>   res2 at gsnAddCyclic = True   ; may or may not be needed
>
>   res2 at cnInfoLabelOn       = False       ; turn off info label
>
>   res2 at cnLinesOn           = False       ; do not draw contour lines
>   res2 at cnLineLabelsOn      = False    ; do not draw contour labels
>
>   res2 at cnFillScaleF        = 0.5         ; add extra density
>
>   printMinMax(prob_djf,0)   ; check to make sure values are
>                                              ; between 0 and 1.
>
>   plot2   = gsn_csm_contour(wks,prob_djf, res2)
>   overlay (plotA, plot2)
>
>   draw (plotA)
>   frame(wks)
> ;=================================================
>
> Best Regards
> Ipshita
>
>
> _______________________________________________
> 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>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20150828/26fd7a43/attachment.html 


More information about the ncl-talk mailing list