Compare commits

..

21 Commits

Author SHA1 Message Date
06b4c4f870 fix README section about python install 2025-03-09 22:01:43 +01:00
a2f61f7405 comply with PEP 625: adjust README.md 2025-02-12 23:36:40 +01:00
bb10d80489 comply with PEP 625: lower case distribution filenames; bump version 2.1.18 2025-02-12 23:18:49 +01:00
1eea219361 github actions: matrix os ubuntu, win; bump version 2.1.17 2025-02-12 22:57:58 +01:00
400b6eaab9 github actions: separate strategy matrix os; bump version 2.1.16 2025-02-12 22:34:01 +01:00
6f4511e1c2 github actions: remove macos; bump version 2.1.15 2025-02-12 13:53:55 +01:00
fe042b531f github actions: use os latest + macos; bump version 2.1.14 2025-02-12 13:46:58 +01:00
9d5f0cff01 bump version 2.1.13; reuse and extract various text fields, take care of backslash in text w.r.t. to python dict 2025-02-12 01:04:51 +01:00
720acd3b62 github actions: fix Upload binary wheels PyPI 2025-02-03 21:11:21 +01:00
8ca6ee3ddc github actions: fix Upload binary wheels PyPI 2025-02-03 20:56:17 +01:00
379feaa85a github actions: fix Upload binary wheels PyPI 2025-02-02 00:53:16 +01:00
cff2e913fc github actions: fix Upload binary wheels PyPI 2025-02-02 00:47:13 +01:00
75d70a9521 * github actions: fix Unable to download artifact(s): Artifact not found for name: binary-wheels
* README.md: structure and sort references
* bump v2.1.8
2025-02-02 00:30:56 +01:00
mario-fink
36cf0c9c18
Merge pull request #32 from jgoedeke/master
Bugfix trigger-time with XY Datasets
2025-01-25 01:15:19 +01:00
jgoedeke
2326725756 bugfix: set xprec to 9 for XY datasets 2025-01-23 15:07:12 +00:00
jgoedeke
59de48424e Fix absolute_trigger_time for XY datasets and remove addtime from output
Add-time is already implicitly provided by the difference between `trigger-time-nt` and `trigger-time` for normal datasets. For XY datasets the `addtime` parameter is not applicable.
2025-01-23 14:18:08 +00:00
jgoedeke
a44461cba6 Fix wrong keys in runtime errors 2025-01-23 14:15:52 +00:00
cee146593b github actions: fix Unable to download artifact(s): Artifact not found for name: binary-wheels 2025-01-22 19:58:58 +01:00
223f25b6e0 github actions: fix Failed to CreateArtifact: Received non-retryable error: Failed request: (409) 2025-01-22 00:40:24 +01:00
8ec02d21c5 github actions: fix Failed to CreateArtifact: Received non-retryable error: Failed request: (409) 2025-01-22 00:20:57 +01:00
df445bfd7f github actions: update runner-images 2025-01-22 00:04:49 +01:00
16 changed files with 120 additions and 49 deletions

View File

