<div dir="ltr"><div class="gmail_default" style="font-size:small">Jesús,</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">It's a bit hard to debug your script because you are setting *lots* of resources and it's hard to follow which plots they are applying to.</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">The error says the third argument to "fspan" is equal to 0 or 1, which is not allowed. I believe this is occurring on this line:<br>
<p class=""><span class=""> opts_xy@</span><span class="">tmXBValues</span><span class=""> = </span><span class="">fspan</span><span class="">(0,xspan,nx)</span></p><p class=""><span class="">so you need to look at how "nx" is being calculated:<br>
</span></p><p class=""><span class=""> </span><span class="">nx</span><span class=""> = </span><span class="">floattoint</span><span class="">((xmax-xmin)/2+1)</span></p></div><div class="gmail_default" style="font-size:small">There's probably an issue with xmin and/or xmax. Maybe they are both equal?</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">--Mary</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small"><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Mar 30, 2016 at 7:37 AM, Jesús Garcia Rosales <span dir="ltr"><<a href="mailto:jesus21gr@gmail.com" target="_blank">jesus21gr@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi ncl users,<div>I have a problem when I want to plot longitude in axis x in my cross section. Please help me.</div><div><br></div><div><br></div><div>The error that appears is:</div><div><br></div><div><div>fatal:fspan: number of elements parameter is less-than-or-equal-to one, can't continue</div><div>fatal:["Execute.c":8575]:Execute: Error occurred at or near line 281 in file prueba.ncl</div></div><div><br></div><div><br></div><div>This is my script:</div><div><br></div><div><div><br></div><div>load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl" </div><div>load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"</div><div>load "$NCARG_ROOT/lib/ncarg/nclscripts/wrf/WRFUserARW.ncl"</div><div><br></div><div>begin</div><div>;</div><div>; The WRF ARW input file. </div><div>; This needs to have a ".nc" appended, so just do it.</div><div> a = addfile("/media/usuario/TOSHIBA/WRF_alan/9km/exp_re/<a href="http://wrfout_2002F.cu_betts.3km.nc" target="_blank">wrfout_2002F.cu_betts.3km.nc</a>","r")</div><div><br></div><div><br></div><div> ; We generate plots, but what kind do we prefer?</div><div> type = "x11"</div><div>; type = "pdf"</div><div>; type = "ps"</div><div>; type = "ncgm"</div><div>; type = "png"</div><div> wks = gsn_open_wks(type,"cross_section_2")</div><div> ;gsn_define_colormap(wks,"BlueWhiteOrangeRed")</div><div> gsn_define_colormap(wks,"WhiteBlueGreenYellowRed") </div><div> ; wks2 = gsn_open_wks(type,"plan_map")</div><div><br></div><div><br></div><div>;;;;;;;;;; Dominio</div><div>; si se quiere disminuir el dominio</div><div>bordh=8 ;8 ;h=haut(hight)</div><div>bordb= 20 ;20 ;b=bas(bajo)</div><div>bordd= 15 ;15 ;d=droite(derecha)</div><div>bordg= 17;17 ;g=gauche (izquierda)</div><div><br></div><div><br></div><div><br></div><div>tmin= 72 ; la seleccion empieza el 01/01/2011 a las 00hs (UTC)</div><div>tmax= 744 ; la seleccion se termina el 31/01/2011 a las 21hs (UTC)</div><div><br></div><div><br></div><div><br></div><div>; Set some basic resources</div><div> res = True</div><div> res@MainTitle = "Hurricane Irene 27 km WRF (P1)"</div><div> res@Footer = False</div><div> </div><div> pltres = True</div><div><br></div><div>; Set the path the cross section will take</div><div> lat_start = -12.</div><div> lon_start = -76.00</div><div> lat_end = -12.</div><div> lon_end = -74.5</div><div><br></div><div>; Limited vertical extent? (True or False)</div><div>LimitedExtent = False</div><div>z_top = 10. ; top in km (ignored if above is False)</div><div><br></div><div><br></div><div><br></div><div>;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;</div><div><br></div><div> times = wrf_user_getvar(a,"times",-1) ; get times in the file</div><div> ntimes = dimsizes(times) ; number of times in the file</div><div> FirstTime = True</div><div><br></div><div> mdims = getfilevardimsizes(a,"P") ; get some dimension sizes for the file</div><div> nd = dimsizes(mdims)</div><div><br></div><div>;---------------------------------------------------------------</div><div><br></div><div> FirstTimeMap = True</div><div><br></div><div> ; do it = 0,ntimes-1,72 ; TIME LOOP</div><div><br></div><div> ; print("Working on time: " + times(it) )</div><div> ; res@TimeLabel = times(it) ; Set Valid time to use on plots</div><div><br></div><div> ; tc = wrf_user_getvar(a,"tc",it) ; temperature (deg C)</div><div> ; rh = wrf_user_getvar(a,"rh",it) ; relative humidity (%)</div><div> z = wrf_user_getvar(a, "z",0) ; grid point height (m)</div><div> p = wrf_user_getvar(a,"pressure",0) ; full model pressure (hPa)</div><div> u = wrf_user_getvar(a,"ua",72) ; x-component wind (m/s)</div><div> v = wrf_user_getvar(a,"va",72) ; y-component wind (m/s)</div><div> lat = wrf_user_getvar(a,"lat",0) ; latitude grid</div><div> lon = wrf_user_getvar(a,"lon",0) ; longitude grid</div><div> ter = wrf_user_getvar(a,"HGT",0) ; model terrain height (m)</div><div> w = wrf_user_getvar(a,"wa",72)</div><div> q= wrf_user_getvar(a,"QVAPOR",72)*1000</div><div><br></div><div><br></div><div>; Compute the relative vorticity from the u and v wind fields</div><div><br></div><div><br></div><div>printVarSummary(p)</div><div><br></div><div>printVarSummary(u)</div><div>printVarSummary(lat)</div><div><br></div><div>printVarSummary(w)</div><div><br></div><div>;tim_u=u(tmin:tmax,:,:,:)</div><div>;tim_v=v(tmin:tmax,:,:,:)</div><div><br></div><div><br></div><div>;printVarSummary(tim_u)</div><div><br></div><div><br></div><div>;vm=dim_avg_n(v,0)</div><div>;um=dim_avg_n(u,0)</div><div>;wm=dim_avg_n(w,0)</div><div><br></div><div>; Sacando los promedios de las varaibles u,v,w</div><div><br></div><div>;um=dim_avg_n(u(tmin:tmax,:,:,:),0)</div><div>;vm=dim_avg_n(v(tmin:tmax,:,:,:),0)</div><div>;wm=dim_avg_n(w(tmin:tmax,:,:,:),0)</div><div>;qm=dim_avg_n(q(tmin:tmax,:,:,:),0)</div><div><br></div><div>vort = uv2vr_cfd(u,v,lat(:,0),lon(0,:),2)</div><div>vort@description = "Relative Vorticity"</div><div><br></div><div><br></div><div>vort@units = "1/s"</div><div><br></div><div> if ( FirstTime ) then ; get height info for labels</div><div> zmin = 0. ; bottom of plot</div><div><br></div><div> if ( LimitedExtent ) then</div><div> angle = 0.</div><div> zmax = z_top</div><div> nz = floattoint(zmax + 1)</div><div> else</div><div> angle = 0.</div><div> zmax = max(z) / 1000.</div><div> nz = floattoint(zmax / 2 + 1)</div><div> FirstTime = False</div><div> end if</div><div> end if</div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div>;---------------------------------------------------------------</div><div><br></div><div>; Plot a cross session that run from point A to point B</div><div><br></div><div> ; starting point for cross-section</div><div> llres = True</div><div> llres@ReturnInt = False</div><div> locij_a = wrf_user_ll_to_ij(a, lon_start, lat_start, llres)</div><div> locij_a = locij_a - 1 ; array pointers in NCL space</div><div> locX_a = locij_a(0)</div><div> locY_a = locij_a(1)</div><div><br></div><div> ; ending point for cross-section</div><div> locij_b = wrf_user_ll_to_ij(a, lon_end, lat_end, llres)</div><div> locij_b = locij_b - 1 ; array pointers in NCL space</div><div> locX_b = locij_b(0)</div><div> locY_b = locij_b(1)</div><div><br></div><div> plane = new(4,float)</div><div> plane = (/ locX_a,locX_b , locY_a,locY_b /) ; start x;y & end x;y point </div><div> opts = True ; start and end points specified</div><div><br></div><div><br></div><div><br></div><div><br></div><div> ;rh_plane = wrf_user_intrp3d(rh,z,"v",plane,0.,opts) ; relative humidity plane</div><div> ;tc_plane = wrf_user_intrp3d(tc,z,"v",plane,0.,opts) ; temperature plane</div><div> p_plane = wrf_user_intrp3d(p,z,"v",plane,0.,opts) ; pressure plane</div><div> vort_plane = wrf_user_intrp3d(vort,z,"v",plane,0.,opts) ; relative vorticity plane</div><div> u_plane = wrf_user_intrp3d(u,z,"v",plane,0.,opts)</div><div> w_plane = wrf_user_intrp3d(w,z,"v",plane,0.,opts)</div><div> q_plane = wrf_user_intrp3d(q,z,"v",plane,0.,opts)</div><div> </div><div>printVarSummary(u_plane)</div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div>;************************************************ </div><div>; Omega is significantly smaller than v, so we will </div><div>; scale it so that some vertical motion is visible </div><div>;************************************************ </div><div> wAve = avg(w_plane(:,:)) ; used for scaling </div><div> uAve = avg(u_plane(:,:)) </div><div> scale = fabs(uAve/wAve) </div><div> w_plane = w_plane*scale ; now scale </div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div>; w_plane=w_plane*100</div><div><br></div><div><br></div><div><br></div><div> vort_plane = vort_plane * 100000. ; normalize vorticity to 10^-5 s^-1</div><div> vort_plane@units = "10^5 s^-1"</div><div><br></div><div> dim = dimsizes(vort_plane) ; Find the data span - for use in labels</div><div> zspan = dim(0)</div><div><br></div><div><br></div><div><br></div><div><br></div><div> if ( FirstTime ) then</div><div> angle = 0.</div><div> zz = wrf_user_intrp3d(z,z,"v",plane,angle,opts)</div><div> b = ind(zz(:,0).gt.zmax*1000.)</div><div> zmax_pos = b(0) - 1</div><div> if ( abs(zz(zmax_pos,0)-zmax*1000.).lt.abs(zz(zmax_pos+1,0)-zmax*1000.) ) then</div><div> zspan = b(0) - 1</div><div><br></div><div> printVarSummary(zmax_pos)</div><div><br></div><div> else</div><div> zspan = b(0)</div><div> end if</div><div> </div><div> delete(zz)</div><div> delete(b)</div><div> FirstTime = False</div><div> end if</div><div><br></div><div><br></div><div>x_plane = wrf_user_intrp2d(lon,plane,angle,opts)</div><div> x_plane@description = "Longitude"</div><div> dimsX = dimsizes(x_plane)</div><div> xmin = x_plane(0)</div><div> xmax = x_plane(dimsX(0)-1)</div><div> xspan = dimsX(0)-1</div><div> nx = floattoint((xmax-xmin)/2+1)</div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div> ; printVarSummary(zmax_pos)</div><div><br></div><div> ; Options for XY Plots</div><div> opts_xy = res</div><div> opts_xy@tiYAxisString = "Height (km)"</div><div> opts_xy@cnMissingValPerimOn = True</div><div> opts_xy@cnMissingValFillColor = 0</div><div> opts_xy@cnMissingValFillPattern = 11</div><div> opts_xy@tmYLMode = "Explicit"</div><div> opts_xy@tmYLValues = fspan(0,zspan,nz) ; Create tick marks</div><div> opts_xy@tmYLLabels = sprintf("%.1f",fspan(zmin,zmax,nz)) ; Create labels</div><div> opts_xy@tiXAxisFontHeightF = 0.020</div><div> opts_xy@tiYAxisFontHeightF = 0.020</div><div> opts_xy@tmXBMajorLengthF = 0.02</div><div> opts_xy@tmYLMajorLengthF = 0.02</div><div> opts_xy@tmYLLabelFontHeightF = 0.015</div><div> opts_xy@PlotOrientation = p_plane@Orientation</div><div><br></div><div><br></div><div><br></div><div> printVarSummary(xspan)</div><div> printVarSummary(nx)</div><div><br></div><div><br></div><div><br></div><div> opts_xy@tmXBMode = "Explicit"</div><div> opts_xy@tmXBValues = fspan(0,xspan,nx) </div><div> opts_xy@tmXBLabels = sprintf("%.1f",fspan(xmin,xmax,nx))</div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div> ; Plotting options for vorticity</div><div> opts_vort = opts_xy</div><div> opts_vort@ContourParameters = (/ -20., 20., 0.5 /)</div><div> opts_vort@pmLabelBarOrthogonalPosF = -0.07</div><div> opts_vort@cnFillOn = True</div><div> opts_vort@cnLinesOn = False</div><div><br></div><div> ; Plotting options for Pressure</div><div> opts_p = opts_xy</div><div> opts_p@ContourParameters = (/ 0.,1000.,50. /)</div><div> opts_p@cnInfoLabelOn = False</div><div><br></div><div><br></div><div><br></div><div><br></div><div> vres = True</div><div><br></div><div> vres@gsnMaximize = True ; Maximize plot in frame</div><div> ;vres@pmLabelBarDisplayMode = "Always" ; Turn on a label bar.</div><div> ;vres@pmLabelBarWidthF = 0.075</div><div> vres@lbPerimOn = False</div><div> vres@tiMainString = "No resources set"</div><div> ;vres@NumVectors = 60</div><div> vres@Footer = False</div><div> vres@InitTime = False</div><div> vres@vcGlyphStyle = "CurlyVector";"LineArrow";"CurlyVector"</div><div> vres@vcMonoLineArrowColor = True ; color arrows based on magnitude</div><div> ;vres@vcLevelSelectionMode = "ExplicitLevels"</div><div> ;vres@vcLevels = (/5,10,15,20,25,30,35,40,45,50,55,60,65/)</div><div> ;vres@vcLevelColors = (//)</div><div> vres@vcRefLengthF = 0.1</div><div> vres@vcFillArrowWidthF = 50</div><div> vres@vcLineArrowThicknessF = 2</div><div> vres@vcMinFracLengthF = 0.5</div><div> vres@vcMinAnnoOn = True</div><div> vres@vcMinAnnoPerimOn = False</div><div> vres@vcMinAnnoString1On = False</div><div> ;vres@vcMinAnnoString2 = "0.2"</div><div> vres@vcMinAnnoFontThicknessF = 10</div><div> vres@vcMinAnnoArrowLineColor = "Black"</div><div> ;vres@vcMinAnnoArrowUseVecColor = "False "</div><div> ;vres@MainTitle = "Vertically-integrated humidity flux"</div><div> ;vres@MainTitlePos = "Center"</div><div> vres@vcMinAnnoArrowSpaceF = 4.0</div><div><br></div><div><br></div><div> </div><div><br></div><div> opts_q = res</div><div> ;opts_q@ContourParameters = (/ 10., 90., 10. /)</div><div> opts_q@pmLabelBarOrthogonalPosF = -0.1 </div><div> opts_q@cnFillOn = True</div><div> opts_q@ContourParameters = (/ .2, 10., 0.5 /)</div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div> ; Get the contour info for the rh and temp</div><div> if ( LimitedExtent ) then</div><div> contour_p = wrf_contour(a,wks,p_plane(0:zmax_pos,:),opts_p)</div><div> contour_vort = wrf_contour(a,wks,vort_plane(0:zmax_pos,:),opts_vort)</div><div> vector = wrf_vector(a,wks,u_plane(0:zmax_pos,:),w_plane(0:zmax_pos,:),vres)</div><div> contour_q = wrf_contour(a,wks,q_plane(0:zmax_pos,:),opts_q)</div><div><br></div><div><br></div><div><br></div><div> else</div><div> contour_p = wrf_contour(a,wks,p_plane,opts_p)</div><div> contour_vort = wrf_contour(a,wks,vort_plane,opts_vort)</div><div> vector = wrf_vector(a,wks,u_plane,w_plane,vres)</div><div> contour_q = wrf_contour(a,wks,q_plane,opts_q)</div><div><br></div><div> end if</div><div><br></div><div><br></div><div> ; vector = wrf_vector(a,wks,u_plane(0:zmax_pos,:),w_plane(0:zmax_pos,:),vres)</div><div> </div><div><br></div><div><br></div><div> ; MAKE PLOTS </div><div> plot = wrf_overlays(a,wks,(/contour_q,contour_p,vector/),pltres)</div><div><br></div><div><br></div><div><br></div><div>end</div></div></div>
<br>_______________________________________________<br>
ncl-talk mailing list<br>
<a href="mailto:ncl-talk@ucar.edu">ncl-talk@ucar.edu</a><br>
List instructions, subscriber options, unsubscribe:<br>
<a href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk" rel="noreferrer" target="_blank">http://mailman.ucar.edu/mailman/listinfo/ncl-talk</a><br>
<br></blockquote></div><br></div>