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

Home » Public Forums » archive » Dynamically naming structures in IDL
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Dynamically naming structures in IDL [message #91572 is a reply to message #91563] Thu, 30 July 2015 07:04 Go to previous messageGo to previous message
Scheherazade is currently offline  Scheherazade
Messages: 4
Registered: July 2015
Junior Member
On Wednesday, July 29, 2015 at 5:16:43 PM UTC-4, wlandsman wrote:
> Oops that should be
>
> status = execute("'save, ' + newname +', file = '/Users/me/Documents/omni_general_'+year+'.sav' ")
>>
>
> On Wednesday, July 29, 2015 at 4:46:02 PM UTC-4, wlandsman wrote:
>> What if you also put the SAVE statement in execute()
>>
>> status = execute("save, newname, file = '/Users/me/Documents/omni_general_'+year+'.sav' ")
>>
>> On Wednesday, July 29, 2015 at 3:12:17 PM UTC-4, Scheherazade wrote:
>>> On Wednesday, July 29, 2015 at 2:23:10 PM UTC-4, wlandsman wrote:
>>>> If I understand correctly, you could use EXECUTE() to rename your structure:
>>>>
>>>> newname = 'new_structure_' + year
>>>> status = execute( newname + '= TEMPORARY(new_variables)' )
>>>> save, newname, filename = '/Users/me/Documents/omni_general_'+year+'.sav'
>>>>
>>>>
>>>> On Wednesday, July 29, 2015 at 1:08:52 PM UTC-4, Scheherazade wrote:
>>>> > I have a structure, 'omni_gen', which is filled with data for 2011, 2012, and 2013. In my program, I pull data out based on year (which is input) using a where statement, create variables for the selected data, and run these variables through a routine which outputs a new set of variables. I want to save these new variables to a structure, so I can later concatenate them together to plot.
>>>> >
>>>> > I first save my structure to a different filename each time:
>>>> >
>>>> > year=strcompress(string(year), /remove_all)
>>>> >
>>>> > new_variables=create_struct('new_globtec_'+year, new_globtec, 'new_day_'+year, new_day_numb, 'new_f10_'+year, new_f10_data, $
>>>> > 'new_ap_'+year, new_ap_data, 'new_smf10_'+year, new_smf10)
>>>> >
>>>> > save, new_variables, filename='/Users/me/Documents/omni_general_'+year+'.sav'
>>>> >
>>>> > When I go to concatenate the structures, I restore these files and manually rename the corresponding new_variables structure each time, like so:
>>>> >
>>>> > restore, '/Users/keleuterio/Documents/omni_2011.sav'
>>>> > new_variables=omni_data_2011
>>>> >
>>>> > But this obviously isn't automated. Is there a different way to do this so that the structure itself will have a different name each time (ex: new_structure_2011, new_structure_2012)?
>>>
>>> That successfully renamed the structure while in the program, but it doesn't work when I restore the file later (since it saves newname, not the new structure).

IDL responded with a "syntax error" on the save. I've been removing/adding quotation marks within that line to fix it, but it gives the same error message each time. I also tried saving the two commands as strings, then executing them (which is how execute is used in the Exelis Vis help page http://www.exelisvis.com/docs/EXECUTE.html ):

status = execute( newname + '= TEMPORARY(new_variables)' )
status1=('save' + "newname + file='/Users/keleuterio/Documents/omni_general_' + year + '.sav'")
status2=execute("status1")

But IDL responds with "% Attempt to call undefined procedure/function: 'STATUS1'". I think that it's mostly a matter of putting the quotation marks in the right place, but I don't fully understand how the Execute command recognizes the difference between a procedure (such as save) and a string (such as the filepath).
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Skip file during loop based on subprocess
Next Topic: Which "PATH" did IDL use???

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

Current Time: Wed Oct 08 11:47:50 PDT 2025

Total time taken to generate the page: 0.00234 seconds