diff --git a/cython/py_imc_termite.pyx b/cython/py_imc_termite.pyx index d103984..4c5500d 100644 --- a/cython/py_imc_termite.pyx +++ b/cython/py_imc_termite.pyx @@ -3,6 +3,7 @@ from imc_termite cimport imc_termite import json as jn +import decimal # import numpy as np cdef class imctermite: @@ -21,7 +22,7 @@ cdef class imctermite: # get JSON list of channels def get_channels(self, bool data): chnlst = self.cpp_imc.get_channels(True,data) - chnlstjn = [jn.loads(chn.decode(errors="ignore")) for chn in chnlst] + chnlstjn = [jn.loads(chn.decode(errors="ignore"),parse_float=decimal.Decimal) for chn in chnlst] return chnlstjn # print channels @@ -31,11 +32,11 @@ cdef class imctermite: # print table including channels def print_table(self, string outputfile): chnlst = self.cpp_imc.get_channels(True,True) - chnlstjn = [jn.loads(chn.decode(errors="ignore")) for chn in chnlst] + chnlstjn = [jn.loads(chn.decode(errors="ignore"),parse_float=decimal.Decimal) for chn in chnlst] with open(outputfile.decode(),'w') as fout: for chn in chnlstjn: - fout.write(str(chn['yunit']).rjust(20)+str(chn['xunit']).rjust(20)+'\n') - fout.write(str(chn['yname']).rjust(20)+str(chn['xname']).rjust(20)+'\n') + fout.write('#' +str(chn['xname']).rjust(19)+str(chn['yname']).rjust(20)+'\n') + fout.write('#'+str(chn['xunit']).rjust(19)+str(chn['yunit']).rjust(20)+'\n') for n in range(0,len(chn['ydata'])): fout.write(str(chn['xdata'][n]).rjust(20)+ str(chn['ydata'][n]).rjust(20)+'\n') diff --git a/lib/imc_channel.hpp b/lib/imc_channel.hpp index a5766cf..26f5d3f 100644 --- a/lib/imc_channel.hpp +++ b/lib/imc_channel.hpp @@ -95,7 +95,7 @@ namespace imc ss<<"["; if ( myvec.size() <= limit ) { - for ( dt el: myvec ) ss< 0 : -# chnydata = channelsdata[0]['ydata'] -# chnxdata = channelsdata[0]['xdata'] -# -# print(len(chnydata)) -# print(len(chnxdata)) -# -# # print the channels into a specific directory -# imcraw.print_channels(b"./") + # print the channels into a specific directory + imcraw.print_channels(b"./") -# print all channels in single file -# imcraw.print_table(b"./allchannels.csv") + # print all channels in single file + imcraw.print_table(("./"+str(os.path.basename(fl).split('.')[0])+"_allchannels.csv").encode())