Compare commits
7 Commits
9c69e94102
...
v2.0.8
Author | SHA1 | Date | |
---|---|---|---|
55f093156d | |||
ff69c329cc | |||
d0accd6e0b | |||
89b7f045a4 | |||
46db4f3fe8 | |||
ef0bb7550d | |||
730b3dad83 |
@@ -318,16 +318,16 @@ namespace imc
|
|||||||
// convert buffer to actual datatype
|
// convert buffer to actual datatype
|
||||||
void convert_buffer()
|
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();
|
std::vector<imc::parameter> prms = blocks_->at(chnenv_.CSuuid_).get_parameters();
|
||||||
if ( prms.size() < 4)
|
if ( prms.size() < 4)
|
||||||
{
|
{
|
||||||
throw std::runtime_error("CS block is invalid and features to few parameters");
|
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();
|
unsigned long int buffstrt = prms[3].begin();
|
||||||
std::vector<unsigned char> CSbuffer( buffer_->begin()+buffstrt+1,
|
std::vector<unsigned char> CSbuffer( buffer_->begin()+buffstrt+buffer_offset_+1,
|
||||||
buffer_->begin()+buffstrt+buffer_size_+1 );
|
buffer_->begin()+buffstrt+buffer_offset_+buffer_size_+1 );
|
||||||
|
|
||||||
// determine number of values in buffer
|
// determine number of values in buffer
|
||||||
unsigned long int num_values = (unsigned long int)(CSbuffer.size()/(signbits_/8));
|
unsigned long int num_values = (unsigned long int)(CSbuffer.size()/(signbits_/8));
|
||||||
|
@@ -236,13 +236,27 @@ namespace imc
|
|||||||
// provide UUID for channel
|
// provide UUID for channel
|
||||||
chnenv.uuid_ = chnenv.CNuuid_;
|
chnenv.uuid_ = chnenv.CNuuid_;
|
||||||
|
|
||||||
|
// for multichannel data there may be multiple channels referring to
|
||||||
|
// the same (final) CS block (in contrast to what the IMC software
|
||||||
|
// documentation seems to suggest) resulting in all channels missing
|
||||||
|
// a CS block except for the very last
|
||||||
|
if ( chnenv.CSuuid_.empty() ) {
|
||||||
|
for ( imc::block blkCS: rawblocks_ ) {
|
||||||
|
if ( blkCS.get_key().name_ == "CS"
|
||||||
|
&& blkCS.get_begin() > (unsigned long int)stol(chnenv.uuid_) ) {
|
||||||
|
chnenv.CSuuid_ = blkCS.get_uuid();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// create channel object and add it to the map of channels
|
// create channel object and add it to the map of channels
|
||||||
channels_.insert( std::pair<std::string,imc::channel>
|
channels_.insert( std::pair<std::string,imc::channel>
|
||||||
(chnenv.CNuuid_,imc::channel(chnenv,&mapblocks_,&buffer_))
|
(chnenv.CNuuid_,imc::channel(chnenv,&mapblocks_,&buffer_))
|
||||||
);
|
);
|
||||||
|
|
||||||
// reset channel uuid
|
// reset channel uuid
|
||||||
chnenv.CNuuid_.clear();
|
chnenv.reset();
|
||||||
|
//chnenv.CNuuid_.clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -254,7 +268,6 @@ namespace imc
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
// provide buffer size
|
// provide buffer size
|
||||||
|
@@ -2,3 +2,4 @@ include lib/*.hpp
|
|||||||
include *.cpp
|
include *.cpp
|
||||||
include *.pyx
|
include *.pyx
|
||||||
include *.pxd
|
include *.pxd
|
||||||
|
include VERSION
|
||||||
|
@@ -1 +1 @@
|
|||||||
2.0.4
|
2.0.8
|
||||||
|
43
python/examples/multichannel.py
Normal file
43
python/examples/multichannel.py
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
|
||||||
|
import IMCtermite
|
||||||
|
import pandas
|
||||||
|
import datetime
|
||||||
|
|
||||||
|
def add_trigger_time(trigger_time, add_time) :
|
||||||
|
trgts = datetime.datetime.strptime(trigger_time,'%Y-%m-%dT%H:%M:%S')
|
||||||
|
dt = datetime.timedelta(seconds=add_time)
|
||||||
|
return (trgts + dt).strftime('%Y-%m-%dT%H:%M:%S:%f')
|
||||||
|
|
||||||
|
if __name__ == "__main__" :
|
||||||
|
|
||||||
|
# read file and extract data
|
||||||
|
imctm = IMCtermite.imctermite(b"Measurement.raw")
|
||||||
|
chns = imctm.get_channels(True)
|
||||||
|
|
||||||
|
# prepare abscissa
|
||||||
|
xcol = "time ["+chns[0]['xunit']+"]"
|
||||||
|
#xcol = "timestamp"
|
||||||
|
xsts = [add_trigger_time(chns[0]['trigger-time'],tm) for tm in chns[0]['xdata']]
|
||||||
|
|
||||||
|
# sort channels
|
||||||
|
chnnms = sorted([chn['name'] for chn in chns], reverse=False)
|
||||||
|
chnsdict = {}
|
||||||
|
for chn in chns :
|
||||||
|
chnsdict[chn['name']] = chn
|
||||||
|
|
||||||
|
# construct dataframe
|
||||||
|
df = pandas.DataFrame()
|
||||||
|
df[xcol] = pandas.Series(chns[0]['xdata'])
|
||||||
|
#df[xcol] = pandas.Series(xsts)
|
||||||
|
#for idx,chn in enumerate(chns) :
|
||||||
|
for chnnm in chnnms :
|
||||||
|
chn = chnsdict[chnnm]
|
||||||
|
#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'])
|
||||||
|
|
||||||
|
# show entire dataframe and write file
|
||||||
|
print(df)
|
||||||
|
df.to_csv("Measurement.csv",header=True,sep='\t',index=False)
|
||||||
|
|
Reference in New Issue
Block a user