initialize new cython module raw_meat
This commit is contained in:
parent
ecd364d482
commit
f8dcc6493f
@ -11,7 +11,7 @@ from libcpp cimport bool
|
|||||||
|
|
||||||
# these method names have to match the C definitions of the methods!!
|
# these method names have to match the C definitions of the methods!!
|
||||||
|
|
||||||
cdef extern from "lib/raweat.hpp":
|
cdef extern from "../lib/raweat.hpp":
|
||||||
cdef cppclass raw_eater:
|
cdef cppclass raw_eater:
|
||||||
raw_eater(string) except +
|
raw_eater(string) except +
|
||||||
# get validity of data format
|
# get validity of data format
|
27
cyt/raw_meat.pxd
Normal file
27
cyt/raw_meat.pxd
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
# cython: language_level = 3
|
||||||
|
# distutils: language = c++
|
||||||
|
|
||||||
|
# use some C++ STL libraries
|
||||||
|
from libcpp.string cimport string
|
||||||
|
from libcpp.vector cimport vector
|
||||||
|
from libcpp cimport bool
|
||||||
|
|
||||||
|
# these method names have to match the C++ definitions of the methods!!
|
||||||
|
cdef extern from "../lib/rawmerge.hpp":
|
||||||
|
cdef cppclass raw_merger:
|
||||||
|
raw_merger(string) except +
|
||||||
|
# get validity of data format
|
||||||
|
bool get_valid()
|
||||||
|
# get channel name and unit
|
||||||
|
string get_name()
|
||||||
|
string get_unit()
|
||||||
|
# get time step and time unit
|
||||||
|
double get_dt()
|
||||||
|
string get_temp_unit()
|
||||||
|
# get data array of time and measured quantity's channel
|
||||||
|
vector[double] get_time()
|
||||||
|
vector[double] get_data()
|
||||||
|
# dump all data to .csv
|
||||||
|
void write_table(const char*,char delimiter)
|
||||||
|
# add channel and try to merge it
|
||||||
|
bool add_channel(string)
|
43
cyt/raw_meat.pyx
Normal file
43
cyt/raw_meat.pyx
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
|
||||||
|
# from <raw_meat> has to match name of .pxd file and cimport name of class defined in .pxd
|
||||||
|
from raw_meat cimport raw_merger
|
||||||
|
import numpy as np
|
||||||
|
import re
|
||||||
|
|
||||||
|
cdef class rawmerger:
|
||||||
|
|
||||||
|
# pointer to C++ instance (since there's no nullary constructor)
|
||||||
|
cdef raw_merger *rawit
|
||||||
|
|
||||||
|
def __cinit__(self, string rawfile):
|
||||||
|
self.rawit = new raw_merger(rawfile)
|
||||||
|
|
||||||
|
def __dealloc__(self):
|
||||||
|
del self.rawit
|
||||||
|
|
||||||
|
def validity(self):
|
||||||
|
return self.rawit.get_valid()
|
||||||
|
|
||||||
|
def channel_name(self):
|
||||||
|
return self.rawit.get_name()
|
||||||
|
|
||||||
|
def unit(self):
|
||||||
|
return self.rawit.get_unit()
|
||||||
|
|
||||||
|
def dt(self):
|
||||||
|
return self.rawit.get_dt()
|
||||||
|
|
||||||
|
def time_unit(self):
|
||||||
|
return self.rawit.get_temp_unit()
|
||||||
|
|
||||||
|
def get_time(self):
|
||||||
|
return self.rawit.get_time()
|
||||||
|
|
||||||
|
def get_channel(self):
|
||||||
|
return self.rawit.get_data()
|
||||||
|
|
||||||
|
def write_table(self, const char* csvfile, char delimiter):
|
||||||
|
return self.rawit.write_table(csvfile,delimiter)
|
||||||
|
|
||||||
|
def add_channel(self, string rawfile):
|
||||||
|
return self.rawit.add_channel(rawfile)
|
62
lib/rawmerge.hpp
Normal file
62
lib/rawmerge.hpp
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
//---------------------------------------------------------------------------//
|
||||||
|
//
|
||||||
|
// @file rawmerge.hpp
|
||||||
|
// @author Mario Fink <mario.fink@record-evolution.de>
|
||||||
|
// @date Aug 2020
|
||||||
|
// @brief unify multiple channels and time series from .raw in single table
|
||||||
|
//
|
||||||
|
//---------------------------------------------------------------------------//
|
||||||
|
|
||||||
|
#ifndef RAW_MERGER
|
||||||
|
#define RAW_MERGER
|
||||||
|
|
||||||
|
#include "raweat.hpp"
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------//
|
||||||
|
|
||||||
|
class raw_merger : public raw_eater
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
|
||||||
|
// number of channels
|
||||||
|
int num_channels_;
|
||||||
|
|
||||||
|
// (merged) channel data
|
||||||
|
std::vector<std::vector<double>> channels_;
|
||||||
|
|
||||||
|
// channel meta data
|
||||||
|
std::vector<std::string> channel_names_;
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
// constructor
|
||||||
|
raw_merger(std::string rawfile): raw_eater(rawfile)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// destructor
|
||||||
|
~raw_merger()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// add a single channel and its associated time series
|
||||||
|
bool add_channel(std::string rawfile)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// print all data to file
|
||||||
|
void write_table(std::string filename, char delimiter = ',', int precision = 6, int width = 25)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------//
|
22
makefile
22
makefile
@ -20,7 +20,7 @@ OPT = -O3 -Wall -mavx -mno-tbm -mf16c -mno-f16c
|
|||||||
# C++
|
# C++
|
||||||
|
|
||||||
# build executable
|
# build executable
|
||||||
$(EXE) : $(SRC)main.cpp $(LIB)raweat.hpp $(LIB)hexshow.hpp
|
$(EXE) : $(SRC)main.cpp $(LIB)raweat.hpp $(LIB)hexshow.hpp $(LIB)rawmerge.hpp
|
||||||
$(CCC) $(OPT) $< -o $@
|
$(CCC) $(OPT) $< -o $@
|
||||||
|
|
||||||
# development version
|
# development version
|
||||||
@ -57,18 +57,26 @@ uninstall :
|
|||||||
# Python
|
# Python
|
||||||
|
|
||||||
# build python module
|
# build python module
|
||||||
build : setup.py raw_eater.pyx raw_eater.pxd $(LIB)raweat.hpp
|
build : setup_raw_eater.py cyt/raw_eater.pyx cyt/raw_eater.pxd $(LIB)raweat.hpp \
|
||||||
python3 setup.py build_ext --inplace
|
setup_raw_meat.py cyt/raw_meat.pyx cyt/raw_meat.pxd $(LIB)rawmerge.hpp
|
||||||
|
python3 setup_raw_eater.py build_ext --inplace
|
||||||
|
python3 setup_raw_meat.py build_ext --inplace
|
||||||
cp raw_eater.cpython-*.so pyt/
|
cp raw_eater.cpython-*.so pyt/
|
||||||
|
cp raw_meat.cpython-*.so pyt/
|
||||||
|
|
||||||
py_install: setup.py raw_eater.pyx raw_eater.pxd $(LIB)raweat.hpp
|
py_install: setup_raw_eater.py cyt/raw_eater.pyx cyt/raw_eater.pxd $(LIB)raweat.hpp \
|
||||||
python3 setup.py install
|
setup_raw_meat.py cyt/raw_meat.pyx cyt/raw_meat.pxd $(LIB)rawmerge.hpp
|
||||||
|
python3 setup_raw_eater.py install --record files_raw_eater.txt
|
||||||
|
python3 setup_raw_meat.py install --record files_raw_meat.txt
|
||||||
|
|
||||||
py_clean :
|
py_clean :
|
||||||
rm -f raw_eater.cpython-*.so
|
rm -f raw_eater.cpython-*.so
|
||||||
rm -f pyt/raw_eater.cpython-*.so
|
rm -f pyt/raw_eater.cpython-*.so
|
||||||
rm -f raw_eater.cpp
|
rm -f cyt/raw_eater.cpp
|
||||||
|
rm -f raw_meat.cpython-*.so
|
||||||
|
rm -f pyt/raw_meat.cpython-*.so
|
||||||
|
rm -f cyt/raw_meat.cpp
|
||||||
rm -rf build/
|
rm -rf build/
|
||||||
|
rm -f *.txt
|
||||||
|
|
||||||
#-----------------------------------------------------------------------------#
|
#-----------------------------------------------------------------------------#
|
||||||
|
|
||||||
|
@ -1,10 +1,11 @@
|
|||||||
|
|
||||||
import raw_eater
|
import raw_eater
|
||||||
|
import raw_meat
|
||||||
|
|
||||||
rawlist = [ "sample/VehicleSpeed_HS.raw",
|
rawlist = [ "smp/VehicleSpeed_HS.raw",
|
||||||
"sample/Rangerover_Evoque_F-RR534_2019-05-07/ABS_A_Port1.raw",
|
"smp/Rangerover_Evoque_F-RR534_2019-05-07/ABS_A_Port1.raw",
|
||||||
"./pyt/example.py",
|
"./pyt/example.py",
|
||||||
"sample/Rangerover_Evoque_F-RR534_2019-05-07/LateralAcceleration_HS.raw" ]
|
"smp/Rangerover_Evoque_F-RR534_2019-05-07/LateralAcceleration_HS.raw" ]
|
||||||
|
|
||||||
print("")
|
print("")
|
||||||
|
|
||||||
|
@ -4,11 +4,7 @@ from Cython.Build import cythonize
|
|||||||
|
|
||||||
extensions = Extension(
|
extensions = Extension(
|
||||||
name="raw_eater",
|
name="raw_eater",
|
||||||
version="0.1.0",
|
sources=["cyt/raw_eater.pyx"],
|
||||||
author="Mario Fink",
|
|
||||||
author_email="mario.fink@record-evolution.de",
|
|
||||||
url="https://github.com/RecordEvolution/raw_eater.git",
|
|
||||||
sources=["raw_eater.pyx"],
|
|
||||||
# libraries=[""],
|
# libraries=[""],
|
||||||
library_dirs=["src"],
|
library_dirs=["src"],
|
||||||
include_dirs=["src"],
|
include_dirs=["src"],
|
20
setup_raw_meat.py
Normal file
20
setup_raw_meat.py
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
from distutils.core import setup
|
||||||
|
from distutils.extension import Extension
|
||||||
|
from Cython.Build import cythonize
|
||||||
|
|
||||||
|
extensions = Extension(
|
||||||
|
name="raw_meat",
|
||||||
|
sources=["cyt/raw_meat.pyx"],
|
||||||
|
# libraries=[""],
|
||||||
|
library_dirs=["src"],
|
||||||
|
include_dirs=["src"],
|
||||||
|
language='c++',
|
||||||
|
extra_compile_args=['-std=c++11','-Wno-unused-variable'],
|
||||||
|
extra_link_args=['-std=c++11'],
|
||||||
|
#extra_objects=["lib/parquet/libarrow.so.200.0.0"],
|
||||||
|
)
|
||||||
|
|
||||||
|
setup(
|
||||||
|
name="raw_meat",
|
||||||
|
ext_modules=cythonize(extensions)
|
||||||
|
)
|
@ -3,6 +3,7 @@
|
|||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include "../lib/raweat.hpp"
|
#include "../lib/raweat.hpp"
|
||||||
|
#include "../lib/rawmerge.hpp"
|
||||||
|
|
||||||
//---------------------------------------------------------------------------//
|
//---------------------------------------------------------------------------//
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user