Re: PLOT question [message #22954] |
Thu, 21 December 2000 09:44 |
Martin Schultz
Messages: 515 Registered: August 1997
|
Senior Member |
|
|
Jaco van Gorkom wrote:
>
>
>
> I used FORMAT_AXIS_VALUES to get "nice" formatting of the strings. If
> you *really* want "3pi/2" at your tick mark instead of 4.71 , then that
> should not be too difficult to code into the PHASE_ANGLE function.
> Better left as an exercise to the reader...
>
... just one little hint: '!4' switches to greek font (or '!7' which
uses complex greek), and '!3' (or '!6') switches back to normal.
Cheers,
Martin
--
[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[ [[[[[[[
[[ Dr. Martin Schultz Max-Planck-Institut fuer Meteorologie [[
[[ Bundesstr. 55, 20146 Hamburg [[
[[ phone: +49 40 41173-308 [[
[[ fax: +49 40 41173-298 [[
[[ martin.schultz@dkrz.de [[
[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[ [[[[[[[
|
|
|
Re: PLOT question [message #22964 is a reply to message #22954] |
Thu, 21 December 2000 06:05  |
Jaco van Gorkom
Messages: 97 Registered: November 2000
|
Member |
|
|
Stuart Colley wrote:
> What I want to do is swap time for phase angle, so the phase is
> somewhere between 0 - 2pi, but the problem is that the phase angle
> repeats, so what I was looking for on the axis was something
> like:
>
> y value |
> |
> | x x
> | x x x x x
> ________|__________________x_____________________x__________ _
> time | 0 pi/2 pi 3pi/2 0 pi/2 pi 3pi/2 0 etc...
>
> |
> end of first cycle, start of second
>
> What I'll probably do is use xtickv and xtickname to set the ticks, since
> as far as I can tell, you MUST 'plot, t, y' to get the plot right,
> 'plot, phase, y' results in the data being merged together and only one
> cycle being plotted.
>
> The reason I sent the first post - I was wondering if there was an easier
> way than xtickv/xtickname since it can't automatically choose the tick
> values like PLOT can, and isn't so flexible when I'm trying to write a
> general purpose routine.
The XTICKFORMAT mechanism as proposed by Dave should give you the
periodic phase angle tick values, if you plug in the logic by Craig:
FUNCTION PHASE_ANGLE, axis, index, t
phase = (t-t0)/period
phase = phase - floor(phase)
; this phase angle goes from 0 to 1, you want 0 - 2pi:
phase = 2*!PI*phase
RETURN, STRING(phase)
END
..
PLOT, t, y, XTICKFORMAT='PHASE_ANGLE'
Now PLOT will automatically choose "nice" tick values based on the
original time values, e.g. 1 s, 2 s, ... You would like "nice" values in
phase angle (pi, 2pi, ..), so I would plot as a function of t/period
(actually the total phase angle), just to get the tick marks at nice
locations:
FUNCTION PHASE_ANGLE, axis, index, totalphase
phase = totalphase - floor(totalphase)
; this phase angle goes from 0 to 1, you want 0 - 2pi:
phase = 2 * !pi * phase
RETURN, (FORMAT_AXIS_VALUES(phase))[0]
END
..
t0 = 0 ; starting time of first (or any) period
PLOT, (t-t0)/period, y, XTICKFORMAT='PHASE_ANGLE'
One important thing here: you need to make sure that IDL uses at least
two tick marks per period, or else these nice periodic tick values will
look just like a ordinary series of zeroes. (for this, set the XTICKS
keyword if necessary)
I used FORMAT_AXIS_VALUES to get "nice" formatting of the strings. If
you *really* want "3pi/2" at your tick mark instead of 4.71 , then that
should not be too difficult to code into the PHASE_ANGLE function.
Better left as an exercise to the reader...
Jaco
------------------------------
Jaco van Gorkom gorkom@rijnh.nl
FOM-Instituut voor Plasmafysica Rijnhuizen
|
|
|
Re: PLOT question [message #22966 is a reply to message #22964] |
Thu, 21 December 2000 03:46  |
Stuart Colley
Messages: 17 Registered: February 2000
|
Junior Member |
|
|
Maybe a small example will be of help - hopefully it will be a bit clearer
than my first message. Imagine a periodic signal (sin wave for example)
and we are plotting more than one cycle, Normally the signal would be
plotted as a function of time, e.g:
y value |
| x x
| x x x x
__ _|__________________x__________________x_____
time | 0 1 2 3 4 5 6 7 etc...
What I want to do is swap time for phase angle, so the phase is
somewhere between 0 - 2pi, but the problem is that the phase angle
repeats, so what I was looking for on the axis was something
like:
y value |
|
| x x
| x x x x x
________|__________________x_____________________x__________ _
time | 0 pi/2 pi 3pi/2 0 pi/2 pi 3pi/2 0 etc...
|
end of first cycle, start of second
What I'll probably do is use xtickv and xtickname to set the ticks, since
as far as I can tell, you MUST 'plot, t, y' to get the plot right,
'plot, phase, y' results in the data being merged together and only one
cycle being plotted.
The reason I sent the first post - I was wondering if there was an easier
way than xtickv/xtickname since it can't automatically choose the tick
values like PLOT can, and isn't so flexible when I'm trying to write a
general purpose routine. Time for some more code I think....
cheers,
S
|
|
|
Re: PLOT question [message #22969 is a reply to message #22966] |
Wed, 20 December 2000 16:40  |
davidf
Messages: 2866 Registered: September 1996
|
Senior Member |
|
|
Craig Markwardt (craigmnet@cow.physics.wisc.edu) writes:
> Oops now that I look at the question again, I think maybe Stuart was
> just looking for (T-T0)/P, without the MOD? Or, a way to sandwich
> together many distant cycles? If the latter, that's a bit more
> difficult. A small program would be needed to join these intervals
> together.
Oh, now, writing a *program* is WAY over the top!
Cheers,
David
P.S. Let's just say this is the reason I only suggested
an *idea*. :-)
--
David Fanning, Ph.D.
Fanning Software Consulting
Phone: 970-221-0438 E-Mail: davidf@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
|
|
|
Re: PLOT question [message #22970 is a reply to message #22969] |
Wed, 20 December 2000 16:14  |
Craig Markwardt
Messages: 1869 Registered: November 1996
|
Senior Member |
|
|
Craig Markwardt <craigmnet@cow.physics.wisc.edu> writes:
> Stuart Colley <src@star.ucl.ac.uk> writes:
>
>> I have some data that is periodic, y=f(t) and the data is plotted as
>> plot, t, y The problem is I'd like t to plot phase angle rather than
>> time, the problem being the phase angle is between 0 and 1 and repeats.
>> Attempting to plot the data you just get a plot between 0 and 1, what I'd
>> like to be able to plot is each cycle of the data with it's phase angle.
>>
>> Any ideas on how to get the plot axes right?
>
Oops now that I look at the question again, I think maybe Stuart was
just looking for (T-T0)/P, without the MOD? Or, a way to sandwich
together many distant cycles? If the latter, that's a bit more
difficult. A small program would be needed to join these intervals
together.
Craig
--
------------------------------------------------------------ --------------
Craig B. Markwardt, Ph.D. EMAIL: craigmnet@cow.physics.wisc.edu
Astrophysics, IDL, Finance, Derivatives | Remove "net" for better response
------------------------------------------------------------ --------------
|
|
|
Re: PLOT question [message #22971 is a reply to message #22970] |
Wed, 20 December 2000 16:01  |
Craig Markwardt
Messages: 1869 Registered: November 1996
|
Senior Member |
|
|
Stuart Colley <src@star.ucl.ac.uk> writes:
> I have some data that is periodic, y=f(t) and the data is plotted as
> plot, t, y The problem is I'd like t to plot phase angle rather than
> time, the problem being the phase angle is between 0 and 1 and repeats.
> Attempting to plot the data you just get a plot between 0 and 1, what I'd
> like to be able to plot is each cycle of the data with it's phase angle.
>
> Any ideas on how to get the plot axes right?
It's not clear to me that everybody else is going waaaayyy overboard
here. Stuart hasn't responded so that may be a good or a bad sign.
Are you just asking how to convert linear time into phase? Perhaps
this is best accomplished with the MOD operator. If your signal has
period P, and the starting epoch is T0, then this may do the trick.
phase = (t-t0)/p MOD 1
phase = (phase+1) MOD 1
plot, phase, y
The "MOD 1" takes the remainder when divided by 1, or simply the
fractional value. The "extra" MOD step there is because MOD doesn't
handle negative numbers very well. It maps the segment from -1 to 0
back onto 0 to 1. Another way to do it in one step is
phase = (t-t0)/p
phase = phase - floor(phase)
Craig
--
------------------------------------------------------------ --------------
Craig B. Markwardt, Ph.D. EMAIL: craigmnet@cow.physics.wisc.edu
Astrophysics, IDL, Finance, Derivatives | Remove "net" for better response
------------------------------------------------------------ --------------
|
|
|
Re: PLOT question [message #22977 is a reply to message #22971] |
Wed, 20 December 2000 10:51  |
Paul van Delst
Messages: 364 Registered: March 1997
|
Senior Member |
|
|
Stuart Colley wrote:
>
> I have some data that is periodic, y=f(t) and the data is plotted as
> plot, t, y The problem is I'd like t to plot phase angle rather than
> time, the problem being the phase angle is between 0 and 1 and repeats.
> Attempting to plot the data you just get a plot between 0 and 1, what I'd
> like to be able to plot is each cycle of the data with it's phase angle.
>
> Any ideas on how to get the plot axes right?
If I understand you correctly, you want to remove the discontinuity in your phase angle - like in a
TAN plot that goes from +/- pi or +/- pi/2 ?
If so, one way is to calculate the phase angle derivatives. If there is a change in sign near a
known boundary (0 or 1), you can add or subtract (based on the sign of the derivative) the required
amount to make the phase angle curve continuous.
I did this many years ago in fortan to view the phase of radiometric signals from an interferometer.
They bounced between +/- pi and doing the above made the plot relatively (insert some hand-waving
here) continuous. If you have a noisy signal, then it can get a bit more difficult as the noise can
confuse matters when the signal is close to a boundary, i.e. you get a lot of flipping back and
forth, but then the result is a continuous curve with dropouts which, in some respects, may also be
a useful plot.
If this is not what you mean, then delete this message.
paulv.
--
Paul van Delst Ph: (301) 763-8000 x7274
CIMSS @ NOAA/NCEP Fax: (301) 763-8545
Rm.207, 5200 Auth Rd. Email: pvandelst@ncep.noaa.gov
Camp Springs MD 20746
|
|
|
Re: PLOT question [message #22978 is a reply to message #22977] |
Wed, 20 December 2000 10:32  |
Dave Greenwood
Messages: 33 Registered: October 2000
|
Member |
|
|
Stuart Colley <src@star.ucl.ac.uk> wrote:
>
> I have some data that is periodic, y=f(t) and the data is plotted as
> plot, t, y The problem is I'd like t to plot phase angle rather than
> time, the problem being the phase angle is between 0 and 1 and repeats.
> Attempting to plot the data you just get a plot between 0 and 1, what I'd
> like to be able to plot is each cycle of the data with it's phase angle.
>
> Any ideas on how to get the plot axes right?
If I understand your question correctly and assuming that the phase angle
is a function of t, something like the following might work:
FUNCTION PHASE_ANGLE, axis, index, t
RETURN, STRING(phase angle at time t)
END
..
PLOT, T, Y, XTICKFORMAT='PHASE_ANGLE'
Dave
--------------
Dave Greenwood Email: Greenwoodde@ORNL.GOV
Oak Ridge National Lab %STD-W-DISCLAIMER, I only speak for myself
|
|
|
Re: PLOT question [message #22980 is a reply to message #22978] |
Wed, 20 December 2000 10:16  |
davidf
Messages: 2866 Registered: September 1996
|
Senior Member |
|
|
Stuart Colley (src@star.ucl.ac.uk) writes:
> I have some data that is periodic, y=f(t) and the data is plotted as
> plot, t, y The problem is I'd like t to plot phase angle rather than
> time, the problem being the phase angle is between 0 and 1 and repeats.
> Attempting to plot the data you just get a plot between 0 and 1, what I'd
> like to be able to plot is each cycle of the data with it's phase angle.
>
> Any ideas on how to get the plot axes right?
If you are just looking for ideas, why not use the
plot you have but add the phase angle as a symbol
on the plot? You could have a filled circle for
a phase angle of 1, a half-filled circle for a
phase angle of 0.5, etc.
Shouldn't be too hard to come up with something
like that. :-)
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting
Phone: 970-221-0438 E-Mail: davidf@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
|
|
|