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

Home » Public Forums » archive » Reading Multiple .sav files with same variable names for graphing
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
Reading Multiple .sav files with same variable names for graphing [message #88951] Mon, 07 July 2014 07:40 Go to next message
morganlsilverman is currently offline  morganlsilverman
Messages: 46
Registered: February 2013
Member
Hello,

I have 9 .sav files each containing a different days data but with the same set of variable names. I am trying to figure out a better method to read each of these files and save the variables to different named arrays or structures so that I can then plot several days of data in the same graph. The method i've been using right now involves a lot of coding (shown below for first 2 files). Is there a better way to do this so that I can then plot multiple arrays from different .save files on the same graph? Thank you.

Sincerely,
Morgan

restore, './DAQPadonia_AvgBackTraj_Flight7.sav'
Flight7 = {Avg500Lat: fltarr(73), Avg500Lon: fltarr(73), Avg1000Lat: fltarr(73), Avg1000Lon: fltarr(73), $
Avg1500Lat: fltarr(73), Avg1500Lon: fltarr(73), Avg2000Lat: fltarr(73), Avg2000Lon: fltarr(73), Avg2500Lat: fltarr(73), $
Avg2500Lon: fltarr(73), Avg3000Lat: fltarr(73), Avg3000Lon: fltarr(73), Avg3500Lat: fltarr(73), Avg3500Lon: fltarr(73)}
Flight7.Avg500Lat = Avg500Lat
Flight7.Avg500Lon = Avg500Lon
Flight7.Avg1000Lat = Avg1000Lat
Flight7.Avg1000Lon = Avg1000Lon
Flight7.Avg1500Lat = Avg1500Lat
Flight7.Avg1500Lon = Avg1500Lon
Flight7.Avg2000Lat = Avg2000Lat
Flight7.Avg2000Lon = Avg2000Lon
Flight7.Avg2500Lat = Avg2500Lat
Flight7.Avg2500Lon = Avg2500Lon
Flight7.Avg3000Lat = Avg3000Lat
Flight7.Avg3000Lon = Avg3000Lon
Flight7.Avg3500Lat = Avg3500Lat
Flight7.Avg3500Lon = Avg3500Lon
restore, './DAQPadonia_AvgBackTraj_Flight6.sav'
Flight6 = {Avg500Lat: fltarr(73), Avg500Lon: fltarr(73), Avg1000Lat: fltarr(73), Avg1000Lon: fltarr(73), $
Avg1500Lat: fltarr(73), Avg1500Lon: fltarr(73), Avg2000Lat: fltarr(73), Avg2000Lon: fltarr(73), Avg2500Lat: fltarr(73), $
Avg2500Lon: fltarr(73), Avg3000Lat: fltarr(73), Avg3000Lon: fltarr(73), Avg3500Lat: fltarr(73), Avg3500Lon: fltarr(73)}
Flight6.Avg500Lat = Avg500Lat
Flight6.Avg500Lon = Avg500Lon
Flight6.Avg1000Lat = Avg1000Lat
Flight6.Avg1000Lon = Avg1000Lon
Flight6.Avg1500Lat = Avg1500Lat
Flight6.Avg1500Lon = Avg1500Lon
Flight6.Avg2000Lat = Avg2000Lat
Flight6.Avg2000Lon = Avg2000Lon
Flight6.Avg2500Lat = Avg2500Lat
Flight6.Avg2500Lon = Avg2500Lon
Flight6.Avg3000Lat = Avg3000Lat
Flight6.Avg3000Lon = Avg3000Lon
Flight6.Avg3500Lat = Avg3500Lat
Flight6.Avg3500Lon = Avg3500Lon
Re: Reading Multiple .sav files with same variable names for graphing [message #88952 is a reply to message #88951] Mon, 07 July 2014 07:47 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Morgan Silverman writes:

> I have 9 .sav files each containing a different days data but with the same set of variable names. I am trying to figure out a better method to read each of these files and save the variables to different named arrays or structures so that I can then plot several days of data in the same graph. The method i've been using right now involves a lot of coding (shown below for first 2 files). Is there a better way to do this so that I can then plot multiple arrays from
different .save files on the same graph? Thank you.

Typically, things like this are done in a loop. :-)

Cheers,

David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thue. ("Perhaps thou speakest truth.")
Re: Reading Multiple .sav files with same variable names for graphing [message #88955 is a reply to message #88952] Mon, 07 July 2014 08:11 Go to previous messageGo to next message
morganlsilverman is currently offline  morganlsilverman
Messages: 46
Registered: February 2013
Member
On Monday, July 7, 2014 10:47:01 AM UTC-4, David Fanning wrote:
> Morgan Silverman writes:
>
>
>
>> I have 9 .sav files each containing a different days data but with the same set of variable names. I am trying to figure out a better method to read each of these files and save the variables to different named arrays or structures so that I can then plot several days of data in the same graph. The method i've been using right now involves a lot of coding (shown below for first 2 files). Is there a better way to do this so that I can then plot multiple arrays from
>
> different .save files on the same graph? Thank you.
>
>
>
> Typically, things like this are done in a loop. :-)
>
>
>
> Cheers,
>
>
>
> David
>
> --
>
> David Fanning, Ph.D.
>
> Fanning Software Consulting, Inc.
>
> Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
>
> Sepore ma de ni thue. ("Perhaps thou speakest truth.")

Right, of course :-) I started creating a loop but ran into trouble when I wanted to rename the structure or variables each loop iteration. I tried doing something like the following but run into trouble creating the temp variable name to use for each new structure and then using it. How do I create a new named structure or array each loop?