@ -10,7 +10,7 @@ jobs:
build_setup:
name: Prepare environment for wheel builds
runs-on: ubuntu-20.04
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v2
- name: Prepare wheel build
@ -20,6 +20,8 @@ jobs:
with:
name: wheel-config
path: python/
- name: Display files
run: ls -lR
build_wheels:
name: Build binary wheels on ${{ matrix.os }}
@ -27,8 +29,7 @@ jobs:
needs: [build_setup]
strategy:
matrix:
os: [ubuntu-20.04, windows-2019]
arch: [auto32, auto64, aarch64]
os: [ubuntu-latest, windows-latest]
steps:
- uses: actions/checkout@v2
@ -43,17 +44,15 @@ jobs:
- name: Build wheels
run: python -m cibuildwheel --output-dir wheelhouse
working-directory: python/
# env:
# CIBW_BUILD: cp36-* cp37-* cp38-* cp39-* cp310-*
- name: Store binary wheels
uses: actions/upload-artifact@v4.6.0
with:
name: binary-wheels
name: binary-wheels-${{matrix.os}}-${{ strategy.job-index }}
path: python/wheelhouse/*.whl
build_sdist:
name: Build source distribution
runs-on: ubuntu-latest
runs-on: ubuntu-24.04
needs: [build_setup]
steps:
- uses: actions/checkout@v2
@ -72,11 +71,13 @@ jobs:
with:
name: source-wheels
path: python/dist/*.tar.gz
- name: Display files
run: ls -lR
upload_pypi:
name: Upload binary wheels to PyPI
runs-on: ubuntu-20.04
name: Upload wheels to PyPI
runs-on: ubuntu-24.04
needs: [build_wheels, build_sdist]
steps:
@ -88,8 +89,11 @@ jobs:
- name: Get binary wheels
uses: actions/download-artifact@v4.1.7
with:
name: binary-wheels
path: dist/
pattern: binary-wheels-*
merge-multiple: true
- name: Display files
run: ls -lR
- uses: pypa/gh-action-pypi-publish@release/v1
with:

View File

@ -2,7 +2,7 @@
[![LICENSE](https://img.shields.io/github/license/RecordEvolution/IMCtermite)](https://img.shields.io/github/license/RecordEvolution/IMCtermite)
[![STARS](https://img.shields.io/github/stars/RecordEvolution/IMCtermite)](https://img.shields.io/github/stars/RecordEvolution/IMCtermite)
![CI Build Wheel](https://github.com/RecordEvolution/IMCtermite/actions/workflows/pypi-deploy.yml/badge.svg?branch=&event=push)
[![PYPI](https://img.shields.io/pypi/v/IMCtermite.svg)](https://pypi.org/project/IMCtermite/)
[![PYPI](https://img.shields.io/pypi/v/IMCtermite.svg)](https://pypi.org/project/imctermite/)
# IMCtermite
@ -131,24 +131,21 @@ which may require root permissions.
### Python
To integrate the library into a customized ETL toolchain, several cython targets
To integrate the library into a customized ETL toolchain, several python targets
are available. For a local build that enables you to run the examples, use:
```
make cython-build
make python-build
```
However, in a production environment, a proper installation of the module with
`make cython-install` is recommended for system-wide availability of the module.
#### Installation with pip
The package is also available in the [Python Package Index](https://pypi.org)
at [IMCtermite](https://pypi.org/project/IMCtermite/).
at [imctermite](https://pypi.org/project/imctermite/).
To install the latest version simply do
```Shell
python3 -m pip install IMCtermite
python3 -m pip install imctermite
```
which provides binary wheels for multiple architectures on _Windows_ and _Linux_
@ -195,9 +192,9 @@ Given the `IMCtermite` module is available, we can import it and declare an inst
of it by passing a _raw_ file to the constructor:
```Python
import IMCtermite
import imctermite
imcraw = IMCtermite.imctermite(b"sample/sampleA.raw")
imcraw = imctermite.imctermite(b"sample/sampleA.raw")
```
An example of how to create an instance and obtain the list of channels is:
@ -222,18 +219,31 @@ can be found in the `python/examples` folder.
## References
### IMC
- https://www.imc-tm.de/produkte/messtechnik-software/imc-famos/funktionen/im-und-export/
- https://www.imc-tm.de/produkte/messtechnik-hardware/imc-cronosflex/ueberblick/
- https://www.imc-tm.de/download-center/produkt-downloads/imc-famos/handbuecher
- https://www.imc-tm.de/fileadmin/Public/Downloads/Manuals/imc_FAMOS/imcGemeinsameKomponenten.pdf
- https://cython.readthedocs.io/en/latest/src/userguide/wrapping_CPlusPlus.html
- https://github.com/Apollo3zehn/ImcFamosFile
- https://apollo3zehn.github.io/ImcFamosFile/api/ImcFamosFile.FamosFileKeyType.html
### Cython
- https://cython.readthedocs.io/en/latest/src/userguide/wrapping_CPlusPlus.html
### PyPI
- https://pypi.org/help/#apitoken
- https://sgoel.dev/posts/uploading-binary-wheels-to-pypi-from-github-actions/
- https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idstepsrun
- https://github.com/pypa/cibuildwheel/blob/main/examples/github-deploy.yml
- https://cibuildwheel.readthedocs.io/en/stable/deliver-to-pypi/
- https://github.com/actions/download-artifact#download-all-artifacts
- https://github.com/actions/download-artifact?tab=readme-ov-file#download-multiple-filtered-artifacts-to-the-same-directory
### iconv
- https://www.gnu.org/software/libiconv/
- https://vcpkg.io/en/packages.html
- https://vcpkg.io/en/getting-started

View File

@ -314,10 +314,11 @@ namespace imc
std::vector<unsigned char>* buffer_;
imc::origin_data NO_;
imc::language NL_;
imc::text CT_;
imc::groupobj CB_;
imc::datafield CG_;
imc::channelobj CN_;
// collect meta-data of channels according to env,
// just everything valueable in here
@ -349,7 +350,7 @@ namespace imc
double xoffset_, yoffset_;
// group reference the channel belongs to
int group_index_;
unsigned long int group_index_;
std::string group_uuid_, group_name_, group_comment_;
// constructor takes channel's block environment
@ -362,6 +363,22 @@ namespace imc
// use uuid from CN block
uuid_ = chnenv_.CNuuid_;
// extract associated NO data
if ( blocks_->count(chnenv_.NOuuid_) == 1 )
{
NO_.parse(buffer_, blocks_->at(chnenv_.NOuuid_).get_parameters());
origin_ = NO_.generator_;
comment_ = NO_.comment_;
}
// extract associated NL data
if ( blocks_->count(chnenv_.NLuuid_) == 1 )
{
NL_.parse(buffer_, blocks_->at(chnenv_.NLuuid_).get_parameters());
codepage_ = NL_.codepage_;
language_code_ = NL_.language_code_;
}
// extract associated CB data
if ( blocks_->count(chnenv_.CBuuid_) == 1 )
{
@ -377,6 +394,15 @@ namespace imc
+ CT_.comment_;
}
// extract associated CN data
if ( blocks_->count(chnenv_.CNuuid_) == 1 )
{
CN_.parse(buffer_, blocks_->at(chnenv_.CNuuid_).get_parameters());
group_index_ = CN_.group_index_;
group_name_ = CN_.name_;
group_comment_ = CN_.comment_;
}
if ( !chnenv_.compenv1_.uuid_.empty() && chnenv_.compenv2_.uuid_.empty() )
{
// normal dataset (single component)
@ -393,7 +419,6 @@ namespace imc
ybuffer_offset_ = comp_group1.Cb_.offset_buffer_;
ybuffer_size_ = comp_group1.Cb_.number_bytes_;
xstart_ = comp_group1.Cb_.x0_;
addtime_ = static_cast<long int>(comp_group1.Cb_.add_time_);
yfactor_ = comp_group1.CR_.factor_;
yoffset_ = comp_group1.CR_.offset_;
yunit_ = comp_group1.CR_.unit_;
@ -407,6 +432,10 @@ namespace imc
std::time_t ts = timegm(&comp_group1.NT_.tms_); // std::mktime(&tms);
trigger_time_ = std::chrono::system_clock::from_time_t(ts);
trigger_time_frac_secs_ = comp_group1.NT_.trigger_time_frac_secs_;
// calculate absolute trigger-time
addtime_ = static_cast<long int>(comp_group1.Cb_.add_time_);
absolute_trigger_time_ = trigger_time_ + std::chrono::seconds(addtime_);
// + std::chrono::nanoseconds((long int)(trigger_time_frac_secs_*1.e9));
}
else if ( !chnenv_.compenv1_.uuid_.empty() && !chnenv_.compenv2_.uuid_.empty() )
{
@ -438,6 +467,7 @@ namespace imc
std::time_t ts = timegm(&comp_group2.NT_.tms_); // std::mktime(&tms);
trigger_time_ = std::chrono::system_clock::from_time_t(ts);
trigger_time_frac_secs_ = comp_group2.NT_.trigger_time_frac_secs_;
absolute_trigger_time_ = trigger_time_;
}
else
{
@ -447,12 +477,9 @@ namespace imc
// start converting binary buffer to imc::datatype
if ( !chnenv_.CSuuid_.empty() ) convert_buffer();
// calculate absolute trigger-time
absolute_trigger_time_ = trigger_time_ + std::chrono::seconds(addtime_);
// + std::chrono::nanoseconds((long int)(trigger_time_frac_secs_*1.e9));
// convert any non-UTF-8 codepage to UTF-8
// convert any non-UTF-8 codepage to UTF-8 and cleanse any text
convert_encoding();
cleanse_text();
}
// convert buffer to actual datatype
@ -508,6 +535,8 @@ namespace imc
throw std::runtime_error("x and y data have different number of values");
}
xprec_ = 9;
process_data(xdata_, xnum_values, xdatatp_, xCSbuffer);
process_data(ydata_, ynum_values, ydatatp_, yCSbuffer);
}
@ -600,6 +629,35 @@ namespace imc
}
}
void cleanse_text()
{
escape_backslash(name_);
escape_backslash(comment_);
escape_backslash(origin_);
escape_backslash(origin_comment_);
escape_backslash(text_);
escape_backslash(language_code_);
escape_backslash(yname_);
escape_backslash(yunit_);
escape_backslash(xname_);
escape_backslash(xunit_);
escape_backslash(group_name_);
escape_backslash(group_comment_);
}
void escape_backslash(std::string &text)
{
char backslash = 0x5c;
std::string doublebackslash("\\\\");
for ( std::string::iterator it = text.begin(); it != text.end(); ++it )
{
if ( int(*it) == backslash ) {
text.replace(it,it+1,doublebackslash);
++it;
}
}
}
// get info string
std::string get_info(int width = 20)
{
@ -624,7 +682,6 @@ namespace imc
<<std::setw(width)<<std::left<<"significant bits:"<<ysignbits_<<"\n"
<<std::setw(width)<<std::left<<"buffer-offset:"<<ybuffer_offset_<<"\n"
<<std::setw(width)<<std::left<<"buffer-size:"<<ybuffer_size_<<"\n"
<<std::setw(width)<<std::left<<"add-time:"<<addtime_<<"\n"
<<std::setw(width)<<std::left<<"xname:"<<xname_<<"\n"
<<std::setw(width)<<std::left<<"xunit:"<<xunit_<<"\n"
<<std::setw(width)<<std::left<<"xstepwidth:"<<xstepwidth_<<"\n"
@ -660,7 +717,6 @@ namespace imc
<<"\",\"yname\":\""<<prepjsonstr(yname_)
<<"\",\"yunit\":\""<<prepjsonstr(yunit_)
<<"\",\"significantbits\":\""<<ysignbits_
<<"\",\"addtime\":\""<<addtime_
<<"\",\"buffer-size\":\""<<ybuffer_size_
<<"\",\"xname\":\""<<prepjsonstr(xname_)
<<"\",\"xunit\":\""<<prepjsonstr(xunit_)

View File

@ -482,7 +482,7 @@ namespace imc
// construct members by parsing particular parameters from buffer
void parse(const std::vector<unsigned char>* buffer, const std::vector<parameter>& parameters)
{
if ( parameters.size() < 7 ) throw std::runtime_error("invalid number of parameters in CD2");
if ( parameters.size() < 7 ) throw std::runtime_error("invalid number of parameters in NO");
origin_ = ( get_parameter(buffer,&parameters[2]) == std::string("1") );
generator_ = get_parameter(buffer,&parameters[4]);
comment_ = get_parameter(buffer,&parameters[6]);
@ -508,7 +508,7 @@ namespace imc
// construct members by parsing particular parameters from buffer
void parse(const std::vector<unsigned char>* buffer, const std::vector<parameter>& parameters)
{
if ( parameters.size() < 8 ) throw std::runtime_error("invalid number of parameters in CD2");
if ( parameters.size() < 8 ) throw std::runtime_error("invalid number of parameters in NT1");
tms_ = std::tm();
tms_.tm_mday = std::stoi( get_parameter(buffer,&parameters[2]) );
tms_.tm_mon = std::stoi( get_parameter(buffer,&parameters[3]) ) - 1;

View File

@ -88,11 +88,11 @@ docker-run:
python-build: check-tags $(GVSN)
make -C python/ build-inplace
cp python/IMCtermite*.so ./ -v
cp python/imctermite*.so ./ -v
python-clean:
make -C python/ clean
rm -vf IMCtermite*.so
rm -vf imctermite*.so
python-test:
PYTHONPATH=./ python python/examples/usage.py

View File

@ -1 +1 @@
2.1.0
2.1.18

View File

@ -1,5 +1,5 @@
import IMCtermite
import imctermite
import pandas
import datetime
@ -11,7 +11,7 @@ def add_trigger_time(trigger_time, add_time) :
if __name__ == "__main__" :
# read file and extract data
imctm = IMCtermite.imctermite(b"Measurement.raw")
imctm = imctermite.imctermite(b"Measurement.raw")
chns = imctm.get_channels(True)
# prepare abscissa

View File

@ -1,11 +1,11 @@
import IMCtermite
import imctermite
import json
import os
# declare and initialize instance of "imctermite" by passing a raw-file
try :
imcraw = IMCtermite.imctermite(b"samples/exampleB.raw")
imcraw = imctermite.imctermite(b"samples/exampleB.raw")
except RuntimeError as e :
raise Exception("failed to load/parse raw-file: " + str(e))

View File

@ -1,5 +1,5 @@
import IMCtermite
import imctermite
import json
import os
@ -15,7 +15,7 @@ for fl in rawlist1:
# declare and initialize instance of "imctermite" by passing a raw-file
try :
imcraw = IMCtermite.imctermite(fl.encode())
imcraw = imctermite.imctermite(fl.encode())
except RuntimeError as e :
raise Exception("failed to load/parse raw-file: " + str(e))

View File

@ -1,12 +1,12 @@
import IMCtermite
import imctermite
import json
import os
import datetime
# declare and initialize instance of "imctermite" by passing a raw-file
try :
imcraw = IMCtermite.imctermite(b"samples/sampleB.raw")
imcraw = imctermite.imctermite(b"samples/sampleB.raw")
except RuntimeError as e :
raise Exception("failed to load/parse raw-file: " + str(e))

View File

@ -1,5 +1,5 @@
from IMCtermite import imctermite
import imctermite import imctermite
def show_results(imcraw) :

View File

@ -1,7 +1,7 @@
# distutils: language = c++
# cython: language_level = 3
from IMCtermite cimport cppimctermite
from imctermite cimport cppimctermite
import json as jn
import decimal

View File

@ -29,6 +29,7 @@ build-clean:
rm -vf imctermite*.so imctermite*.cpp
rm -vf IMCtermite*.so IMCtermite*.cpp
rm -rvf dist/ IMCtermite.egg-info/
rm -rvf dist/ imctermite.egg-info/
cibuildwheel-build: setup
cibuildwheel --platform linux

View File

@ -1,6 +1,6 @@
[metadata]
name = IMCtermite
name = imctermite
description = Enables extraction of measurement data from binary files with extension 'raw' used by proprietary software imcFAMOS and imcSTUDIO and facilitates its storage in open source file formats
long_description = file: README.md
# long_description_content_type = text/x-rst

View File

@ -11,8 +11,8 @@ cmpArgs = {
}
extension = Extension(
"IMCtermite",
sources=["IMCtermite.pyx"],
"imctermite",
sources=["imctermite.pyx"],
extra_compile_args=cmpArgs[sys.platform]
)