automate wave creation and wave calling


I am really new with Igor pro and struggling with my data analysis. I am running a for loop and in each run I want to copy the output wave to a new wave. I want to automate the new wave creation and then copying the data to each new wave from each run. I have to create like 100s of new waves, so, need to automate it somehow.



It would be great if you could explain a bit more what you are trying to do, so that we can help you better (and may even be able to suggest a completely different approach). If you want to copy data as is the Duplicate command is your friend. Here you can learn more:

DisplayHelpTopic "Duplicate"

But to be honest, duplicating hundreds of waves seems a bit overkill to me. There may be another way to achieve what you want.

Thank you for your reply. So, I have the air sampling data of 10 years. I want to segregate the data according to different time scenarios like yearly, monthly, day etc. So, I take the master data wave and extract from it and put in different waves using a for loop. The destination wave in extract function gets overwritten every time. So, I take the data from the destination wave and copy it to a new wave. This happens for every run when the loop runs. So, I want in someway to change the wave where destination wave copies the data in each run. Here is the code, just the part of it. I know its not elegant. I am really a beginner, and use Igor only once or twice in a few years.


variable n,start_day=1,end_day=31
make/d/o/n=(8784,10) yearly_data=0, yearly_data_indx
SetScale d 0, 0, "dat", yearly_data


        start_time = date2secs(YRS[n],MNTH[0],start_day)		
        stop_time = date2secs(YRS[n],MNTH[11],end_day)+23*3600
	extract Date_time,dest, Date_time>=start_time && Date_time<=stop_time  


I see. In your code you could give your destination wave a new name every time the extract function runs. This will then create a new wave every time without the need to copy anything. It may look like this:

String OutputName = "output_" + num2str(n)
Extract Date_time, $OutputName , Date_time>=start_time && Date_time<=stop_time  

This will result in waves with names output_0, output_1, output_2 and so on. Note the use of the $ character which convert strings into 'reverences'. You will use it a lot. This $ conversion usually confuses a lot of new users, so you better get used to it now. :)

In reply to by chozo

Thanks a million. This is exactly what I was looking for. I read about wave referencing, but couldn't understand enough. I am not good with programming. I'll try to understand the $ conversion more.. :)


Being new t programming is where everyone starts, no need for apologies.  Also when someone is new it is very difficult to reference the manual since you may not know what to look for.  I had the worst programming teacher (self taught) and I found the best way to help is to be clear as to what problem you would like to solve in your inquiry. Chozo is providing the same guidance in framing the question. For example, often times if I want to process a large number of input waves my interest maybe only in getting a parameter or two from the analysis.  In those cases it is not needed to create the output wave and I will "reuse" the same wave over in the loop. An example is when I do particle analysis on a folder of images, where I just want the number of particles and average size from each image.  It would take a lot space to keep output waves if I had 1000's of images as opposed to two numbers per image.

The folks here enjoy helping and please take their input in that spirit, but also let us help to the fullest extent with some background of why you need to do something.


Also, if you're new to Igor, please take the time to go through the Guided Tour. It will probably save you a lot of time in the future. Use the Help->Getting Started menu item to find it.