for i=0,0 do begin
flightnum = [5,10,14,4,8,11,2,6,7]
flight = flightnum(i)
restore, './DAQPadonia_AvgBackTraj_Flight'+strtrim(flight,2)+'.sav'
temp = 'Flight'+strtrim(i,2)
temp = {Avg500Lat: fltarr(73), Avg500Lon: fltarr(73), Avg1000Lat: fltarr(73), Avg1000Lon: fltarr(73), $
Avg1500Lat: fltarr(73), Avg1500Lon: fltarr(73), Avg2000Lat: fltarr(73), Avg2000Lon: fltarr(73)}
Flight5.Avg500Lat = Avg500Lat
Re: Reading Multiple .sav files with same variable names for graphing [message #88956 is a reply to message #88955] Mon, 07 July 2014 08:15 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Morgan Silverman writes:

> Right, of course :-) I started creating a loop but ran into trouble when I wanted to rename the structure or variables each loop iteration. I tried doing something like the following but run into trouble creating the temp variable name to use for each new structure and then using it. How do I create a new named structure or array each loop?
>

Off the top of my head, I can't think of any reason why you would NEED a
structure if you are doing this in a loop.

If you need the variables for later, just make an array of structures:

struct = {...}
varStructs = Replicate(struct, n)

Cheers,

David

--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thue. ("Perhaps thou speakest truth.")
Re: Reading Multiple .sav files with same variable names for graphing [message #88972 is a reply to message #88951] Wed, 09 July 2014 08:02 Go to previous message
Russell Ryan is currently offline  Russell Ryan
Messages: 122
Registered: May 2012
Senior Member
Why not use the IDL_Savefile object?

http://www.exelisvis.com/docs/idl_savefile.html#objects_misc _904195448_1076956

I can show examples if that helps?

R



On Monday, July 7, 2014 10:40:58 AM UTC-4, Morgan Silverman wrote:
> Hello,
>
>
>
> I have 9 .sav files each containing a different days data but with the same set of variable names. I am trying to figure out a better method to read each of these files and save the variables to different named arrays or structures so that I can then plot several days of data in the same graph. The method i've been using right now involves a lot of coding (shown below for first 2 files). Is there a better way to do this so that I can then plot multiple arrays from different .save files on the same graph? Thank you.
>
>
>
> Sincerely,
>
> Morgan
>
>
>
> restore, './DAQPadonia_AvgBackTraj_Flight7.sav'
>
> Flight7 = {Avg500Lat: fltarr(73), Avg500Lon: fltarr(73), Avg1000Lat: fltarr(73), Avg1000Lon: fltarr(73), $
>
> Avg1500Lat: fltarr(73), Avg1500Lon: fltarr(73), Avg2000Lat: fltarr(73), Avg2000Lon: fltarr(73), Avg2500Lat: fltarr(73), $
>
> Avg2500Lon: fltarr(73), Avg3000Lat: fltarr(73), Avg3000Lon: fltarr(73), Avg3500Lat: fltarr(73), Avg3500Lon: fltarr(73)}
>
> Flight7.Avg500Lat = Avg500Lat
>
> Flight7.Avg500Lon = Avg500Lon
>
> Flight7.Avg1000Lat = Avg1000Lat
>
> Flight7.Avg1000Lon = Avg1000Lon
>
> Flight7.Avg1500Lat = Avg1500Lat
>
> Flight7.Avg1500Lon = Avg1500Lon
>
> Flight7.Avg2000Lat = Avg2000Lat
>
> Flight7.Avg2000Lon = Avg2000Lon
>
> Flight7.Avg2500Lat = Avg2500Lat
>
> Flight7.Avg2500Lon = Avg2500Lon
>
> Flight7.Avg3000Lat = Avg3000Lat
>
> Flight7.Avg3000Lon = Avg3000Lon
>
> Flight7.Avg3500Lat = Avg3500Lat
>
> Flight7.Avg3500Lon = Avg3500Lon
>
> restore, './DAQPadonia_AvgBackTraj_Flight6.sav'
>
> Flight6 = {Avg500Lat: fltarr(73), Avg500Lon: fltarr(73), Avg1000Lat: fltarr(73), Avg1000Lon: fltarr(73), $
>
> Avg1500Lat: fltarr(73), Avg1500Lon: fltarr(73), Avg2000Lat: fltarr(73), Avg2000Lon: fltarr(73), Avg2500Lat: fltarr(73), $
>
> Avg2500Lon: fltarr(73), Avg3000Lat: fltarr(73), Avg3000Lon: fltarr(73), Avg3500Lat: fltarr(73), Avg3500Lon: fltarr(73)}
>
> Flight6.Avg500Lat = Avg500Lat
>
> Flight6.Avg500Lon = Avg500Lon
>
> Flight6.Avg1000Lat = Avg1000Lat
>
> Flight6.Avg1000Lon = Avg1000Lon
>
> Flight6.Avg1500Lat = Avg1500Lat
>
> Flight6.Avg1500Lon = Avg1500Lon
>
> Flight6.Avg2000Lat = Avg2000Lat
>
> Flight6.Avg2000Lon = Avg2000Lon
>
> Flight6.Avg2500Lat = Avg2500Lat
>
> Flight6.Avg2500Lon = Avg2500Lon
>
> Flight6.Avg3000Lat = Avg3000Lat
>
> Flight6.Avg3000Lon = Avg3000Lon
>
> Flight6.Avg3500Lat = Avg3500Lat
>
> Flight6.Avg3500Lon = Avg3500Lon
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Projected Meter Space and mapCoord
Next Topic: IDL project build scripts?

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

Current Time: Wed Oct 08 13:36:09 PDT 2025

Total time taken to generate the page: 0.00580 seconds