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

Home » Public Forums » archive » Plotting one point per loop
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 one point per loop [message #91391] Wed, 08 July 2015 10:32 Go to next message
wdolan is currently offline  wdolan
Messages: 29
Registered: June 2015
Junior Member
*new user here!

So I have a set of scans that make up one 'run', and I have a loop that calculates a certain value for each scan. I want to plot that value against the longitude of the scan, so that at the end I get a graph that plots the value vs. the longitude on one graph for all the scans in that run. If you need clarification let me know!

I've got the variables figured out, but it doesn't want to let me plot a singular point on a graph, and then loop over it and plot more singular points on that same graph. I've tried just the plots command, with no luck.

Thanks for the help!
Re: Plotting one point per loop [message #91392 is a reply to message #91391] Wed, 08 July 2015 10:46 Go to previous messageGo to next message
Paul Van Delst[1] is currently offline  Paul Van Delst[1]
Messages: 1157
Registered: April 2002
Senior Member
Hello,

On 07/08/15 13:32, wdolan@oxy.edu wrote:
> *new user here!
>
> So I have a set of scans that make up one 'run', and I have a loop
> that calculates a certain value for each scan. I want to plot that
> value against the longitude of the scan, so that at the end I get a
> graph that plots the value vs. the longitude on one graph for all the
> scans in that run. If you need clarification let me know!
>
> I've got the variables figured out, but it doesn't want to let me
> plot a singular point on a graph, and then loop over it and plot more
> singular points on that same graph. I've tried just the plots
> command, with no luck.

Direct or function graphics?

Either way, why not just do a single plot of all the points at the end
of a 'run', rather than as you go for each scan? That is, one mondo plot
outside the scan loop.

That way you don't have to keep track of the plot window, plot bounds,
etc etc..

And it'll prolly be faster too.

cheers,

paulv
Re: Plotting one point per loop [message #91393 is a reply to message #91392] Wed, 08 July 2015 10:52 Go to previous messageGo to next message
wdolan is currently offline  wdolan
Messages: 29
Registered: June 2015
Junior Member
Hi Paul,

It is set to plot to a postscript file. That seems like a good idea, but I am not sure how to store those values until the end. Because if I did an array, I would have to specify a size, and each run has a different number of scans.

Thanks,

Wayana


On Wednesday, July 8, 2015 at 10:46:56 AM UTC-7, Paul van Delst wrote:
> Hello,
>
> On 07/08/15 13:32, wdolan@oxy.edu wrote:
>> *new user here!
>>
>> So I have a set of scans that make up one 'run', and I have a loop
>> that calculates a certain value for each scan. I want to plot that
>> value against the longitude of the scan, so that at the end I get a
>> graph that plots the value vs. the longitude on one graph for all the
>> scans in that run. If you need clarification let me know!
>>
>> I've got the variables figured out, but it doesn't want to let me
>> plot a singular point on a graph, and then loop over it and plot more
>> singular points on that same graph. I've tried just the plots
>> command, with no luck.
>
> Direct or function graphics?
>
> Either way, why not just do a single plot of all the points at the end
> of a 'run', rather than as you go for each scan? That is, one mondo plot
> outside the scan loop.
>
> That way you don't have to keep track of the plot window, plot bounds,
> etc etc..
>
> And it'll prolly be faster too.
>
> cheers,
>
> paulv
Re: Plotting one point per loop [message #91395 is a reply to message #91391] Wed, 08 July 2015 11:15 Go to previous messageGo to next message
Craig Markwardt is currently offline  Craig Markwardt
Messages: 1869
Registered: November 1996
Senior Member
On Wednesday, July 8, 2015 at 1:32:28 PM UTC-4, wdo...@oxy.edu wrote:
> *new user here!
>
> So I have a set of scans that make up one 'run', and I have a loop that calculates a certain value for each scan. I want to plot that value against the longitude of the scan, so that at the end I get a graph that plots the value vs. the longitude on one graph for all the scans in that run. If you need clarification let me know!
>
> I've got the variables figured out, but it doesn't want to let me plot a singular point on a graph, and then loop over it and plot more singular points on that same graph. I've tried just the plots command, with no luck.
>
> Thanks for the help!

;; Example longitude from 0 to 360, value from -100 to 100
PLOT, [0, 360], [-100,100], /nodata
for i = 0, Ndata-1 do begin
;; ... do whatever it takes to get your next point ...
lon_i = ...blah blah blah...
val_i = ...blah blah blah...
OPLOT, [lon_i], [lat_i], psym=1
endfor

Done!
Re: Plotting one point per loop [message #91397 is a reply to message #91393] Wed, 08 July 2015 11:33 Go to previous messageGo to next message
Paul Van Delst[1] is currently offline  Paul Van Delst[1]
Messages: 1157
Registered: April 2002
Senior Member
On 07/08/15 13:52, wdolan@oxy.edu wrote:
> Hi Paul,
>
> It is set to plot to a postscript file. That seems like a good idea,
> but I am not sure how to store those values until the end. Because if
> I did an array, I would have to specify a size, and each run has a
> different number of scans.

Fair enough.

Craig answered your actual question (thank goodness! :o). I went off on
a tangent about efficient ways to increase array sizes when you don't
know the final size, so that you can then plot (mostly because you said
you were a new user :o)

Keep reading only for sh*ts and giggles.

As an exercise (my actual work today is a bit repetitive) I came up with
the code way down below. When I run it I get the following:

IDL> .run blah.pro
% Compiled module: $MAIN$.
% Time elapsed: 16.238165 seconds.
X FLOAT = Array[300000]
% Time elapsed: 0.20202398 seconds.
X FLOAT = Array[300000]

The doubling method is pretty efficient. Way better than simple
concatenation. If you increase the number of scans to 1000000 then the
first method will be done sometime tomorrow....



; The (generally unknown) number of scans for this example
n_scans = 300000L


; METHOD #1: CONTINUALLY CONCATENATE ONTO ARRAY

; Specify an empty array
x = []

; Loop over your (unknown) number of scans
scan_count = 0
tic
repeat begin
; Keep track of the scan count
scan_count++
; Accumulate an array of numbers to plot
x = [x,randomn(seed,1)]
endrep until scan_count eq n_scans
toc
help, x


; METHOD #2: DOUBLE SIZE OF ARRAY AS NEEDED
; (HAM FISTED CODE, BUT YOU GET THE IDEA)

; Specify an empty array and initial size
n_size = 10000L
x = fltarr(1000)

; Loop over your (unknown) number of scans
scan_count = 0
tic
repeat begin
; Keep track of the scan count
scan_count++
; Double array size if necessary
if ( n_elements(x) lt scan_count ) then begin
n = n_elements(x)
x = [temporary(x),fltarr(n)]
endif
; Insert value into array
x[scan_count-1] = randomn(seed,1)
endrep until scan_count eq n_scans
; Truncate array as necessary
x = x[0:scan_count-1]
toc
help, x

end




cheers,

paulv
Re: Plotting one point per loop [message #91398 is a reply to message #91391] Wed, 08 July 2015 13:13 Go to previous message
wdolan is currently offline  wdolan
Messages: 29
Registered: June 2015
Junior Member
Oh man, thank you both! Problem solved :)

On Wednesday, July 8, 2015 at 10:32:28 AM UTC-7, wdo...@oxy.edu wrote:
> *new user here!
>
> So I have a set of scans that make up one 'run', and I have a loop that calculates a certain value for each scan. I want to plot that value against the longitude of the scan, so that at the end I get a graph that plots the value vs. the longitude on one graph for all the scans in that run. If you need clarification let me know!
>
> I've got the variables figured out, but it doesn't want to let me plot a singular point on a graph, and then loop over it and plot more singular points on that same graph. I've tried just the plots command, with no luck.
>
> Thanks for the help!
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: READ, adn get data into an array from LARGE SIZE FILES
Next Topic: Leap Seconds and JULDAY()

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

Current Time: Wed Oct 08 09:14:59 PDT 2025

Total time taken to generate the page: 0.00428 seconds