Skip to main content

C++ parser of .sht files.

Project description

shtRipper

На винде в зависимостях MSVS140

Код для извлечения данных из .sht файлов.

Перед обновлением пакета остановить все запущенные питоновские интерпретаторы!

Надёжнее удалять предыдущую версию, чтобы гарантированно обновились бинарные файлы.

Пример кода для чтения всего sht файла:

import shtRipper



filename = '\\\\172.16.12.127\\Data\\sht40808.SHT'

res = shtRipper.ripper.read(filename)

print(res.keys())

Пример кода для чтения только выбранных сигналов:

import shtRipper



filename = '\\\\172.16.12.127\\Data\\sht40808.SHT'

res = shtRipper.ripper.read(filename, ['Лазер', 'Emission electrode voltage', 'Emission electrode current'])

print(res.keys())

Пример кода для объединения нескольких sht файлов в один без распаковки/запаковки:

import shtRipper



path: str = ''

filename: str = 'out.sht'

filenames: list[str] = ['in1.sht', 'in2.sht']

ripper.merge('', filename, filenames)

Пример кода для упаковки данных в формат .sht:

import shtRipper

import math  # used only for example sin() signal



to_pack = {

   'signal with error': {

       'comment': 'Точки хранят ещё и погрешность, требует много памяти.',

       'unit': 'T_e(eV)',

       'x': x,

       'y': T_c,

       'err': T_err

   },

   'X Y signal': {

       'comment': 'Точки хранятся парой значений, требует много памяти.',

       'unit': 'T_e(eV)',

       'x': x,

       'y': n_c

   },

   'Y signal with fixed X-grid': {

       'comment': 'Этот тип хранения данных предназначен для данных АЦП',

       'unit': 'U(V)',

       'tMin': 0.0,  # mininun time

       'tMax': 100.0,  # maximum time

       'offset': 0.0,  # ADC zero level offset

       'yRes': 0.0001,  # ADC resolution: 0.0001 Volt per adc bit

       'y': [math.sin(i / 10) for i in range(100)]

   }

}



packed = shtRipper.ripper.write(path='D:/tmp/', filename='example.SHT', data=to_pack)

if len(packed) != 0:

    print('packed error = "%s"' % packed)

Пример кода для упаковки данных АЦП spectraltech в формат sht:

import shtRipper



shotn = 46128

Tukhmeneva_path = '\\\\172.16.12.127\\Pub\\!!!SHT Tuxmeneva\\'

sht_path = '\\\\172.16.12.127\\Data\\'



