|
| 1 | +//************************************************************** |
| 2 | +//************************************************************** |
| 3 | + |
| 4 | +// To merge any number of 2D waves selected in the data browser |
| 5 | +// Output is generated in the same folder as "mergedWave2D" |
| 6 | + |
| 7 | +// Usage : select waves in the data browser and run the command |
| 8 | + |
| 9 | +function merge_2Dwaves_to_2D() |
| 10 | + |
| 11 | +string name1 |
| 12 | +variable j, jmax , k |
| 13 | +variable rows, columns |
| 14 | +variable x1,x2 |
| 15 | +variable totalCol |
| 16 | +variable counter |
| 17 | + |
| 18 | + |
| 19 | +// purpose is to count the number of waves selected |
| 20 | +do |
| 21 | + name1 = GETBROWSERSELECTION(j) |
| 22 | + wave wav1=$name1 |
| 23 | + if(strlen(name1)<=0) |
| 24 | + break |
| 25 | + endif |
| 26 | + x1=dimsize(wav1,0) |
| 27 | + j=j+1 |
| 28 | +while(1) |
| 29 | +jmax=j // jmax is the number of selected waves |
| 30 | + |
| 31 | +make /o /d /n=(jmax) tempCol |
| 32 | +wave tempCol |
| 33 | + |
| 34 | +print tempCol |
| 35 | +j=0 |
| 36 | +// purpose is to count the number of columns per wave selected |
| 37 | +do |
| 38 | + name1 = GETBROWSERSELECTION(j) |
| 39 | + wave wav1=$name1 |
| 40 | + if(strlen(name1)<=0) |
| 41 | + break |
| 42 | + endif |
| 43 | + columns=dimsize(wav1,1) |
| 44 | + print columns |
| 45 | + tempCol [j] = columns |
| 46 | + |
| 47 | + counter=counter+columns |
| 48 | + j=j+1 |
| 49 | +while(1) |
| 50 | + |
| 51 | + |
| 52 | +// print counter |
| 53 | + |
| 54 | +// Construct and assign the 2D wave |
| 55 | +make /o /d /n=(x1, counter) mergedWave2D=0 |
| 56 | +wave mergedWave=mergedWave2D |
| 57 | + |
| 58 | +counter=0 |
| 59 | +// Assign the columns of data |
| 60 | +for (j=0 ; j < jmax ; j=j+1) |
| 61 | + |
| 62 | + name1 = GETBROWSERSELECTION(j) |
| 63 | + wave wav1=$name1 |
| 64 | + columns = tempCol [j] |
| 65 | + |
| 66 | + for ( k=0 ; k < columns ; k=k+1) |
| 67 | + |
| 68 | + // print j, k, name1, counter |
| 69 | + mergedWave[][ counter ] = wav1[p][k] |
| 70 | + counter=counter+1 |
| 71 | + endfor |
| 72 | +endfor |
| 73 | + |
| 74 | +totalCol = dimsize (mergedWave, 1) |
| 75 | +printf "\tProcess finished. 'mergedWave2D' created as output with dimensions : %g x %g.\r", x1, totalCol |
| 76 | + |
| 77 | +killwaves /Z tempCol |
| 78 | +end |
| 79 | + |
| 80 | +//************************************************************** |
| 81 | +//************************************************************** |
0 commit comments