Make a 2D wave from multiple 1D waves

akablackmumba
Posts: 2
Joined: 2017-06-09
Location: Japan

Hi.
I am totally new to Igor pro and I got stucked in making a 2D wave from multiple 1D waves that I currently have.

The situation is something like:
I have several 1D wave data, and I want to make a 2D wave from those 1D waves, for instance.

In command line, if I write like:

Make/o/n=(18, 3000) wave2D
wave[0][] = root:results:wave170101001[q]
wave[1][] = root:results:wave170101002[q]
wave[2][] = root:results:wave170101003[q]
.
.
.
.
Here wave170101xxx are 1D waves I have.

It's easy to make a 2D wave if I just want to put 2 or 3 1D waves inside, but it becomes quite time-consuming if I want to have many, let's say, 20 or even more 1D waves to make a 2D wave, by just typing these commands in sequence.

I am trying to make a macros that allows me to just input a "start wave" and "end wave" to automatically generate a 2D wave that contains all 1D waves between the "start" and "end". But I don't even know where to start.

Any suggestions? I'd be definitely very appreciated if you guys would help me out with this.
Thank you very much in advance.


hegedus
Posts: 268
Joined: 2009-03-21
Location: United States

The place I would recommend starting is to look at the concatenate function.

Concatenate [ /DL /KILL /NP[=dim ] /O] [typeFlags ] waveListStr, destWave

It does a number of things for you:
1. It takes a list of 1D waves and creates a 2D wave from them unless you force non-promotion flag
2. You don't need to create the recipient wave ahead of time just give it a name
3. It takes a wave list string as an input

The choice for you would be how to create the wave list string and your description needs a bit more clarity. You say start and end, how are those described? For example is there a starting number and ending number as part of the wave names? Are the waves consecutively numbered..

Also what is the usage you see going forward. If this is to be done a lot you might want to spend. For occasional use for example a work flow could be
1. Make a temp folder
2. drag copies of waves to made into a 2D wave into that folder
3. Make that folder the active folder
4. concatenate/Kill (Wavelist("*",";",""), NewwaveName

This would leave a single wave, NewwaveName, as a 2D wave.

If you are going to do this a great number of times then I would create a function that returns the wave list with only the names needed.

Andy


akablackmumba
Posts: 2
Joined: 2017-06-09
Location: Japan

hegedus wrote:
The place I would recommend starting is to look at the concatenate function.

Concatenate [ /DL /KILL /NP[=dim ] /O] [typeFlags ] waveListStr, destWave

It does a number of things for you:
1. It takes a list of 1D waves and creates a 2D wave from them unless you force non-promotion flag
2. You don't need to create the recipient wave ahead of time just give it a name
3. It takes a wave list string as an input

The choice for you would be how to create the wave list string and your description needs a bit more clarity. You say start and end, how are those described? For example is there a starting number and ending number as part of the wave names? Are the waves consecutively numbered..

Also what is the usage you see going forward. If this is to be done a lot you might want to spend. For occasional use for example a work flow could be
1. Make a temp folder
2. drag copies of waves to made into a 2D wave into that folder
3. Make that folder the active folder
4. concatenate/Kill (Wavelist("*",";",""), NewwaveName

This would leave a single wave, NewwaveName, as a 2D wave.

If you are going to do this a great number of times then I would create a function that returns the wave list with only the names needed.

Andy

Thank you so much for your reply.
By "start wave" and "end wave", I actually want to create an user interface, to prompt 2 input options, something like:
start wave = wave170101005
end wave = wave170101027

These waves are consecutively numbered, the only difference is last 3 digits, for e.g. 170101xxx, xxx is ranging from 001 to maybe 100, depending on how many data I collected.


hegedus
Posts: 268
Joined: 2009-03-21
Location: United States

Hi,

The you can create a function that returns a list

Function/S MakeWaveList(StartV,EndV) //S flag to signal it is going to return a string
   variable startV, endV
 
  variable index
  string ItemString, ReturnString
  ReturnString =""
 
  for(index=startV; index<=EndV;index+=1)
    sprintf itemString "wave170101%03d", index  // this makes the individual list item
    ReturnString +=(ItemString +";") // adds individual item to the overall list
  endfor
 
  return ReturnString
End

You may want to add some error checking in case the first number is larger than the second. Also in the sprinf line I assumed that the individual wave name would be a sequence with leading zeros to be 3 characters in length. That is what %03d code in sprintf does. If your actual use case is different that will need to be amended.

Andy


Back to top