Re: Y-axis label and values

From: Mary Haley <haley_at_nyahnyahspammersnyahnyah>
Date: Fri Jan 08 2010 - 08:21:36 MST

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:
>
> 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: Wednesday, January 6, 2010, 9:22 AM
>
> Kalim,
>
> I tried a piece of your script on our "hov_1.ncl" example, and it
> worked just fine. I got the month labels on the Y axis. This leads
> me to believe that your "time" coordinate array is not in the range
> of major_ticks. See the attached script and png file.
>
> Your "major_ticks" array goes from 0.0 to 144.8. What is the range
> of zAvgTime&time? What does print(zAvgTime&time) report?
>
> 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>

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Fri Jan 8 08:22:22 2010

This archive was generated by hypermail 2.1.8 : Fri Jan 15 2010 - 13:51:45 MST