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