comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Plotting time
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Plotting time [message #46515] Fri, 25 November 2005 08:37 Go to next message
clivecook59 is currently offline  clivecook59
Messages: 26
Registered: November 2005
Junior Member
I'm trying to plot in IDL with time on the x-axis. Now i can do this in
direct graphics mode by converting my x values into julian time and
then using the tickunits='time' and tick_format='LABEL_DATE' comands.
However i am trying to do this in an object plot and i just cannot get
it to work. Whats the best way to plot time correctly in object
graphics?

many thanks

Clive Cook
Re: Plotting time [message #46548 is a reply to message #46515] Tue, 29 November 2005 16:57 Go to previous messageGo to next message
Mark Hadfield is currently offline  Mark Hadfield
Messages: 783
Registered: May 1995
Senior Member
David Fanning wrote:
> Hang on a minute and I'll make it easy for you. :-)

David sent me some code in which a date axis as described by the OP was
grafted into his XPLOT plotting window application thingy. The axis
appeared in the wrong place, off the left-hand edge of the plot window,
as reported. I traced the problem. XPLOT gets the axes in the right
place by adjusting the scaling, something like this

xAxis->GetProperty, CRange=xrange
xs = Normalize(xrange, Position=[xn0,xn1])
xAxis->SetProperty, XCoord_Conv=xs

where xn0 & xn1 are the desired end points of the axis in normalised
coordinates.

NORMALIZE was doing its calculations in single-precision floating point
and returning a single-precision result. Once I changed everything to
double-precision, the axis appears in the right place.


>> Incidentally, LABEL_DATE is evil; the C() formats are much better, and
>> not *that* hard to construct.
>
> It is screwy with or without LABEL_DATE.

Sure. That was just me riding one of my hobby horses.

--
Mark Hadfield "Kei puwaha te tai nei, Hoea tahi tatou"
m.hadfield@niwa.co.nz
National Institute for Water and Atmospheric Research (NIWA)
Re: Plotting time [message #46550 is a reply to message #46515] Tue, 29 November 2005 15:09 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Mark Hadfield writes:

> And I thought I could get away with offering standard answer #127. Now I
> have to go and actually read the code in question...
>
> How are you or the OP locating the axis in the x direction? You're not
> under the illusion that you can do this with the POSITION keyword are
> you? Oh no. For an X/Y/Z axis the 0/1/2nd element of POSITION is ignored.

Hang on a minute and I'll make it easy for you. :-)

> Incidentally, LABEL_DATE is evil; the C() formats are much better, and
> not *that* hard to construct.

It is screwy with or without LABEL_DATE.

Cheers,

David

--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Re: Plotting time [message #46551 is a reply to message #46515] Tue, 29 November 2005 14:57 Go to previous messageGo to next message
Mark Hadfield is currently offline  Mark Hadfield
Messages: 783
Registered: May 1995
Senior Member
David Fanning wrote:
> Well, that changed things. The axis moved further to the LEFT,
> and I wanted it over here on the RIGHT. Sigh...
>
> I checked all the inputs, etc. everything appears to be in
> double precision.

And I thought I could get away with offering standard answer #127. Now I
have to go and actually read the code in question...

How are you or the OP locating the axis in the x direction? You're not
under the illusion that you can do this with the POSITION keyword are
you? Oh no. For an X/Y/Z axis the 0/1/2nd element of POSITION is ignored.

Incidentally, LABEL_DATE is evil; the C() formats are much better, and
not *that* hard to construct.


--
Mark Hadfield "Kei puwaha te tai nei, Hoea tahi tatou"
m.hadfield@niwa.co.nz
National Institute for Water and Atmospheric Research (NIWA)
Re: Plotting time [message #46553 is a reply to message #46515] Tue, 29 November 2005 14:18 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Mark Hadfield writes:

> Yes, but the problem is not with the axis object, which keeps its data
> in double precision, but with the view object. Set the view object's
> DOUBLE property and these problems should disappear.

Well, that changed things. The axis moved further to the LEFT,
and I wanted it over here on the RIGHT. Sigh...

I checked all the inputs, etc. everything appears to be in
double precision.

It is a mystery.

Cheers,

David

--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Re: Plotting time [message #46554 is a reply to message #46515] Tue, 29 November 2005 14:09 Go to previous messageGo to next message
Mark Hadfield is currently offline  Mark Hadfield
Messages: 783
Registered: May 1995
Senior Member
David Fanning wrote:
> clivecook59@gmail.com writes:
>
>
>> I was wondering if this is a problem with the way in which the
>> idlgraxis receives the different values. What i mean by this is that
>> for instance it reads the xrange and xcoord_conv values as floating
>> points instead of as double precission numbers. Could this be the
>> problem?
>
>
> This is my working hypothesis at the moment, too.

Yes, but the problem is not with the axis object, which keeps its data
in double precision, but with the view object. Set the view object's
DOUBLE property and these problems should disappear.


--
Mark Hadfield "Kei puwaha te tai nei, Hoea tahi tatou"
m.hadfield@niwa.co.nz
National Institute for Water and Atmospheric Research (NIWA)
Re: Plotting time [message #46558 is a reply to message #46515] Tue, 29 November 2005 10:55 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
clivecook59@gmail.com writes:

> I was wondering if this is a problem with the way in which the
> idlgraxis receives the different values. What i mean by this is that
> for instance it reads the xrange and xcoord_conv values as floating
> points instead of as double precission numbers. Could this be the
> problem?

This is my working hypothesis at the moment, too.

Cheers,

David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Re: Plotting time [message #46559 is a reply to message #46515] Tue, 29 November 2005 10:42 Go to previous messageGo to next message
clivecook59 is currently offline  clivecook59
Messages: 26
Registered: November 2005
Junior Member
I was wondering if this is a problem with the way in which the
idlgraxis receives the different values. What i mean by this is that
for instance it reads the xrange and xcoord_conv values as floating
points instead of as double precission numbers. Could this be the
problem?

Clive
Re: Plotting time [message #46560 is a reply to message #46515] Tue, 29 November 2005 10:37 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
clivecook59@gmail.com writes:

> Here's the code for the x-axis,
>
> dummy = LABEL_DATE(DATE_FORMAT=['%H:%I'])
> xrange1 = [julday(10,1,2005,5,0,0),julday(10,1,2005,10,0,0)]
>
> xAxis1a = Obj_New("IDLgrAxis",0,Color=[0,0,0],Ticklen=0.025,$
> Range=xrange1,title=xtitle1,Location=[position2(0),position2 (1)],$
> /Exact,tickunits='time',TICKFORMAT ='LABEL_DATE')
>
> xAxis1a->GetProperty, Ticktext=xAxisText
> xAxisText->SetProperty, Font=helvetica10pt
>
> I would assue that this should give me an axis from 5:00 to 10:00
> however i get nothing

Humm. Well, I get *something*, but it is clearly not right.
In my example, using your axis range, tickunits, and tickformat,
I can see just a portion of the axis. The rest is off to the
left of my view somewhere. So, it appears that it cannot be
positioned and scaled like other axes. I would guess bug
at this point. Maybe we could get someone at RSI to respond.

Cheers,

David

--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Re: Plotting time [message #46561 is a reply to message #46515] Tue, 29 November 2005 10:08 Go to previous messageGo to next message
clivecook59 is currently offline  clivecook59
Messages: 26
Registered: November 2005
Junior Member
Here's the code for the x-axis,

dummy = LABEL_DATE(DATE_FORMAT=['%H:%I'])
xrange1 = [julday(10,1,2005,5,0,0),julday(10,1,2005,10,0,0)]

xAxis1a = Obj_New("IDLgrAxis",0,Color=[0,0,0],Ticklen=0.025,$
Range=xrange1,title=xtitle1,Location=[position2(0),position2 (1)],$
/Exact,tickunits='time',TICKFORMAT ='LABEL_DATE')

xAxis1a->GetProperty, Ticktext=xAxisText
xAxisText->SetProperty, Font=helvetica10pt

I would assue that this should give me an axis from 5:00 to 10:00
however i get nothing

many thanks

Clive
Re: Plotting time [message #46562 is a reply to message #46515] Tue, 29 November 2005 08:56 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Clive,

> It means that the x-axis does not display the time correctly. I used
> the idlgraxis comand and specify an xrange with the start and stop time
> in julian time however i cannot get it to display correctly.

Umm, mine looks fine. Guess I'd need an example. :-)

Cheers,

David

--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Re: Plotting time [message #46632 is a reply to message #46515] Wed, 30 November 2005 12:44 Go to previous message
clivecook59 is currently offline  clivecook59
Messages: 26
Registered: November 2005
Junior Member
Hi,

Thanks for the help. The problem was solved once i set the idlgrview to
double.

cheers

Clive
Re: Plotting time [message #46646 is a reply to message #46548] Tue, 29 November 2005 17:31 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Mark Hadfield writes:

> David sent me some code in which a date axis as described by the OP was
> grafted into his XPLOT plotting window application thingy. The axis
> appeared in the wrong place, off the left-hand edge of the plot window,
> as reported. I traced the problem. XPLOT gets the axes in the right
> place by adjusting the scaling, something like this
>
> xAxis->GetProperty, CRange=xrange
> xs = Normalize(xrange, Position=[xn0,xn1])
> xAxis->SetProperty, XCoord_Conv=xs
>
> where xn0 & xn1 are the desired end points of the axis in normalised
> coordinates.
>
> NORMALIZE was doing its calculations in single-precision floating point
> and returning a single-precision result. Once I changed everything to
> double-precision, the axis appears in the right place.

Ah, *my* NORMALIZE does it's calculations in double precision. But I
just noticed that my XPLOT has an *old* copy that does it in single
precision. Just another reminder to all you aspiring IDL programmers
out there that you should really, REALLY check your assumptions. :-)

Thanks, Mark.

Cheers,

David

P.S. The *new* version of XPLOT will not include NORMALIZE. :-)

--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Utilizing Identifiers in iTools
Next Topic: IDL T-Shirt Makes You Feel Like a Rock Star

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 11:36:23 PDT 2025

Total time taken to generate the page: 0.11999 seconds