Re: MJO clivar

From: juki juki <juky_emc2_at_nyahnyahspammersnyahnyah>
Date: Fri Jun 01 2012 - 17:57:11 MDT

I have checked, print(xBegin), print(yBegin), print(pc), and there is no  _FillValue/missing value there. However, when I change the period of plotting from > ymdStrt = 20110101 ; start yyyymmdd > ymdLast = 20111231 ; last To  ymdStrt = 19961016                         ; start yyyymmdd  ymdLast = 19970415                         ; last   As in example (http://www.ncl.ucar.edu/Applications/Scripts/mjoclivar_15.ncl). However, the result of MJO phase plot is tottaly different from the example (see attached file). I don't know the reason, probably some friends here have idea about it. The plot is in opposite with plot in http://www.ncl.ucar.edu/Applications/Scripts/mjoclivar_15.ncl, in which in the example Dec is within Phase 7 and 6, 5 and 4, but in my plot it is within 3,2,1,8. Thanks for sharing, JuKy ________________________________ From: Dennis Shea <shea_at_ucar.edu> To: juki juki <juky_emc2_at_yahoo.com> Cc: "ncl-talk_at_ucar.edu" <ncl-talk_at_ucar.edu> Sent: Friday, June 1, 2012 1:24 PM Subject: Re: [ncl-talk] MJO clivar You can try debugging yourself by printing values *prior* to the statement in question. If the following is in error print(xBegin) print(yBegin) print(pc) Maybe one of them is _FillValue? plot@$unique_string("dum")$ = gsn_add_polyline(wks, \       plot, (/xBegin,pc1(nt)/), (/yBegin,pc2(nt)/), plLine)) There is no "ismissing" in the driver script. Good luck On 5/31/12 5:27 PM, juki juki wrote: > Thanks for nice suggestion Dennis, it works now. > > However, allow me to ask another thing in plotting MJOclivar. > > Question-1: I try to run mjoclivar_15.ncl, however I got the following > error: > > fatal:The result of the conditional expression yields a missing > value. NCL can not determine branch, see ismissing function > > fatal:Execute: Error occurred at or near line 115 in mjoclivar_15.ncl > (the following line: plot@$unique_string("dum")$ = gsn_add_polyline(wks, > plot, (/xBegin,pc1(nt)/), (/yBegin,pc2(nt)/), plLine)) > > I didn't change much the available code, only the input data and > start-ending time. The complete code is: > > -- > 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/diagnostics_cam.ncl" > > begin > ymdStrt = 20110101 ; start yyyymmdd > ymdLast = 20111231 ; last > > pltDir = "./" ; plot directory > pltType = "ps" > pltName = "mjoclivar15" ; yrStrt+"_"+yrLast > > pltMovie= False ; animation > pltTitle= "MJO Phase: 15S-15N: "+ymdStrt+"-"+ymdLast > ;*********************************************************** > ; Open PC components file created in 'mjo_14.ncl' > ;*********************************************************** > diri = "e:/RData/MJO_cal/Anom/" ; input directory > fMJO = "MJO_PC_INDEX.nc" ; created in mjo_14.ncl > f = addfile (diri+fMJO, "r") > > ;*********************************************************** > ; Find the indices corresponding to the start/end times > ;*********************************************************** > TIME = f->time ; days since ... > YMD = cd_calendar(TIME, -2) ; entire (time,6) > > iStrt = ind(YMD.eq.ymdStrt) ; index start > iLast = ind(YMD.eq.ymdLast) ; index last > delete(TIME) > delete(YMD ) > > ;*********************************************************** > ; Read the data for the desired period > ;*********************************************************** > pc1 = f->PC1(iStrt:iLast) > pc2 = f->PC2(iStrt:iLast) > mjo_indx= f->MJO_INDEX(iStrt:iLast) > > time = f->time(iStrt:iLast) > ymdhms = cd_calendar(time, 0) > > ntim = dimsizes( time ) > ; print(ymdhms) > > ;------------------------------------------------------------ > ; PLOT > ;------------------------------------------------------------ > > opt = True ; Background options > ;opt_at_gsnMaximize = True ; make large > opt_at_tiMainString = pltTitle > > plMark = True ; poly marker > plMark_at_gsMarkerIndex = 16 ; solid circle > plMark_at_gsMarkerSizeF = 0.005 > plMark_at_gsMarkerThicknessF = 1 > > plLine = True ; line segments > plLine_at_gsLineThicknessF = 1.0 ; 1.0 is default > > txres = True > txres_at_txFontHeightF = 0.010 ; size of font for printed day > > namMonth = (/ "Jan","Feb","Mar","Apr","May","June" \ > ,"July","Aug","Sep","Oct","Nov","Dec" /) > > colMonth = (/2,3,5,6,7,8,10,11,12,13,18,20/) ; indices into color table > > imon = floattoint( ymdhms(:,1) ) ; convenience > iday = floattoint( ymdhms(:,2) ) ; sunscripts must be integer > print(colMonth) > > pltPath = pltDir+pltName > if (.not.pltMovie) then > wks = gsn_open_wks(pltType, pltPath) ; open workstation > gsn_define_colormap(wks,"radar_1") > end if > > plot = mjo_phase_background(wks, opt) ; generic phase space background > xBegin= pc1(0) ; need for start of the line > yBegin= pc2(0) > plMark_at_gsMarkerColor = "black" ; indicate initial point > plMark_at_gsMarkerSizeF = 2.5*plMark_at_gsMarkerSizeF ; make larger > plot@$unique_string("dum")$ = gsn_add_polymarker(wks, plot, xBegin, > yBegin, plMark) > plMark_at_gsMarkerSizeF = plMark_at_gsMarkerSizeF/2.5 ; reset > > nMon = 0 > monInfo = new ((/12,2/),"string") > monInfo(nMon,0) = namMonth(imon(0)-1) > monInfo(nMon,1) = colMonth(imon(0)-1) > label_opt = 5 ; label every # day 0 = don't label days > label_color = True ; draw month label with its proper color > do nt=1,ntim-1 > if (pltMovie) then > ext = "_"+sprinti("%4.0i", nt ) > wks = gsn_open_wks(pltType,pltName+ext) > gsn_define_colormap(wks,"radar_1") > end if > ; color changes w month > plLine_at_gsLineColor = colMonth(imon(nt)-1) ; -1 is cuz NCL is 0-based > plot@$unique_string("dum")$ = gsn_add_polyline(wks, plot, > (/xBegin,pc1(nt)/), (/yBegin,pc2(nt)/), plLine) > if (label_opt.eq.0) then > plMark_at_gsMarkerColor = plLine_at_gsLineColor ; same as line color > plot@$unique_string("dum")$ = gsn_add_polymarker(wks, plot, xBegin, > yBegin, plMark) > else > if (iday(nt)%label_opt.eq.0) then > txres_at_txFontColor = "black" > plot@$unique_string("dum")$ = gsn_add_text(wks, plot, iday(nt)+"", > xBegin, yBegin, txres) > else ; marker only > plMark_at_gsMarkerColor = plLine_at_gsLineColor ; same as line color > plot@$unique_string("dum")$ = gsn_add_polymarker(wks, plot, xBegin, > yBegin, plMark) > end if > end if > > if (iday(nt).eq.1) then > nMon = nMon+1 > monInfo(nMon,0) = namMonth(imon(nt)-1) > monInfo(nMon,1) = colMonth(imon(nt)-1) > end if > > if (pltMovie) then > draw(plot) > frame(wks) > end if > > xBegin= pc1(nt) > yBegin= pc2(nt) > end do > > plMark_at_gsMarkerColor = "black" ; indicate last point > plMark_at_gsMarkerSizeF = 2.5*plMark_at_gsMarkerSizeF ; make larger > plot@$unique_string("dum")$ = gsn_add_polymarker(wks, plot, xBegin, > yBegin, plMark) > > if (.not.pltMovie) then > if (label_color) then ; fancy coloring of months > getvalues plot > "trXMinF" : xmin > end getvalues > xinc = (xmin*-2) / (nMon+1+2.) ; total number months = nMon+1. +2 > ; for spacing on ends > txres_at_txJust = "CenterLeft" > txres_at_txFontHeightF = 0.013 ; size of font for printed month > xstart = xmin+(1.25*xinc) > if (nMon.gt.0) then > do n=0, nMon > txres_at_txFontColor = monInfo(n,1) > plot@$unique_string("dum")$ = gsn_add_text(wks, plot, monInfo(n,0) > ,xstart , -3.75, txres) > xstart = xstart+xinc > end do > end if > end if > draw(plot) > frame(wks) > end if > end > ---- > > Question 2: regarding the mjoclivar_16.ncl. I run the code to plot MJO > Phase during 2011. it run successfully. However, I think the result is > little bit abnormal because the negative anomaly of OLR propagates > westward. It is commonly known that the MJO propagates estward. I send > the plot example in the email. The code for plotting is: > > ;*********************************************************** > ; Generate life cycle composites based upon daily phase space > ; If the MJO_INDEX is < 1.0 it is not included > ;*********************************************************** > 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 > latS = -15 > latN = 15 > > ymdStrt = 20110101 ; start yyyymmdd > ymdLast = 20111231 ; last > > yrStrt = ymdStrt/10000 > yrLast = ymdLast/10000 > > pltSubTitle = "Anomalous: OLR, U850, V850" > > pltDir = "./" ; plot directory > pltType = "ps" > pltName = "mjoclivar" ; yrStrt+"_"+yrLast > diri = "e:/RData/MJO_cal/Anom/" ; input directory > > filo = "olr.day.anomalies.2001-2011.nc" > filu = "uwnd.day.850.anomalies.2001-2011.nc" > filv = "vwnd.day.850.anomalies.2001-2011.nc" > > ;************************************************ > ; create BandPass Filter > ;************************************************ > ihp = 2 ; bpf=>band pass filter > nWgt = 201 > sigma = 1.0 ; Lanczos sigma > fca = 1./100. > fcb = 1./20. > wgt = filwgts_lanczos (nWgt, ihp, fca, fcb, sigma ) > > ;*********************************************************** > ; Find the indicies (subscripts) corresponding to the start/end times > ;*********************************************************** > > f = addfile (diri+filu , "r") > TIME = f->time ; days since ... > YMD = cd_calendar(TIME, -2) ; entire (time,6) > > iStrt = ind(YMD.eq.ymdStrt) ; index start > iLast = ind(YMD.eq.ymdLast) ; index last > delete(TIME) > delete(YMD ) > > time = f->time(iStrt:iLast) ; days since ... > u = f->UWND_anom(iStrt:iLast,{latS:latN},:) > ;*********************************************************** > ; Read anomalies frpm other fields > ;*********************************************************** > f = addfile (diri+filv , "r") > v = f->VWND_anom(iStrt:iLast,{latS:latN},:) > > f = addfile (diri+filo , "r") > x = f->OLR_anom(iStrt:iLast,{latS:latN},:) > > dimx = dimsizes( x ) > ntim = dimx(0) > nlat = dimx(1) > mlon = dimx(2) > ;************************************************ > ; Apply the band pass filter to the original anomalies > ;************************************************ > x = wgt_runave_leftdim (x, wgt, 0) > u = wgt_runave_leftdim (u, wgt, 0) > v = wgt_runave_leftdim (v, wgt, 0) > > ;*********************************************************** > ; Open PC components file created in 'mjo_14.ncl' > ;*********************************************************** > diri = "e:/RData/MJO_cal/Anom/" ; input directory > fMJO = "MJO_PC_INDEX.nc" ; created in mjo_14.ncl > f = addfile (diri+fMJO, "r") > > ;*********************************************************** > ; Find the indices corresponding to the start/end times > ;*********************************************************** > TIME = f->time ; days since ... > YMD = cd_calendar(TIME, -2) ; entire (time,6) > printVarSummary(TIME) > > iStrt = ind(YMD.eq.ymdStrt) ; index start > iLast = ind(YMD.eq.ymdLast) ; index last > delete(TIME) > delete(YMD ) > > ;*********************************************************** > ; Read the data for the desired period > ;*********************************************************** > pc1 = f->PC1(iStrt:iLast) > pc2 = f->PC2(iStrt:iLast) > mjo_indx= f->MJO_INDEX(iStrt:iLast) > > time = f->time(iStrt:iLast) > ymdhms = cd_calendar(time, 0) > > imon = floattoint( ymdhms(:,1) ) ; convenience > iday = floattoint( ymdhms(:,2) ) ; subscripts must be integer > > ;*********************************************************** > ; Place each array into an appropriate array > ;*********************************************************** > nPhase = 8 > angBnd = new( (/2,nPhase/), "float") > angBnd(0,:) = fspan( 0,315,nPhase) > angBnd(1,:) = fspan( 45,360,nPhase) > > r2d = 180./(4.*atan(1.0)) > ang = atan2(pc2,pc1)*r2d ; phase space > nn = ind(ang.lt.0) > ang(nn) = ang(nn) + 360 ; make 0 to 360 > > nDays = new (nPhase, "integer") > pLabel = "P"+ispan(1,nPhase,1)+": " > > ;------------------------------------------------------------ > ; PLOTS > ;------------------------------------------------------------ > pltPath = pltDir+pltName > > wks = gsn_open_wks(pltType,pltPath) > gsn_define_colormap(wks,"ViBlGrWhYeOrRe") > plot = new(nPhase,graphic) ; create graphic array > > res = True > res_at_gsnDraw = False ; don't draw yet > res_at_gsnFrame = False ; don't advance frame yet > res_at_gsnSpreadColors = True ; spread out color table > res_at_mpFillOn = False ; turn off map fill > res_at_mpMinLatF = latS ; zoom in on map > res_at_mpMaxLatF = latN > res_at_mpCenterLonF = 210. > res_at_cnFillOn = True ; turn on color fill > res_at_cnLinesOn = False ; True is default > res_at_cnLineLabelsOn = False ; True is default > res_at_lbLabelBarOn = False ; turn off individual lb's > res_at_gsnScalarContour = True ; contour 3rd array > res_at_gsnMajorLatSpacing = 15 > res_at_gsnMajorLonSpacing = 60 > res_at_tmXBLabelFontHeightF = 0.01 > res_at_tmYLLabelFontHeightF = 0.01 > > ; common contours > ;mnmxint = nice_mnmxintvl( min(x) , max(x), 16, False) > res_at_cnLevelSelectionMode = "ManualLevels" > res_at_cnMinLevelValF = -40 ; -100; mnmxint(0) > res_at_cnMaxLevelValF = 40 ; 80; mnmxint(1) > res_at_cnLevelSpacingF = 5 ; 20; mnmxint(2) > ;print(res) > > res_at_vcMinDistanceF = 0.01 ; thin the vector density > res_at_vcRefMagnitudeF = 2.0 ; define vector ref mag > res_at_vcRefLengthF = 0.025 ; define length of vec ref > res_at_vcRefAnnoOrthogonalPosF = -1.0 ; move ref vector > res_at_vcRefAnnoArrowLineColor = "black" ; change ref vector color > res_at_vcRefAnnoArrowUseVecColor = False ; don't use vec color for ref > > ; panel plot only resources > resP = True ; modify the panel plot > resP_at_gsnMaximize = True ; large format > resP_at_gsnPanelLabelBar = True ; add common colorbar > resP_at_lbLabelAutoStride = True ; auto stride on labels > resP_at_lbLabelFontHeightF = 0.01 > resP_at_gsnPanelBottom = 0.05 ; add some space at bottom > resP_at_pmLabelBarWidthF = 0.8 ; label bar width > resP_at_pmLabelBarHeightF = 0.05 > resP_at_gsnPanelFigureStringsFontHeightF = 0.0125 ; bit larger than default > ;resP_at_pmLabelBarOrthogonalPosF = 0.015 ; move labelbar up a bit > > txres = True > txres_at_txFontHeightF = 0.01 > txid = gsn_create_text(wks, pltSubTitle, txres) > > amres = True > ;amres_at_amParallelPosF = 0.575 > amres_at_amOrthogonalPosF = 0.75 > amres_at_amJust = "CenterCenter" > ;amres_at_amResizeNotify = True > > ;******************************************* > ; Loop over each phase > ;******************************************* > res_at_gsnLeftString = "" > res_at_gsnRightString = "" > do nSeason=1,2 > if (nSeason.eq.1) then > resP_at_txString = yrStrt+"-"+yrLast+": Jan to Dec" > else > resP_at_txString = yrStrt+"-"+yrLast+": Jan to Dec" > end if > do n=0,nPhase-1 > if (nSeason.eq.1) then > nt = ind(mjo_indx.gt.1.0 .and. \ > (imon.ge.1 .and. imon.le.12).and. \ > ang.ge.angBnd(0,n) .and. ang.lt.angBnd(1,n)) > else > nt = ind(mjo_indx.gt.1.0 .and. \ > (imon.ge.1 .or. imon.le. 12).and. \ > ang.ge.angBnd(0,n) .and. ang.lt.angBnd(1,n)) > end if > if (.not.all(ismissing(nt))) then > xAvg = dim_avg_Wrap( x(lat|:,lon|:,time|nt) ) > uAvg = dim_avg_Wrap( u(lat|:,lon|:,time|nt) ) > vAvg = dim_avg_Wrap( v(lat|:,lon|:,time|nt) ) > nDays(n) = dimsizes(nt) > > res_at_tmXBLabelsOn = False ; do not draw lon labels > res_at_tmXBOn = False ; lon tickmarks > if (n.eq.(nPhase-1)) then ; > res_at_tmXBLabelsOn = True ; draw lon labels > res_at_tmXBOn = True ; tickmarks > end if > > plot(n) = gsn_csm_vector_scalar_map_ce(wks,uAvg,vAvg,xAvg,res) > end if > delete(nt) ; will change next iteration > end do > > ;;ann3 = gsn_add_annotation(plot(0), txid, amres) > resP_at_gsnPanelFigureStrings= pLabel+nDays > gsn_panel(wks,plot,(/nPhase,1/),resP) ; now draw as one plot > end do > > system("gv "+pltPath+"."+pltType) > end > > -------------------- > > Best regards, > JuKY > > > >

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk

Received on Fri Jun 1 17:57:29 2012

This archive was generated by hypermail 2.1.8 : Wed Jun 06 2012 - 15:17:44 MDT