Re: Help with cross-section Y-axis labels

From: Chris Klich <caklich_at_nyahnyahspammersnyahnyah>
Date: Mon Feb 20 2012 - 13:35:50 MST

Hi, I've tried what was suggested below, but it seems to create 50 axis
labels. Zspan has a size of 100, so it tries to create 50 labels, every 2
labels. However, when I do print(fspan(0,zspan,nz)+"
"+sprintf("%.1f",fspan(zmin,
zmax,nz))) , it outputs:

(0) 0 0.0
(1) 11.1111 2.1
(2) 22.2222 4.2
(3) 33.3333 6.4
(4) 44.4444 8.5
(5) 55.5556 10.6
(6) 66.6667 12.7
(7) 77.7778 14.8
(8) 88.8889 17.0
(9) 100 19.1

This seems like a simple fix, but I cannot seem to figure out how to get
labels every 2km up to 18km (the model top is 19.09km).

Thanks again,
Chris

> Hi Chris,
>> opts_xy@tmYLValues =
>> fspan(0,zspan,nz) ; Create tick marks
>> opts_xy@tmYLLabels =
>> sprintf("%.1f",fspan(zmin,
>> zmax,nz)) ; Create labels
>>
>> I would recommend printing the following to see the values/labels you
>> are setting:
>> print(fspan(0,zspan,nz)+" "+sprintf("%.1f",fspan(zmin,zmax,nz)))
>>
>> (Note: The print out should match the Y-axis labels you are seeing in
>> your plot.)
>>
>> I would recommend you use ispan instead of fspan if you want labels to
>> be every 2km. You can do this with fspan as well,
>> but as you are coding generically (i.e. you are not hard-wiring things
>> in) it might be best to use ispan. For example this:
>>
>> opts_xy@tmYLValues = ispan(0,zspan,2)
>> opts_xy@tmYLLabels = opts_xy@tmYLValues ; this is assuming that the
>> value/label are the same
>>
>> Should produce labels at every 2km, labeled as such..
>> Hope that helps. If not, let ncl-talk know..
>> Adam
>>
>>
>>
>>
>>
>> On 02/14/2012 08:46 AM, Chris Klich wrote:
>> > Hi all, I am currently plotting a cross-section of vertical velocity
>> > from a WRF output file. However, it seems no matter what I try to do
>> > the Y-axis labels are odd numbers. For example, in my current script,
>> > they are in increments of about 2.2km, when in the end I would like
>> > them every 2 or 3 kilometers. I am fairly new at making cross-section
>> > plots in NCL, and I have used the sample scripts to help build my
>> > current code (which is not done formatting). However, I cannot seem
>> > to figure out how to make the labels "nicer" numbers.
>> >
>> > Any help will be appreciated! I've attached the code I'm using, as
>> > well as pasted below the section of the code that makes the height
>> labels.
>> >
>> >
>> >
>> > if ( FirstTime ) then ; get height
>> > info for labels
>> > zmin = 0.
>> > zmax = max(z)/1000.
>> > nz = floattoint(zmax/2 + 1)
>> > FirstTime = False
>> > end if
>> >
>> >
>> >
>> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
>> > ; Use the built in latlon to ij function to convert the
>> > specified ;
>> > ; latitudes and longitudes to the closest i/x and j/y points in
>> > the domain ;
>> >
>> >
>> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
>> >
>> > loc_xy = wrf_user_latlon_to_ij(a,lats,lons)
>> > ys = loc_xy(0,0) ; Starting y (j)
>> > location
>> > ye = loc_xy(1,0) ; Ending y (j)
>> > location
>> > xs = loc_xy(0,1) ; Starting x (i)
>> > location
>> > xe = loc_xy(1,1) ; Ending x (i)
>> > location
>> >
>> >
>> >
>> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
>> > ; Specify the start and end points of the cross section after
>> > creating a ;
>> > ; plane to store these start and end locations ;
>> >
>> >
>> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
>> >
>> >
>> > plane = new(4,float) ; Create a float plane
>> > with 4 dimension sizes
>> > plane = (/ xs,ys , xe,ye /) ; Approx. start
>> > x,y and end x,y point
>> >
>> >
>> > opts = True ; Set options for the
>> > wrf_user_intrp3d below to True
>> > w_plane = wrf_user_intrp2d(w,plane,0.,opts) ; Use the
>> > wrf_user_intrp2d to create a vertical cross section plane of W with
>> > interpolated heights
>> > dim = dimsizes(w_plane) ; Find the data
>> > span - for use in labels
>> > zspan = dim(0)
>> >
>> >
>> > opts_xy = res
>> > opts_xy@tiYAxisString = "Height (km)"
>> > opts_xy@AspectRatio = 0.75
>> > opts_xy@cnMissingValPerimOn = True
>> > opts_xy@cnMissingValFillColor = 0
>> > opts_xy@cnMissingValFillPattern = 11
>> > opts_xy@tmYLMode = "Explicit"
>> > opts_xy@tmYLValues =
>> > fspan(0,zspan,nz) ; Create tick marks
>> > opts_xy@tmYLLabels =
>> > sprintf("%.1f",fspan(zmin,zmax,nz)) ; Create labels
>> > opts_xy@tiXAxisFontHeightF = 0.020
>> > opts_xy@tiYAxisFontHeightF = 0.020
>> > opts_xy@tmXBMajorLengthF = 0.02
>> > opts_xy@tmYLMajorLengthF = 0.02
>> > opts_xy@tmYLLabelFontHeightF = 0.015
>> >
>> >
>> > Thank you,
>> > Chris Klich
>>
>>
>> --
>> Christopher Klich
>> Graduate Student
>> Florida State University
>> (908) 208-9743
>>
>>

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Mon Feb 20 13:35:59 2012

This archive was generated by hypermail 2.1.8 : Thu Feb 23 2012 - 10:01:53 MST