pychemstation 0.4.7.dev1__py3-none-any.whl → 0.4.7.dev2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pychemstation/control/__init__.py +3 -2
- hein-analytical-control/devices/Agilent/hplc.py → pychemstation/control/comm.py +21 -181
- pychemstation/control/method.py +232 -0
- pychemstation/control/sequence.py +140 -0
- pychemstation/control/table_controller.py +75 -0
- pychemstation/utils/__init__.py +0 -2
- {ag_hplc_macro/control → pychemstation/utils}/chromatogram.py +2 -1
- pychemstation/utils/constants.py +1 -1
- hein_analytical_control/devices/Agilent/hplc_param_types.py → pychemstation/utils/macro.py +5 -69
- pychemstation/utils/method_types.py +44 -0
- pychemstation/utils/sequence_types.py +33 -0
- pychemstation/utils/table_types.py +60 -0
- {pychemstation-0.4.7.dev1.dist-info → pychemstation-0.4.7.dev2.dist-info}/METADATA +13 -12
- pychemstation-0.4.7.dev2.dist-info/RECORD +30 -0
- ag_hplc_macro/__init__.py +0 -3
- ag_hplc_macro/analysis/__init__.py +0 -1
- ag_hplc_macro/analysis/base_spectrum.py +0 -509
- ag_hplc_macro/analysis/spec_utils.py +0 -304
- ag_hplc_macro/analysis/utils.py +0 -63
- ag_hplc_macro/control/__init__.py +0 -5
- ag_hplc_macro/control/hplc.py +0 -673
- ag_hplc_macro/generated/__init__.py +0 -56
- ag_hplc_macro/generated/dad_method.py +0 -367
- ag_hplc_macro/generated/pump_method.py +0 -519
- ag_hplc_macro/utils/__init__.py +0 -2
- ag_hplc_macro/utils/constants.py +0 -15
- ag_hplc_macro/utils/hplc_param_types.py +0 -185
- hein-analytical-control/__init__.py +0 -3
- hein-analytical-control/analysis/__init__.py +0 -1
- hein-analytical-control/analysis/base_spectrum.py +0 -509
- hein-analytical-control/analysis/spec_utils.py +0 -304
- hein-analytical-control/analysis/utils.py +0 -63
- hein-analytical-control/devices/Agilent/__init__.py +0 -3
- hein-analytical-control/devices/Agilent/chemstation.py +0 -290
- hein-analytical-control/devices/Agilent/chromatogram.py +0 -129
- hein-analytical-control/devices/Agilent/hplc_param_types.py +0 -141
- hein-analytical-control/devices/Magritek/Spinsolve/__init__.py +0 -0
- hein-analytical-control/devices/Magritek/Spinsolve/commands.py +0 -495
- hein-analytical-control/devices/Magritek/Spinsolve/spectrum.py +0 -822
- hein-analytical-control/devices/Magritek/Spinsolve/spinsolve.py +0 -425
- hein-analytical-control/devices/Magritek/Spinsolve/utils/__init__.py +0 -5
- hein-analytical-control/devices/Magritek/Spinsolve/utils/connection.py +0 -168
- hein-analytical-control/devices/Magritek/Spinsolve/utils/constants.py +0 -8
- hein-analytical-control/devices/Magritek/Spinsolve/utils/exceptions.py +0 -25
- hein-analytical-control/devices/Magritek/Spinsolve/utils/parser.py +0 -340
- hein-analytical-control/devices/Magritek/Spinsolve/utils/shimming.py +0 -55
- hein-analytical-control/devices/Magritek/Spinsolve/utils/spinsolve_logging.py +0 -43
- hein-analytical-control/devices/Magritek/__init__.py +0 -0
- hein-analytical-control/devices/OceanOptics/IR/NIRQuest512.py +0 -90
- hein-analytical-control/devices/OceanOptics/IR/__init__.py +0 -0
- hein-analytical-control/devices/OceanOptics/IR/ir_spectrum.py +0 -191
- hein-analytical-control/devices/OceanOptics/Raman/__init__.py +0 -0
- hein-analytical-control/devices/OceanOptics/Raman/raman_control.py +0 -46
- hein-analytical-control/devices/OceanOptics/Raman/raman_spectrum.py +0 -148
- hein-analytical-control/devices/OceanOptics/UV/QEPro2192.py +0 -90
- hein-analytical-control/devices/OceanOptics/UV/__init__.py +0 -0
- hein-analytical-control/devices/OceanOptics/UV/uv_spectrum.py +0 -227
- hein-analytical-control/devices/OceanOptics/__init__.py +0 -0
- hein-analytical-control/devices/OceanOptics/oceanoptics.py +0 -115
- hein-analytical-control/devices/__init__.py +0 -15
- hein-analytical-control/generated/__init__.py +0 -56
- hein-analytical-control/generated/dad_method.py +0 -367
- hein-analytical-control/generated/pump_method.py +0 -519
- hein_analytical_control/__init__.py +0 -3
- hein_analytical_control/analysis/__init__.py +0 -1
- hein_analytical_control/analysis/base_spectrum.py +0 -509
- hein_analytical_control/analysis/spec_utils.py +0 -304
- hein_analytical_control/analysis/utils.py +0 -63
- hein_analytical_control/devices/Agilent/__init__.py +0 -3
- hein_analytical_control/devices/Agilent/chemstation.py +0 -290
- hein_analytical_control/devices/Agilent/chromatogram.py +0 -129
- hein_analytical_control/devices/Agilent/hplc.py +0 -436
- hein_analytical_control/devices/Magritek/Spinsolve/__init__.py +0 -0
- hein_analytical_control/devices/Magritek/Spinsolve/commands.py +0 -495
- hein_analytical_control/devices/Magritek/Spinsolve/spectrum.py +0 -822
- hein_analytical_control/devices/Magritek/Spinsolve/spinsolve.py +0 -425
- hein_analytical_control/devices/Magritek/Spinsolve/utils/__init__.py +0 -5
- hein_analytical_control/devices/Magritek/Spinsolve/utils/connection.py +0 -168
- hein_analytical_control/devices/Magritek/Spinsolve/utils/constants.py +0 -8
- hein_analytical_control/devices/Magritek/Spinsolve/utils/exceptions.py +0 -25
- hein_analytical_control/devices/Magritek/Spinsolve/utils/parser.py +0 -340
- hein_analytical_control/devices/Magritek/Spinsolve/utils/shimming.py +0 -55
- hein_analytical_control/devices/Magritek/Spinsolve/utils/spinsolve_logging.py +0 -43
- hein_analytical_control/devices/Magritek/__init__.py +0 -0
- hein_analytical_control/devices/OceanOptics/IR/NIRQuest512.py +0 -90
- hein_analytical_control/devices/OceanOptics/IR/__init__.py +0 -0
- hein_analytical_control/devices/OceanOptics/IR/ir_spectrum.py +0 -191
- hein_analytical_control/devices/OceanOptics/Raman/__init__.py +0 -0
- hein_analytical_control/devices/OceanOptics/Raman/raman_control.py +0 -46
- hein_analytical_control/devices/OceanOptics/Raman/raman_spectrum.py +0 -148
- hein_analytical_control/devices/OceanOptics/UV/QEPro2192.py +0 -90
- hein_analytical_control/devices/OceanOptics/UV/__init__.py +0 -0
- hein_analytical_control/devices/OceanOptics/UV/uv_spectrum.py +0 -227
- hein_analytical_control/devices/OceanOptics/__init__.py +0 -0
- hein_analytical_control/devices/OceanOptics/oceanoptics.py +0 -115
- hein_analytical_control/devices/__init__.py +0 -15
- hein_analytical_control/generated/__init__.py +0 -56
- hein_analytical_control/generated/dad_method.py +0 -367
- hein_analytical_control/generated/pump_method.py +0 -519
- pychemstation-0.4.7.dev1.dist-info/RECORD +0 -109
- /ag_hplc_macro/utils/chemstation.py → /pychemstation/utils/parsing.py +0 -0
- {pychemstation-0.4.7.dev1.dist-info → pychemstation-0.4.7.dev2.dist-info}/LICENSE +0 -0
- {pychemstation-0.4.7.dev1.dist-info → pychemstation-0.4.7.dev2.dist-info}/WHEEL +0 -0
- {pychemstation-0.4.7.dev1.dist-info → pychemstation-0.4.7.dev2.dist-info}/top_level.txt +0 -0
@@ -1,129 +0,0 @@
|
|
1
|
-
"""Module for HPLC chromatogram data loading and manipulating"""
|
2
|
-
|
3
|
-
import os
|
4
|
-
import logging
|
5
|
-
import time
|
6
|
-
|
7
|
-
import numpy as np
|
8
|
-
|
9
|
-
from .chemstation import CHFile
|
10
|
-
|
11
|
-
from ...analysis import AbstractSpectrum
|
12
|
-
|
13
|
-
# Chemstation data path
|
14
|
-
DATA_DIR = r"C:\Chem32\1\Data"
|
15
|
-
|
16
|
-
|
17
|
-
# standard filenames for spectral data
|
18
|
-
CHANNELS = {"A": "01", "B": "02", "C": "03", "D": "04"}
|
19
|
-
|
20
|
-
ACQUISITION_PARAMETERS = "acq.txt"
|
21
|
-
|
22
|
-
# format used in acquisition parameters
|
23
|
-
TIME_FORMAT = "%Y-%m-%d-%H-%M-%S"
|
24
|
-
|
25
|
-
|
26
|
-
class AgilentHPLCChromatogram(AbstractSpectrum):
|
27
|
-
"""Class for HPLC spectrum (chromatogram) loading and handling."""
|
28
|
-
|
29
|
-
AXIS_MAPPING = {"x": "min", "y": "mAu"}
|
30
|
-
|
31
|
-
INTERNAL_PROPERTIES = {
|
32
|
-
"baseline",
|
33
|
-
"parameters",
|
34
|
-
"data_path",
|
35
|
-
}
|
36
|
-
|
37
|
-
# set of properties to be saved
|
38
|
-
PUBLIC_PROPERTIES = {
|
39
|
-
"x",
|
40
|
-
"y",
|
41
|
-
"peaks",
|
42
|
-
"timestamp",
|
43
|
-
}
|
44
|
-
|
45
|
-
def __init__(self, path=None, autosaving=False):
|
46
|
-
|
47
|
-
if path is not None:
|
48
|
-
os.makedirs(path, exist_ok=True)
|
49
|
-
self.path = path
|
50
|
-
else:
|
51
|
-
self.path = os.path.join(".", "hplc_data")
|
52
|
-
os.makedirs(self.path, exist_ok=True)
|
53
|
-
|
54
|
-
self.logger = logging.getLogger("AgilentHPLCChromatogram")
|
55
|
-
|
56
|
-
super().__init__(path=path, autosaving=autosaving)
|
57
|
-
|
58
|
-
def load_spectrum(self, data_path, channel="A"):
|
59
|
-
"""Loads the spectra from the given folder.
|
60
|
-
|
61
|
-
Args:
|
62
|
-
data_path (str): Path where HPLC data has been saved.
|
63
|
-
"""
|
64
|
-
|
65
|
-
# to avoid dropping parameters when called in parent class
|
66
|
-
if self.x is not None:
|
67
|
-
if self.autosaving:
|
68
|
-
self.save_data(filename=f"{data_path}_{channel}")
|
69
|
-
self._dump()
|
70
|
-
|
71
|
-
# get raw data
|
72
|
-
x, y = self.extract_rawdata(data_path, channel)
|
73
|
-
|
74
|
-
# get timestamp
|
75
|
-
tstr = data_path.split(".")[0].split("_")[-1]
|
76
|
-
timestamp = time.mktime(time.strptime(tstr, TIME_FORMAT))
|
77
|
-
|
78
|
-
# loading all data
|
79
|
-
super().load_spectrum(x, y, timestamp)
|
80
|
-
|
81
|
-
### PUBLIC METHODS TO LOAD RAW DATA ###
|
82
|
-
|
83
|
-
def extract_rawdata(self, experiment_dir: str, channel: str):
|
84
|
-
"""
|
85
|
-
Reads raw data from Chemstation .CH files.
|
86
|
-
|
87
|
-
Args:
|
88
|
-
experiment_dir: .D directory with the .CH files
|
89
|
-
|
90
|
-
Returns:
|
91
|
-
np.array(times), np.array(values) Raw chromatogram data
|
92
|
-
"""
|
93
|
-
filename = os.path.join(experiment_dir, f"DAD1{channel}")
|
94
|
-
npz_file = filename + ".npz"
|
95
|
-
|
96
|
-
if os.path.exists(npz_file):
|
97
|
-
# already processed
|
98
|
-
data = np.load(npz_file)
|
99
|
-
return data["times"], data["values"]
|
100
|
-
else:
|
101
|
-
self.logger.debug("NPZ file not found. First time loading data.")
|
102
|
-
ch_file = filename + ".ch"
|
103
|
-
data = CHFile(ch_file)
|
104
|
-
np.savez_compressed(npz_file, times=data.times, values=data.values)
|
105
|
-
return np.array(data.times), np.array(data.values)
|
106
|
-
|
107
|
-
def extract_peakarea(self, experiment_dir: str):
|
108
|
-
"""
|
109
|
-
Reads processed data from Chemstation report files.
|
110
|
-
|
111
|
-
Args:
|
112
|
-
experiment_dir: .D directory with the report files
|
113
|
-
"""
|
114
|
-
# filename = os.path.join(experiment_dir, f"REPORT{CHANNELS[channel]}.csv")
|
115
|
-
# TODO parse file properly
|
116
|
-
# data = np.genfromtxt(filename, delimiter=',')
|
117
|
-
# return data
|
118
|
-
pass
|
119
|
-
|
120
|
-
def default_processing(self):
|
121
|
-
"""
|
122
|
-
Processes the chromatogram in place.
|
123
|
-
"""
|
124
|
-
# trim first 5 min and last 3 min of run
|
125
|
-
self.trim(5, 25)
|
126
|
-
# parameters found to work best for chromatogram data
|
127
|
-
self.correct_baseline(lmbd=1e5, p=0.0001, n_iter=10)
|
128
|
-
# get all peaks in processed chromatogram
|
129
|
-
self.find_peaks()
|
@@ -1,141 +0,0 @@
|
|
1
|
-
from dataclasses import dataclass
|
2
|
-
from enum import Enum
|
3
|
-
from typing import Union, Any
|
4
|
-
|
5
|
-
from ...generated import SolventElement, Signal
|
6
|
-
|
7
|
-
|
8
|
-
# Commands sent to the Chemstation Macro
|
9
|
-
# See https://www.agilent.com/cs/library/usermanuals/Public/MACROS.PDF
|
10
|
-
class Command(Enum):
|
11
|
-
def __str__(self):
|
12
|
-
return '%s' % self.value
|
13
|
-
|
14
|
-
RESET_COUNTER_CMD = "last_cmd_no = 0"
|
15
|
-
GET_STATUS_CMD = "response$ = AcqStatus$"
|
16
|
-
SLEEP_CMD = "Sleep {seconds}"
|
17
|
-
STANDBY_CMD = "Standby"
|
18
|
-
STOP_MACRO_CMD = "Stop"
|
19
|
-
PREPRUN_CMD = "PrepRun"
|
20
|
-
LAMP_ON_CMD = "LampAll ON"
|
21
|
-
LAMP_OFF_CMD = "LampAll OFF"
|
22
|
-
PUMP_ON_CMD = "PumpAll ON"
|
23
|
-
PUMP_OFF_CMD = "PumpAll OFF"
|
24
|
-
GET_METHOD_CMD = "response$ = _MethFile$"
|
25
|
-
SWITCH_METHOD_CMD = 'LoadMethod "{method_dir}", "{method_name}.M"'
|
26
|
-
START_METHOD_CMD = "StartMethod"
|
27
|
-
RUN_METHOD_CMD = 'RunMethod "{data_dir}",, "{experiment_name}_{timestamp}"'
|
28
|
-
STOP_METHOD_CMD = "StopMethod"
|
29
|
-
UPDATE_METHOD_CMD = 'UpdateMethod'
|
30
|
-
|
31
|
-
|
32
|
-
class RegisterFlag(Enum):
|
33
|
-
def __str__(self):
|
34
|
-
return '%s' % self.value
|
35
|
-
|
36
|
-
SOLVENT_A_COMPOSITION = "PumpChannel_CompositionPercentage"
|
37
|
-
SOLVENT_B_COMPOSITION = "PumpChannel2_CompositionPercentage"
|
38
|
-
SOLVENT_C_COMPOSITION = "PumpChannel3_CompositionPercentage"
|
39
|
-
SOLVENT_D_COMPOSITION = "PumpChannel4_CompositionPercentage"
|
40
|
-
FLOW = "Flow"
|
41
|
-
MAX_TIME = "StopTime_Time"
|
42
|
-
COLUMN_OVEN_TEMP1 = "TemperatureControl_Temperature"
|
43
|
-
COLUMN_OVEN_TEMP2 = "TemperatureControl2_Temperature"
|
44
|
-
STOPTIME_MODE = "StopTime_Mode"
|
45
|
-
POSTIME_MODE = "PostTime_Mode"
|
46
|
-
|
47
|
-
|
48
|
-
class MethodTableOperation(Enum):
|
49
|
-
def __str__(self):
|
50
|
-
return '%s' % self.value
|
51
|
-
|
52
|
-
DELETE_TABLE = 'DelTab RCPMP1Method[1], "Timetable"'
|
53
|
-
CREATE_TABLE = 'NewTab RCPMP1Method[1], "Timetable"'
|
54
|
-
NEW_ROW = 'InsTabRow RCPMP1Method[1], "Timetable"'
|
55
|
-
NEW_COLUMN = ""
|
56
|
-
DOWNLOAD_TABLE = ""
|
57
|
-
|
58
|
-
|
59
|
-
class PType(Enum):
|
60
|
-
STR = "str"
|
61
|
-
NUM = "num"
|
62
|
-
|
63
|
-
|
64
|
-
@dataclass
|
65
|
-
class Param:
|
66
|
-
ptype: PType
|
67
|
-
val: Union[float, int, str, Any]
|
68
|
-
chemstation_key: Union[RegisterFlag, list[RegisterFlag]]
|
69
|
-
|
70
|
-
|
71
|
-
@dataclass
|
72
|
-
class HPLCMethodParams:
|
73
|
-
organic_modifier: Param
|
74
|
-
flow: Param
|
75
|
-
temperature: Param
|
76
|
-
inj_vol: Param
|
77
|
-
equ_time: Param
|
78
|
-
maximum_run_time: Param
|
79
|
-
|
80
|
-
|
81
|
-
@dataclass
|
82
|
-
class Entry:
|
83
|
-
start_time: float
|
84
|
-
organic_modifer: float
|
85
|
-
flow: float
|
86
|
-
|
87
|
-
|
88
|
-
@dataclass
|
89
|
-
class MethodTimetable:
|
90
|
-
first_row: HPLCMethodParams
|
91
|
-
subsequent_rows: list[Entry]
|
92
|
-
dad_wavelengthes: list[Signal]
|
93
|
-
organic_modifier: SolventElement
|
94
|
-
modifier_a: SolventElement
|
95
|
-
|
96
|
-
|
97
|
-
class HPLCRunningStatus(Enum):
|
98
|
-
@classmethod
|
99
|
-
def has_member_key(cls, key):
|
100
|
-
return key in cls.__members__
|
101
|
-
|
102
|
-
INJECTING = "INJECTING"
|
103
|
-
PREPARING = "PREPARING"
|
104
|
-
RUN = "RUN"
|
105
|
-
NOTREADY = "NOTREADY"
|
106
|
-
POSTRUN = "POSTRUN"
|
107
|
-
RAWDATA = "RAWDATA"
|
108
|
-
INITIALIZING = "INITIALIZING"
|
109
|
-
NOMODULE = "NOMODULE"
|
110
|
-
|
111
|
-
|
112
|
-
class HPLCAvailStatus(Enum):
|
113
|
-
@classmethod
|
114
|
-
def has_member_key(cls, key):
|
115
|
-
return key in cls.__members__
|
116
|
-
|
117
|
-
PRERUN = "PRERUN"
|
118
|
-
OFFLINE = "OFFLINE"
|
119
|
-
STANDBY = "STANDBY"
|
120
|
-
|
121
|
-
|
122
|
-
class HPLCErrorStatus(Enum):
|
123
|
-
|
124
|
-
@classmethod
|
125
|
-
def has_member_key(cls, key):
|
126
|
-
return key in cls.__members__
|
127
|
-
|
128
|
-
ERROR = "ERROR"
|
129
|
-
BREAK = "BREAK"
|
130
|
-
NORESPONSE = "NORESPONSE"
|
131
|
-
MALFORMED = "MALFORMED"
|
132
|
-
|
133
|
-
|
134
|
-
def str_to_status(status: str) -> Union[HPLCAvailStatus, HPLCErrorStatus, HPLCRunningStatus]:
|
135
|
-
if HPLCErrorStatus.has_member_key(status):
|
136
|
-
return HPLCErrorStatus[status]
|
137
|
-
if HPLCRunningStatus.has_member_key(status):
|
138
|
-
return HPLCRunningStatus[status]
|
139
|
-
if HPLCAvailStatus.has_member_key(status):
|
140
|
-
return HPLCAvailStatus[status]
|
141
|
-
raise KeyError(status)
|
File without changes
|