Split Channel Into 3D Channel


Recommended Posts

Hi,

 

I have a channel with a big long history that I would like to chop into smaller chunks and store each chunk in a new column (so creating another array dimension) and then plotting as a contour graph. Had a look at the histogram function but couldn't really work it out.

Firstly I would like to do this on time resolved data where I take all of the data between two time periods and bin it into a 3D array, for example:

bin data every 5 seconds

 

15y07m20d 16h26m10   1

15y07m20d 16h26m11   1

15y07m20d 16h26m12   1

15y07m20d 16h26m13   1 

15y07m20d 16h26m14   1

15y07m20d 16h26m15   1

15y07m20d 16h26m16   2 

15y07m20d 16h26m17   2

15y07m20d 16h26m18   2

15y07m20d 16h26m19   2

15y07m20d 16h26m20   2

15y07m20d 16h26m21   3

......etc

 

would produce

 

15y07m20d 16h26m11   1    1    1    1    1    

15y07m20d 16h26m16   2    2    2    2    2 

15y07m20d 16h26m21   3

.....etc

 

then also do it on data read from a file where all the daqfactory time stamps are the same but there is a value for time and a value to chop up:

 

15y07m20d 16h26m10    20    1

15y07m20d 16h26m10    21    1

15y07m20d 16h26m10    22    1

15y07m20d 16h26m10    23    1

15y07m20d 16h26m10    24    1

15y07m20d 16h26m10    25    1

15y07m20d 16h26m10    26    2

15y07m20d 16h26m10    27    2

15y07m20d 16h26m10    28    2

15y07m20d 16h26m10    29    2

15y07m20d 16h26m10    30    2

15y07m20d 16h26m10    31    3

....etc

 

would produce

 

15y07m20d 16h26m10    21    1    1    1    1    1

15y07m20d 16h26m10    26    2    2    2    2    2

15y07m20d 16h26m10    31    3

 

....etc

 

obviously the values wouldn't all be 1's and 2's but real values from a device

 

Any ideas?

 

Many thanks

Steve 

 

 

Link to comment
Share on other sites

I'm not completely sure what you want to do, but you'll likely need to use a little bit of a loop (maybe not if you can avoid it) and a combination of array subsetting and the transpose function.

 

For example, if you wanted to take the last 15 readings (a 15x1 array) of channel "in" and convert it into 3 rows and 5 columnes (3x5), you'd do:

 

global out

for (private i = 0, i < 15, i+=5)

   out[i/5] = transpose(in[i,i+4],1)

endfor

Link to comment
Share on other sites

Thanks,

 

I got it working with the loop below but i'll try your way too and see which is faster

 

for (i = 0, i < NumRows(dataset), i++)
   for (private n = 0, n < (array_depth - 1), n++) 
      v.sliced_data[n] = dataset
    endfor

endfor 

 

Cheers

Steve

Link to comment
Share on other sites

I can't get the transpose function working which I would like to as i think will be faster than nested loops

 

passed global variables are:

array_depth = 1000

total_datapoints = NumRows(dataset) 

 
 
 
//for (i = 0, i < total_datapoints, i+=(array_depth))
 //  v.sliced_data[i/array_depth] = transpose(dataset[i,i+array_depth],1)
//endfor
 
I just get "C1004 Unknown error setting value"
Link to comment
Share on other sites

You can't set V channels that way.  They can only be set like Channels.  So, you can do:

 

V.sliced_data = 3

 

and it will put 3 at the top of the V.sliced_data array, but any subsetting into the V channel is read-only, same as channels.  You instead have to use variables:

 

global sliced_data
global dataset = seqadd(0,1,100000)
private array_depth = 1000
private total_datapoints = NumRows(dataset) 
 
for (private i = 0, i < total_datapoints, i+=(array_depth))
   sliced_data[i/array_depth] = transpose(dataset[i,i+array_depth],1)
endfor
 
You might be able to then assign the result to a v channel in one go, but why bother? 
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.