Re: plotting irregular x-axis

From: Mary Haley <haley_at_nyahnyahspammersnyahnyah>
Date: Thu Nov 08 2012 - 09:47:24 MST

Hi Nick,

The time values are the problem:

> Time: [1321928218.059011..1321957275.072762]

These are huge numbers, and NCL is having trouble trying to plot and label these correctly.

How do you actually want the time axis to be labeled? You probably don't want those huge values!

What does printVarSummary(Temp&Time) report? It may be that you need to convert these time values to
something else, so you can get decent labels on the X axis.

You may want to look at the "time_axis_labels" function, which creates some "nice" labels for the X or Y axis.

The Time array will need to have units of something like "hours since 01-01-2011" or "minutes since 1-1-1999" or something similar.

See example time_labels_2.ncl at:

http://www.ncl.ucar.edu/Applications/time_labels.shtml#ex2

--Mary

On Nov 8, 2012, at 9:38 AM, Nick Guy wrote:

> Hi Mary,
> Sorry for the incomplete information. More information is given below.
>
> Plotting works fine, it's only the X axis that is not working as I had thought.
> The plot reverts to element number for the plot.
> I should note that earlier in the code I pull Temp (using 'addfiles') from multiple NetCDF and rename and define the coordinate axes (otherwise the "Time" coordinate is called ncl_join). Each NetCDF contains variables, each of which are 1D array of values (gridded to a pressure level). Therefore, only a single column is used to define Pressure and Time.
>
> TimeEpoch=fAll[:]->Time
> TimeEpoch@_FillValue=-999.
> Pres=fAll[:]->Pressure
>
> ; Find the dimionality of arrays
> ndims=dimsizes(TimeEpoch)
>
> TDrop=toint(ndims(1)*.75) ; Find the index near the surface
> TimeAx=TimeEpoch(:,TDrop)
>
> Temp=fAll[:]->Temp
> Temp!1="Pressure"
> Temp&Pressure=(/Pres(0,:)/)
> Temp!0="Time"
> Temp&Time=(/TimeAx/)
>
>
> Below is the printVarSummary() return for a couple of variables.
>
> Variable: Temp
> Type: float
> Total Size: 93228 bytes
> 23307 values
> Number of Dimensions: 2
> Dimensions and sizes: [Time | 51] x [Pressure | 457]
> Coordinates:
> Time: [1321928218.059011..1321957275.072762]
> Pressure: [101..1013]
> Number Of Attributes: 3
> long_name : Dry Bulb Temperature
> units : C
> _FillValue : -999
> ************************
> Variable: TimeAx
> Type: double
> Total Size: 408 bytes
> 51 values
> Number of Dimensions: 1
> Dimensions and sizes: [ncl_join | 51]
> Coordinates:
> Number Of Attributes: 3
> units : seconds since 1970-1-1 00:00:0.0
> calendar : standard
> _FillValue : -999
> ***************************
> I have also attached the image generated, please note the top row of plots which correspond to the code in original email.
> Thanks for your help!<20111122_dropsonde_timeseries_p1.eps>
>
> Nick Guy
> nick.guy@noaa.gov
>
>
>
>
> On Nov 8, 2012, at 10:12 AM, Mary Haley wrote:
>
>> Hi Nick,
>>
>> There's not enough information to go on here. It sounds like there's something strange about your X axis coordinate values.
>>
>> What does
>>
>>
>> printVarSummary(Temp)
>>
>> report?
>>
>> When you have weird problems like this, usually it's a good idea to try plotting your data with a bare number of resources set.
>>
>> What happens if you just do:
>>
>> res = True
>> res@cnFillOn = True
>> plot = gsn_csm_contour(wksPan1,transpose(Temp),res)
>>
>>
>> --Mary
>>
>>
>> On Nov 7, 2012, at 1:44 PM, Nick Guy wrote:
>>
>>> Hi,
>>>
>>> I am trying to output a contour plot with irregular spacing along the X (time) axis. I continue to receive the below error:
>>> warning:IrTransInitialize: error creating spline approximation for trXCoordPoints; defaulting to linear
>>> warning:ComputeMinorTickMarks: The distance between major tickmarks is so close or so far apart that arithmetic error may cause problems determining the accurate locations of minor tickmarks
>>> warning:ComputeMinorTickMarks: The distance between major tickmarks is so close or so far apart that arithmetic error may cause problems determining the accurate locations of minor tickmarks
>>> warning:ContourPlotSetValues: current transformation requires trYMaxF to be within data coordinate range: resetting
>>> warning:_NhlCreateSplineCoordApprox: Attempt to create spline approximation for X axis failed: consider adjusting trXTensionF value
>>>
>>>
>>> I've found the archived discussions and examples talking about converting irregular axes to linear and tried a couple different things. Any help to figure out how to fix this would be wonderful!
>>>
>>> =====ATTEMPT WITH LABEL VIA TIME_AXIS_LABELS=======
>>> TAx=fspan(min(TimeAx),max(TimeAx),50)
>>> res1A=True
>>> res1A@gsnDraw=False ; Don't draw plot , do this with the panel
>>> res1A@gsnFrame=False ; Don't advance frame
>>> res1A@cnFillOn=True ; Turn on filled contours
>>> res1A@cnLinesOn=True
>>> res1A@cnLineLabelsOn=True
>>>
>>> res1A@gsnSpreadColors=True
>>> res1A@gsnLeftStringFontHeightF=.03 ; Shrink the label
>>> res1A@gsnRightStringFontHeightF=.03
>>> res1A@gsnXAxisIrregular2Linear=True
>>>
>>> res1A@lbOrientation="Vertical" ; Vertical colorbar
>>> res1A@vpWidthF=1. ; Make the plot longer
>>> res1A@vpHeightF=0.7 ; Make the plot shorter
>>>
>>> res1A@tiXAxisString="" ; No x-axis title
>>> res1A@tiYAxisString="Pressure (hPa)" ; Define Y-Axis title
>>> res1A@trYReverse=True ; Reverse the y-axis
>>> res1A@trYMinF=300. ; Set min Y plot range
>>> res1A@trYMaxF=1025. ; Set the max Y plot range
>>> res1A@tmXBLabelsOn=True
>>>
>>> restime=True
>>> restime@ttmAxis="XB"
>>> restime@ttmFormat="%H:%M"
>>> restime@ttmMajorStride=10
>>>
>>> time_axis_labels(TimeAx,res1A,restime)
>>> panPlot1(0)=gsn_csm_contour(wksPan1,transpose(Temp),res1A)
>>> ====================================================
>>>
>>> and also setting your axis to irregular and defining the
>>>
>>> ======ATTEMPT DEFINING AXIS==========================
>>> res1B=True
>>> res1B@gsnDraw=False ; Don't draw plot , do this with the panel
>>> res1B@gsnFrame=False ; Don't advance frame
>>> res1B@cnFillOn=True ; Turn on filled contours
>>>
>>> res1B@gsnSpreadColors=True
>>> res1B@gsnLeftStringFontHeightF=.03 ; Shrink the label
>>> res1B@gsnRightStringFontHeightF=.03
>>>
>>> res1B@lbOrientation="Vertical" ; Vertical colorbar
>>> res1B@vpWidthF=1. ; Make the plot longer
>>> res1B@vpHeightF=0.7 ; Make the plot shorter
>>>
>>> res1B@tiXAxisString=" " ; No x-axis title
>>> res1B@tiYAxisString="Pressure (hPa)" ; Define Y-Axis title
>>> res1B@trYReverse=True ; Reverse the y-axis
>>> res1B@trYMinF=300. ; Set min Y plot range
>>> res1B@trYMaxF=1025. ; Set the max Y plot range
>>>
>>> res1B@sfXArray=TimeAx
>>> res1B@trXAxisType="Irregular"
>>> res1B@trXCoordPoints=TimeAx
>>> ; res1B@tmXB
>>> panPlot1(1)=gsn_csm_contour(wksPan1,transpose(RH),res1B)
>>> ====================================================
>>>
>>> Thanks!
>>>
>>> Nick Guy
>>> nick.guy@noaa.gov
>>>
>>>
>>>
>>>
>>> _______________________________________________
>>> 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 Thu Nov 8 09:47:33 2012

This archive was generated by hypermail 2.1.8 : Tue Nov 13 2012 - 14:27:24 MST