* fix channel dependent buffer offset, issue #15
* add python example multichannel.py
This commit is contained in:
parent
46db4f3fe8
commit
89b7f045a4
@ -318,16 +318,16 @@ namespace imc
|
||||
// convert buffer to actual datatype
|
||||
void convert_buffer()
|
||||
{
|
||||
// TODO no clue how/if/when to handle buffer offset/mask/subsequent_bytes
|
||||
// etc. and whatever that shit is!
|
||||
std::vector<imc::parameter> prms = blocks_->at(chnenv_.CSuuid_).get_parameters();
|
||||
if ( prms.size() < 4)
|
||||
{
|
||||
throw std::runtime_error("CS block is invalid and features to few parameters");
|
||||
}
|
||||
|
||||
// extract (channel dependent) part of buffer
|
||||
unsigned long int buffstrt = prms[3].begin();
|
||||
std::vector<unsigned char> CSbuffer( buffer_->begin()+buffstrt+1,
|
||||
buffer_->begin()+buffstrt+buffer_size_+1 );
|
||||
std::vector<unsigned char> CSbuffer( buffer_->begin()+buffstrt+buffer_offset_+1,
|
||||
buffer_->begin()+buffstrt+buffer_offset_+buffer_size_+1 );
|
||||
|
||||
// determine number of values in buffer
|
||||
unsigned long int num_values = (unsigned long int)(CSbuffer.size()/(signbits_/8));
|
||||
|
24
python/examples/multichannel.py
Normal file
24
python/examples/multichannel.py
Normal file
@ -0,0 +1,24 @@
|
||||
|
||||
import IMCtermite
|
||||
import pandas
|
||||
|
||||
if __name__ == "__main__" :
|
||||
|
||||
imctm = IMCtermite.imctermite(b"Measurement.raw")
|
||||
|
||||
chns = imctm.get_channels(True)
|
||||
|
||||
df = pandas.DataFrame()
|
||||
|
||||
xcol = "time ["+chns[0]['xunit']+"]"
|
||||
df[xcol] = pandas.Series(chns[0]['xdata'])
|
||||
|
||||
for idx,chn in enumerate(chns) :
|
||||
#xcol = (chn['xname'] if chn['xname'] != '' else "x_"+str(idx))+" ["+chn['xunit']+"]"
|
||||
#df[xcol] = pandas.Series(chn['xdata'])
|
||||
ycol = chn['yname']+" ["+chn['yunit']+"]"
|
||||
df[ycol] = pandas.Series(chn['ydata'])
|
||||
|
||||
print(df)
|
||||
df.to_csv("Measurement.csv",header=True,sep='\t',index=False)
|
||||
|
Loading…
x
Reference in New Issue
Block a user