Re: Integer axis marker

From: David Brown <dbrown_at_nyahnyahspammersnyahnyah>
Date: Mon Jan 11 2010 - 11:07:11 MST

Hi Yongzho,

If you actually want the values to be rounded to the nearest integer,
you can use this format string:

  " .1;0f"

This says to make the units digit the "leftmost significant digit" (;
0) and to include only 1 significant digit (.1 -- starting from the
leftmost).
  -dave

On Jan 11, 2010, at 8:56 AM, Mary Haley wrote:

>
> On Jan 11, 2010, at 8:23 AM, Li, Yongzuo wrote:
>
>> Mary,
>>
>> Do you mean res@tmYLFormat = "f" will produce
>> axis marker without decimal?
>>
>> I do not want to have float with decimal.
>>
>
> That is correct. If you have "385.0", it will turn it into "385".
>
> If you have "385.5", however, it will stay "385.5".
>
> --Mary
>
>> Thanks.
>>
>> Yongzuo
>> ________________________________________
>> From: Mary Haley [haley@ucar.edu]
>> Sent: Monday, January 11, 2010 9:03 AM
>> To: Li, Yongzuo
>> Cc: ncl-talk@ucar.edu
>> Subject: Re: ncl-talk Digest, Vol 74, Issue 25
>>
>> Hi Yongzuo,
>>
>> In the future, if you post to ncl-talk, would you change the subject
>> so that it includes a more meaningful subject, other than "ncl-talk
>> Digest". This especially helps when we archive the messages.
>>
>> To get integers on your Y axis, you need to use the tmYLFormat
>> resource. Dave Brown created a nice example awhile back, showing how
>> to use different formats. See example 8 at:
>>
>> http://www.ncl.ucar.edu/Applications/tickmarks.shtml#ex8
>>
>> In your case, I believe you want:
>>
>> res@tmYLFormat = "f"
>>
>> --Mary
>>
>> On Jan 11, 2010, at 7:35 AM, Li, Yongzuo wrote:
>>
>>> Hi,
>>>
>>> How can the axis tick marker be defined as integer for gsn_xy plot?
>>> I got 980.0 982.0 ... on y-axis. I just want to have 980 , 982 on
>>> y-axis.
>>>
>>> Thanks.
>>>
>>> Yongzuo
>>> ________________________________________
>>> From: ncl-talk-bounces@ucar.edu [ncl-talk-bounces@ucar.edu] on
>>> behalf of ncl-talk-request@ucar.edu [ncl-talk-request@ucar.edu]
>>> Sent: Sunday, January 10, 2010 7:54 PM
>>> To: ncl-talk@ucar.edu
>>> Subject: ncl-talk Digest, Vol 74, Issue 25
>>>
>>> Send ncl-talk mailing list submissions to
>>> ncl-talk@ucar.edu
>>>
>>> To subscribe or unsubscribe via the World Wide Web, visit
>>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>> or, via email, send a message with subject or body 'help' to
>>> ncl-talk-request@ucar.edu
>>>
>>> You can reach the person managing the list at
>>> ncl-talk-owner@ucar.edu
>>>
>>> When replying, please edit your Subject line so it is more specific
>>> than "Re: Contents of ncl-talk digest..."
>>>
>>>
>>> Today's Topics:
>>>
>>> 1. Re: subtraction function (jwsmith@ucar.edu)
>>> 2. Re: Y-axis label and values (kalim ullah)
>>>
>>>
>>> ---------------------------------------------------------------------
>>> -
>>>
>>> Message: 1
>>> Date: Sun, 10 Jan 2010 14:25:47 -0700
>>> From: jwsmith@ucar.edu
>>> Subject: Re: subtraction function
>>> To: Dennis Shea <shea@ucar.edu>
>>> Cc: ncl-talk <ncl-talk@ucar.edu>
>>> Message-ID: <20100110142547.2kd3llso9w48k44c@web3.acd.ucar.edu>
>>> Content-Type: text/plain; charset=UTF-8; DelSp="Yes";
>>> format="flowed"
>>>
>>> co(Time, bottom_top, south_north, west_east)
>>>
>>>
>>> I want to take a ten - day average of co at 12z. I then want to
>>> subtract this average from the individual 12 z time in that period.
>>> This will be the anamolous field. I want to make a vertical cross
>>> section of the anamolies.
>>>
>>> When I did the subtraction in nco using ncbo and ncdiff. The
>>> difference of co was taken, but it also seems to have taken the
>>> difference of the XLAT and XLON. I think this happened because co
>>> is a
>>> variable with lat/lon (bottom_top) coordinates, (I could be
>>> misinterpreting the use of ncdiff and ncbo).
>>>
>>> Hencem I was asking if the subtraction could be done in ncl. I
>>> hope I
>>> have provided more clarity this time.
>>>
>>> Thanks,
>>> Jonathan
>>>
>>>
>>> Quoting Dennis Shea <shea@ucar.edu>:
>>>
>>>> I agree with Huang. It is not clear what you want to do.
>>>> It does sound like conform is what ou need.
>>>>
>>>> If you have:
>>>>
>>>> x3(Times,lat,lon) and xBase(lat,lon)
>>>>
>>>> xDiff = x3 - conform(x3, xBase, (/1,2/) )
>>>> copy_VarMeta(x3, xDiff)
>>>>
>>>> http://www.ncl.ucar.edu/Document/Functions/Built-in/conform.shtml
>>>>
>>>> Good Luck
>>>>
>>>> ph0007@ustc.edu wrote:
>>>>> Hi, Jonathan
>>>>>
>>>>> I'm not really sure what you want to do. I guess the function
>>>>> "conform"
>>>>> could help you.
>>>>>
>>>>> Please see the document about details.
>>>>>
>>>>> Huang Ping
>>>>>
>>>>>
>>>>> 2010-01-10
>>>>> -------------------------------------------------------------------
>>>>> -
>>>>> ----
>>>>> -------------------------------------------------------------------
>>>>> -
>>>>> ----
>>>>> *????* jwsmith
>>>>> *?????* 2010-01-10 13:16:56
>>>>> *????* ncl-talk
>>>>> *???*
>>>>> *???* [ncl-talk] subtraction function
>>>>> Hello ncl
>>>>> I see that there is a sum function in ncl. Is there a subtraction
>>>>> fuction? I need to subtract a wrfout that contains the average of
>>>>> fields from an single wrf model time. The ncbo and ncdiff
>>>>> functions
>>>>> in nco did not work because the files contain lat/lon
>>>>> coordinates. Is
>>>>> it possible to something like this in ncl?
>>>>> Jonathan
>>>>> Jonathan Wynn Smith
>>>>> Doctoral Student in Howard University
>>>>> Program in Atmospheric Sciences (HUPAS)
>>>>> 2008 ASP Graduate Student Visitor
>>>>> 2006 ASP Summer Colloquium Participant
>>>>> 408 Thirkield Building
>>>>> 2355 6th St. NW
>>>>> Washington, DC 20059
>>>>> E-mail: jw_smith@howard.edu or jwsmith9@gmail.com
>>>>> Cell Phone: 336-601-4563
>>>>> ----------------------------------------------------------------
>>>>> This message was sent using IMP, the Internet Messaging Program.
>>>>> _______________________________________________
>>>>> ncl-talk mailing list
>>>>> List instructions, subscriber options, unsubscribe:
>>>>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>>>>
>>>>>
>>>>> -------------------------------------------------------------------
>>>>> -
>>>>> ----
>>>>>
>>>>> _______________________________________________
>>>>> ncl-talk mailing list
>>>>> List instructions, subscriber options, unsubscribe:
>>>>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>>>
>>>>
>>>>
>>>
>>>
>>>
>>> Jonathan Wynn Smith
>>>
>>> Doctoral Student in Howard University
>>> Program in Atmospheric Sciences (HUPAS)
>>> 2008 ASP Graduate Student Visitor
>>> 2006 ASP Summer Colloquium Participant
>>>
>>> 408 Thirkield Building
>>> 2355 6th St. NW
>>> Washington, DC 20059
>>>
>>> E-mail: jw_smith@howard.edu or jwsmith9@gmail.com
>>> Cell Phone: 336-601-4563
>>>
>>> ----------------------------------------------------------------
>>> This message was sent using IMP, the Internet Messaging Program.
>>>
>>>
>>>
>>> ------------------------------
>>>
>>> Message: 2
>>> Date: Sun, 10 Jan 2010 17:54:09 -0800 (PST)
>>> From: kalim ullah <kalimrid@yahoo.com>
>>> Subject: Re: Y-axis label and values
>>> To: Mary Haley <haley@ucar.edu>
>>> Cc: ncl-talk@ucar.edu
>>> Message-ID: <275943.50743.qm@web53708.mail.re2.yahoo.com>
>>> Content-Type: text/plain; charset="utf-8"
>>>
>>> Dear Mary, thanks alot for your kind help.
>>> regrads,
>>> kalim
>>>
>>> --- On Fri, 1/8/10, Mary Haley <haley@ucar.edu> wrote:
>>>
>>>
>>> From: Mary Haley <haley@ucar.edu>
>>> Subject: Re: Y-axis label and values
>>> To: "kalim ullah" <kalimrid@yahoo.com>
>>> Cc: ncl-talk@ucar.edu
>>> Date: Friday, January 8, 2010, 7:21 AM
>>>
>>>
>>> Dear?
>>>
>>> Kalim,
>>>
>>>
>>> You can use ut_calendar to convert your time coordinate values to
>>> something more manageable, like years, months, and days, and then
>>> you can use these arrays to determine which part of the Y axis you
>>> want to label.
>>>
>>>
>>> I changed your script to show how you might label the first day of
>>> every month. You can modify this to label the midpoint of every
>>> month, using the days_in_month calendar as you did before. You'll
>>> still want to use ut_calendar so you can retrieve the months and
>>> days.
>>>
>>>
>>> You can use this same method to determine where you want minor tick
>>> marks.
>>>
>>>
>>> --Mary
>>>
>>>
>>>
>>>
>>>
>>> On Jan 6, 2010, at 8:19 PM, kalim ullah wrote:
>>>
>>>
>>>
>>>
>>>
>>>
>>> Dear Mary,
>>> Thanks a lot for spending your precious time on my problem.?I think
>>> you are right my time coordinate array may be wrong. When I ignore
>>> the (res@tmYLMode = "Explicit?) it works and the label appear on Y-
>>> axis like (1779600- 1780200) but I don?t know how to convert it
>>> into days and month label? ?So, for your conveyance my plot, NCEP
>>> data file and zAvgTime print report is attached given below. Your
>>> guidance in this regard will be appreciated.
>>> thanks
>>> kalim
>>> *****************************
>>> Variable: z
>>> Type: float
>>> Total Size: 10828800 bytes
>>> 2707200 values
>>> Number of Dimensions: 3
>>> Dimensions and sizes: [time | 150] x [lat | 94] x [lon | 192]
>>> Coordinates:
>>> time: [1779456..1780350]
>>> lat: [88.542..-88.542]
>>> lon: [ 0..358.125]
>>> Number Of Attributes: 18
>>> long_name : 6-hourly Mean of Latent Heat Net Flux at Surface
>>> unpacked_valid_range : ( -2420, 2420 )
>>> actual_range : ( -667.2, 1884.8 )
>>> units : W/m^2
>>> _FillValue : -32767
>>> precision : 1
>>> least_significant_digit : 0
>>> GRIB_id : 121
>>> GRIB_name : LHTFL
>>> var_desc : Latent Heat Net Flux
>>> dataset : NCEP/DOE AMIP-II Reanalysis (Reanalysis-2)
>>> level_desc : Surface
>>> statistic : Mean
>>> parent_stat : Individual Obs
>>> standard_name : surface_upward_latent_heat_flux
>>> cell_methods : time: mean
>>> valid_range : ( -2420, 2419.9 )
>>> missing_value : -32767
>>> ?
>>> Variable: zAvgTime
>>> Type: float
>>> Total Size: 115200 bytes
>>> 28800 values
>>> Number of Dimensions: 2
>>> Dimensions and sizes: [time | 150] x [lon | 192]
>>> Coordinates:
>>> time: [1779456..1780350]
>>> lon: [ 0..358.125]
>>> Number Of Attributes: 19
>>> missing_value : -32767
>>> valid_range : ( -2420, 2419.9 )
>>> cell_methods : time: mean
>>> standard_name : surface_upward_latent_heat_flux
>>> parent_stat : Individual Obs
>>> statistic : Mean
>>> level_desc : Surface
>>> dataset : NCEP/DOE AMIP-II Reanalysis (Reanalysis-2)
>>> var_desc : Latent Heat Net Flux
>>> GRIB_name : LHTFL
>>> GRIB_id : 121
>>> least_significant_digit : 0
>>> precision : 1
>>> _FillValue : -32767
>>> units : W/m^2
>>> actual_range : ( -667.2, 1884.8 )
>>> unpacked_valid_range : ( -2420, 2420 )
>>> long_name : 6-hourly Mean of Latent Heat Net Flux at Surface
>>> average_op_ncl : dim_avg over dimension: lat
>>> --- On Wed, 1/6/10, Mary Haley <haley@ucar.edu> wrote:
>>>
>>>
>>>
>>> ?
>>> If these values are not in the range of 0.0 to 144.8, then this is
>>> what your problem is.
>>>
>>>
>>>
>>>
>>>
>>> --Mary
>>>
>>>
>>>
>>> On Jan 5, 2010, at 7:50 PM, kalim ullah wrote:
>>>
>>>
>>>
>>>
>>>
>>>
>>> Dear Mary, thanks for your response. Actually, I want to plot as
>>> example (hov_7.ncl:) but after some mudification I got the?figure?
>>> without label(i.e.month names) on y-axis?,so my plot is attached
>>> herewith.
>>> thanks
>>> kalim
>>> --- On Tue, 1/5/10, Mary Haley <haley@ucar.edu> wrote:
>>>
>>>
>>> From: Mary Haley <haley@ucar.edu>
>>> Subject: Re: Y-axis label and values
>>> To: "kalim ullah" <kalimrid@yahoo.com>
>>> Cc: ncl-talk@ucar.edu
>>> Date: Tuesday, January 5, 2010, 8:59 AM
>>>
>>>
>>>
>>>
>>> Kalim,
>>>
>>>
>>> If your tickmark labels are not showing up in "explicit" mode, then
>>> usually the problem is that the tickmark values you're using are
>>> not within the range of your axis values.
>>>
>>>
>>> Since I can't run your script, I'm not sure what your Y axis values
>>> are. ?You need to look at the arrays zAvgTime&time and major_ticks
>>> and make sure they are in the same data space.
>>>
>>>
>>> major_ticks should be set to values that are within the range of
>>> your time values.
>>>
>>>
>>> --Mary
>>>
>>>
>>> On Jan 4, 2010, at 7:09 PM, kalim ullah wrote:
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> Dear NCL Users,
>>> I?m trying to plot time vs lon figure but after plotting there is
>>> no Y-axis labels and values appear and also no error. Please could
>>> you help me in this regard? My script is attached given below:
>>> Thanks in advance
>>> kalim
>>> ******************************
>>> ?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
>>> ;=============================================
>>> ; data processing
>>> ;=============================================
>>> ?? f = addfile("lhtfl.sfc.gauss.2007.nc","r")
>>> ?? z = short2flt(f->lhtfl(0:149,:,:))???? ;AUG(1-5)
>>> ?? printVarSummary(z)
>>> ?? zAvgTime = dim_avg_Wrap(z(time|:,lon|:,{lat|0:40}))
>>> ?? printVarSummary(zAvgTime)
>>> ?
>>> ?? wks? = gsn_open_wks ("x11", "hov" )
>>> ?? gsn_define_colormap(wks,"BlAqGrYeOrRe")
>>> ?? ;*******************************
>>> ?? res??????????? = True????????????????????????
>>> ?? res@cnFillOn????????????? = True?
>>> ?? months????? = (/1,? 2,??? 3,?? 4,?? 5/)?? ???
>>> ?? years?????? = (/2007,2007,2007,2007,2007/)
>>> ?? tk_per_mon? = 5 ; Tickmarks per month.
>>> ?? nmonths???? = dimsizes(months)
>>> ?? ndays?????? = nmonths * tk_per_mon
>>> ?
>>> ?? day_in_mon? = new(nmonths,float)?????????? ; Number of days in
>>> each month
>>> ?? do i=0,nmonths-1
>>> ?? day_in_mon(i) = days_in_month(years(i),months(i))*1.
>>> ?? end do
>>> ?
>>> ?? major_ticks = new(ndays,float)??? ; Array to hold major tickmark
>>> values.
>>> ?? imonth????? = 0
>>> ?? days_accum? = 0.
>>> ?? ii4???????? = ispan(1,4,1)*1.
>>> ?? do i=0,ndays-1,5
>>> ?? major_ticks(i) = days_accum
>>> ?? major_ticks(i+1:i+4) = major_ticks(i) + ii4*(day_in_mon(imonth)/
>>> tk_per_mon)
>>> ?? days_accum???? = days_accum + day_in_mon(imonth)
>>> ?? imonth = imonth + 1
>>> ?? end do
>>> ?? ;*********************************
>>> ?? res@cnLinesOn??????? ?????= False
>>> ?? res@gsnSpreadColors?????? = True
>>> ?? res@cnLevelSelectionMode = "ManualLevels"
>>> ?? res@cnMinLevelValF?????? = -10.?????????????? ; min level
>>> ?? res@cnMaxLevelValF?????? =? 100.?????????????? ; max leve
>>> ?? res@lbOrientation???????? = "Vertical"
>>> ?? res@gsnLeftString???????? = "Latent Heat Net Flux(W/m^2)"
>>> ?? res@gsnRightString?????? = ""
>>> ?? res@tmYLMode?????????? = "Explicit"???????? ; Define own tick
>>> mark labels.
>>> ?? res@tmYLMinorValues??? = major_ticks(0:ndays-1:5)
>>> ?? res@tmYLValues???????? = major_ticks
>>> ?? res@tmYLLabels???????? = new(ndays,string)
>>> ?? res@tmYLLabels(:)???? = ""
>>> ?
>>> ; Label mid tickmark with the month label.
>>> ?? res@tmYLLabels(3::5)? = (/"JAN", "FEB", "MAR", "APR", "MAY"/)
>>> ?
>>> ?? res@tmYLMinorOutwardLengthF = 0.02??? ; Increase length and
>>> size of
>>> ?? res@tmYLMinorLengthF??????? = 0.02??? ; minor tickmarks
>>> ?? res@tmYLMinorThicknessF???? = 2.0
>>> ?? res@tmYLMajorOutwardLengthF = 0.01
>>> ?? res@tmYLMajorLengthF??????? = 0.01
>>> ?? plot = gsn_csm_hov(wks, zAvgTime(:,{30:120}) , res )
>>> ?? end
>>>
>>> _______________________________________________
>>> ncl-talk mailing list
>>> List instructions, subscriber options, unsubscribe:
>>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>>
>>> <hov.pdf>
>>>
>>> <Lhov3.pdf><lhtfl.sfc.gauss.2007.nc>
>>>
>>>
>>>
>>>
>>> -------------- next part --------------
>>> An HTML attachment was scrubbed...
>>> URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/
>>> 20100110/849ae607/attachment.html
>>>
>>> ------------------------------
>>>
>>> _______________________________________________
>>> ncl-talk mailing list
>>> ncl-talk@ucar.edu
>>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>>
>>>
>>> End of ncl-talk Digest, Vol 74, Issue 25
>>> ****************************************
>>> _______________________________________________
>>> ncl-talk mailing list
>>> List instructions, subscriber options, unsubscribe:
>>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>
>
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Mon Jan 11 11:07:18 2010

This archive was generated by hypermail 2.1.8 : Tue Jan 12 2010 - 15:38:20 MST