names = [

{

    'yRes': 2.5,

    'frequencyHz': 50e3,

    'ch': [

        {

            'name': 'continuum',

            'comment': 'PassiveSpectroscopy, ADC 1, ch 1',

            'unit': 'S(V)'

        },

        {

            'name': 'Линия C III (465 nm)',

            'comment': 'PassiveSpectroscopy, ADC 1, ch 2',

            'unit': 'S(V)'

        },

        {

            'name': 'Линия He I (587 nm)',

            'comment': 'PassiveSpectroscopy, ADC 1, ch 3'

        },{

            'name': 'Линия N II (568 nm)',

            'comment': 'PassiveSpectroscopy, ADC 1, ch 4',

            'yRes': -2.5

        },{

            'name': 'Линия O II (441 nm)',

            'comment': 'PassiveSpectroscopy, ADC 1, ch 5',

            'yRes': -2.5

        },{

            'name': 'Линия B II (343 nm)',

            'comment': 'PassiveSpectroscopy, ADC 1, ch 6',

            'yRes': -2.5

        },{

            'name': 'Линия Fe I (427 nm)',

            'comment': 'PassiveSpectroscopy, ADC 1, ch 7',

            'yRes': -2.5

        },{

            'skip': True,

            'comment': 'PassiveSpectroscopy, ADC 1, ch 8',

        },{

            'skip': True,

            'comment': 'PassiveSpectroscopy, ADC 1, ch 9',

        },

        {

            'skip': True,

            'comment': 'PassiveSpectroscopy, ADC 1, ch 10',

        },

        {

            'skip': True,

            'comment': 'PassiveSpectroscopy, ADC 1, ch 11',

        },

        {

            'skip': True,

            'comment': 'PassiveSpectroscopy, ADC 1, ch 12',

        },{

            'skip': True,

            'comment': 'PassiveSpectroscopy, ADC 1, ch 13',

        },{

            'skip': True,

            'comment': 'PassiveSpectroscopy, ADC 1, ch 14',

        },{

            'skip': True,

            'comment': 'PassiveSpectroscopy, ADC 1, ch 15',

        },{

            'skip': True,

            'comment': 'PassiveSpectroscopy, ADC 1, ch 16',

        }

    ]

},

{

    'yRes': 2.5,

    'frequencyHz': 50e3,

    'ch': [

        {

            'comment': 'PassiveSpectroscopy, ADC 2, ch 1'

        },{

            'comment': 'PassiveSpectroscopy, ADC 2, ch 2'

        },{

            'comment': 'PassiveSpectroscopy, ADC 2, ch 3'

        },{

            'comment': 'PassiveSpectroscopy, ADC 2, ch 4'

        },{

            'comment': 'PassiveSpectroscopy, ADC 2, ch 5'

        },{

            'comment': 'PassiveSpectroscopy, ADC 2, ch 6'

        },{

            'comment': 'PassiveSpectroscopy, ADC 2, ch 7'

        },{

            'comment': 'PassiveSpectroscopy, ADC 2, ch 8'

        },{

            'comment': 'PassiveSpectroscopy, ADC 2, ch 9'

        },{

            'comment': 'PassiveSpectroscopy, ADC 2, ch 10'

        },{

            'comment': 'PassiveSpectroscopy, ADC 2, ch 11'

        },{

            'comment': 'PassiveSpectroscopy, ADC 2, ch 12'

        },{

            'comment': 'PassiveSpectroscopy, ADC 2, ch 13'

        },{

            'comment': 'PassiveSpectroscopy, ADC 2, ch 14'

        },{

            'comment': 'PassiveSpectroscopy, ADC 2, ch 15'

        },{

            'comment': 'PassiveSpectroscopy, ADC 2, ch 16'

        }

    ]

},

{

    'yRes': 2.5,

    'frequencyHz': 50e3,

    'ch': [

        {

            'comment': 'PassiveSpectroscopy, ADC 3, ch 1'

        },

        {

            'comment': 'PassiveSpectroscopy, ADC 3, ch 2'

        },

        {

            'comment': 'PassiveSpectroscopy, ADC 3, ch 3'

        },{

            'comment': 'PassiveSpectroscopy, ADC 3, ch 4'

        },{

            'comment': 'PassiveSpectroscopy, ADC 3, ch 5'

        },{

            'comment': 'PassiveSpectroscopy, ADC 3, ch 6'

        },{

            'comment': 'PassiveSpectroscopy, ADC 3, ch 7'

        },{

            'comment': 'PassiveSpectroscopy, ADC 3, ch 8'

        },{

            'comment': 'PassiveSpectroscopy, ADC 3, ch 9'

        },{

            'comment': 'PassiveSpectroscopy, ADC 3, ch 10'

        },

        {

            'comment': 'PassiveSpectroscopy, ADC 3, ch 11'

        },

        {

            'comment': 'PassiveSpectroscopy, ADC 3, ch 12'

        },{

            'comment': 'PassiveSpectroscopy, ADC 3, ch 13'

        },{

            'comment': 'PassiveSpectroscopy, ADC 3, ch 14'

        },{

            'comment': 'PassiveSpectroscopy, ADC 3, ch 15'

        },{

            'comment': 'PassiveSpectroscopy, ADC 3, ch 16'

        }

    ]

},

    {

    'yRes': 2.5,

    'frequencyHz': 50e3,

    'ch': [

        {

            'comment': 'PassiveSpectroscopy, ADC 4, ch 1'

        },

        {

            'comment': 'PassiveSpectroscopy, ADC 4, ch 2'

        },

        {

            'comment': 'PassiveSpectroscopy, ADC 4, ch 3'

        },{

            'comment': 'PassiveSpectroscopy, ADC 4, ch 4'

        },{

            'comment': 'PassiveSpectroscopy, ADC 4, ch 5'

        },{

            'comment': 'PassiveSpectroscopy, ADC 4, ch 6'

        },{

            'comment': 'PassiveSpectroscopy, ADC 4, ch 7'

        },{

            'comment': 'PassiveSpectroscopy, ADC 4, ch 8'

        },{

            'comment': 'PassiveSpectroscopy, ADC 4, ch 9'

        },

        {

            'comment': 'PassiveSpectroscopy, ADC 4, ch 10'

        },

        {

            'comment': 'PassiveSpectroscopy, ADC 4, ch 11'

        },

        {

            'comment': 'PassiveSpectroscopy, ADC 4, ch 12'

        },{

            'comment': 'PassiveSpectroscopy, ADC 4, ch 13'

        },{

            'comment': 'PassiveSpectroscopy, ADC 4, ch 14'

        },{

            'comment': 'PassiveSpectroscopy, ADC 4, ch 15'

        },{

            'comment': 'PassiveSpectroscopy, ADC 4, ch 16'

        }

    ]

}

]



merge: list[str] = []

#merge.append('%ssht%d.SHT' % (sht_path, shotn))



for i in range(4):

    path = '%s%d\\ADC%d\\' % (Tukhmeneva_path, shotn, i+1)

    packed = shtRipper.ripper.write_ADC(path=path, filename='adc_data.slow', data=names[i])

    merge.append('%s\\adc_data.slow.sht' % path)



print(merge)



shtRipper.ripper.merge('', 'all_%d.sht' % shotn, merge)



#res = shtRipper.ripper.read('all_%d.sht' % shotn)

#print(res.keys())





print('OK.')

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

shtripper_cpp-1.6.2.tar.gz (836.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

shtRipper_cpp-1.6.2-py3-none-any.whl (837.2 kB view details)

Uploaded Python 3

File details

Details for the file shtripper_cpp-1.6.2.tar.gz.

File metadata

  • Download URL: shtripper_cpp-1.6.2.tar.gz
  • Upload date:
  • Size: 836.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.3

File hashes

Hashes for shtripper_cpp-1.6.2.tar.gz
Algorithm Hash digest
SHA256 0c7fe22d442a74263acaf53afc8219f451f663a01bcb0332c1185ca462b80219
MD5 a805dfaf94a7f7a9692e5768656c8deb
BLAKE2b-256 1ac3d32cd488dd46f5d47240ce81f11e28be67781e86a1a3efc01f42cee97819

See more details on using hashes here.

File details

Details for the file shtRipper_cpp-1.6.2-py3-none-any.whl.

File metadata

  • Download URL: shtRipper_cpp-1.6.2-py3-none-any.whl
  • Upload date:
  • Size: 837.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.3

File hashes

Hashes for shtRipper_cpp-1.6.2-py3-none-any.whl
Algorithm Hash digest
SHA256 20db6d5a89de59b11ae460f875fb4c2c0adb53c62753cec8211832c872ff4997
MD5 7a3552457ff9f17540e0d5d76f510311
BLAKE2b-256 dcfb6035b70e3fb25cc595a10f47326b7762504c6b7924e09cacef0dd1db6ce8

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page