operation on a number of wave

mwpro
Posts: 83
Joined: 2015-03-18
Location: United States

Hi all
I was wondering what would be the best or a good way to perform operation on a number of waves, if they are in the same data folder and if they are in different data folders. It I were to use a loop, what would be an efficient way in moving between the folders or it would just be easier if just put all waves in the same data folder? Thanks!


Posts: 1675
Joined: 2007-06-21
Location: United States

Create a wave reference wave containing references to each of the waves you want to operate on and pass it as a parameter to the function that does the looping.

DisplayHelpTopic "Wave Reference Waves"


mwpro
Posts: 83
Joined: 2015-03-18
Location: United States

Ah thanks hrodstein!


mwpro
Posts: 83
Joined: 2015-03-18
Location: United States

I used the wave reference but assigned the waves outside of the function
my function is as but get the expected assignment operator: =, +=, -+.. when trying to compile, what is wrong? thanks!

function mainroutine()
wave wind_direction_avg
WAVE wr
variable i
 
for (i=0;i<35;i=i+1)
WAVE  w =  wr[i]
 
string east = nameofwave(w) + "_east"
string west = nameofwave(w) +  "_west"
duplicate/o w $east, $west
 
$east =  wind_direction_avg < 180 &&  wind_direction_avg >0  ?   w :   nan
$west = wind_direction_avg <360 && wind_direction_avg > 180  ?  w  :  nan
 
endfor
 
end


tony
Posts: 168
Joined: 2007-08-28
Location: Canada

you need to tell the compiler the wave type for the wave reference wave:

wave /wave wr


Posts: 1675
Joined: 2007-06-21
Location: United States

In addition to needing

WAVE/WAVE wr

instead of
WAVE wr

your use of $east and $west in wave assignment statements will not work. For details, execute:
DisplayHelpTopic "Wave References"

Here is an untested crack at correcting this issue:

Function mainroutine()
	Wave wind_direction_avg
	WAVE/WAVE wr
	Variable i
 
	for (i=0;i<35;i=i+1)
		WAVE w = wr[i]
 
		string eastName = nameofwave(w) + "_east"
		Duplicate/O w, $eastName
		WAVE eastWave = $eastName
		eastWave =  wind_direction_avg < 180 &&  wind_direction_avg >0  ? w : nan
 
		string westName = nameofwave(w) +  "_west"
		Duplicate/O w, $westName
		WAVE westWave = $westName
		westWave = wind_direction_avg <360 && wind_direction_avg > 180 ?  w : nan
	endfor
End


mwpro
Posts: 83
Joined: 2015-03-18
Location: United States

thank you hrodstein!


mwpro
Posts: 83
Joined: 2015-03-18
Location: United States

thank you hrodstein!


mwpro
Posts: 83
Joined: 2015-03-18
Location: United States

thank you hrodstein!


mwpro
Posts: 83
Joined: 2015-03-18
Location: United States

thank you hrodstein!


mwpro
Posts: 83
Joined: 2015-03-18
Location: United States

thank you hrodstein!


Back to top