@complat/react-spectra-editor 1.0.0-rc2 → 1.0.0-rc20.patch-1
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.
- package/README.md +16 -0
- package/dist/__tests__/fixtures/aif_jcamp_1.js +136 -0
- package/dist/__tests__/fixtures/aif_jcamp_2.js +122 -0
- package/dist/__tests__/fixtures/backup/nmr1h_a.js +3518 -0
- package/dist/__tests__/fixtures/backup/xrd_jcamp_1.js +10705 -0
- package/dist/__tests__/fixtures/cds_jcamp.js +861 -0
- package/dist/__tests__/fixtures/compare_ir_1_jcamp.js +585 -0
- package/dist/__tests__/fixtures/compare_ir_2_jcamp.js +515 -0
- package/dist/__tests__/fixtures/compare_uv_vis_jcamp.js +640 -0
- package/dist/__tests__/fixtures/cyclic_voltammetry_1.js +778 -0
- package/dist/__tests__/fixtures/cyclic_voltammetry_2.js +758 -0
- package/dist/__tests__/fixtures/cyclic_voltammetry_3.js +759 -0
- package/dist/__tests__/fixtures/dls_acf_jcamp.js +148 -0
- package/dist/__tests__/fixtures/dls_intensity_jcamp.js +151 -0
- package/dist/__tests__/fixtures/emissions_jcamp.js +883 -0
- package/dist/__tests__/fixtures/hplc_uvvis_jcamp.js +638 -0
- package/dist/__tests__/fixtures/hplc_uvvis_jcamp_2.js +221 -0
- package/dist/__tests__/fixtures/ir_jcamp.js +148 -0
- package/dist/__tests__/fixtures/ir_result.js +46 -0
- package/dist/__tests__/fixtures/ir_svg.js +8 -0
- package/dist/__tests__/fixtures/ms_jcamp.js +64 -0
- package/dist/__tests__/fixtures/nmr13c_dept_jcamp.js +3543 -0
- package/dist/__tests__/fixtures/nmr13c_jcamp.js +1229 -0
- package/dist/__tests__/fixtures/nmr15n_jcamp.js +7177 -0
- package/dist/__tests__/fixtures/nmr19f_jcamp.js +6560 -0
- package/dist/__tests__/fixtures/nmr1h_2_jcamp.js +2005 -0
- package/dist/__tests__/fixtures/nmr1h_jcamp.js +4516 -0
- package/dist/__tests__/fixtures/nmr29si_jcamp.js +3029 -0
- package/dist/__tests__/fixtures/nmr31p_jcamp.js +3418 -0
- package/dist/__tests__/fixtures/nmr_result.js +68 -0
- package/dist/__tests__/fixtures/nmr_svg.js +8 -0
- package/dist/__tests__/fixtures/phenylalanin.js +142 -0
- package/dist/__tests__/fixtures/qDescValue.js +65 -0
- package/dist/__tests__/fixtures/raman_jcamp.js +410 -0
- package/dist/__tests__/fixtures/sec_1_jcamp.js +425 -0
- package/dist/__tests__/fixtures/sec_2_jcamp.js +407 -0
- package/dist/__tests__/fixtures/sec_3_jcamp.js +408 -0
- package/dist/__tests__/fixtures/sec_4_jcamp.js +407 -0
- package/dist/__tests__/fixtures/tga_jcamp.js +4157 -0
- package/dist/__tests__/fixtures/uv_vis_jcamp.js +249 -0
- package/dist/__tests__/fixtures/xrd_jcamp_1.js +436 -0
- package/dist/__tests__/fixtures/xrd_jcamp_2.js +955 -0
- package/dist/__tests__/fixtures/xrd_jcamp_3.js +1871 -0
- package/dist/__tests__/units/components/panel/graph_selection.test.js +72 -0
- package/dist/__tests__/units/components/panel/peaks.test.js +87 -0
- package/dist/actions/curve.js +15 -14
- package/dist/actions/cyclic_voltammetry.js +40 -60
- package/dist/actions/edit_peak.js +8 -12
- package/dist/actions/forecast.js +16 -24
- package/dist/actions/integration.js +12 -18
- package/dist/actions/jcamp.js +16 -24
- package/dist/actions/layout.js +4 -6
- package/dist/actions/manager.js +20 -30
- package/dist/actions/meta.js +4 -6
- package/dist/actions/multiplicity.js +24 -36
- package/dist/actions/scan.js +12 -18
- package/dist/actions/shift.js +8 -12
- package/dist/actions/status.js +12 -18
- package/dist/actions/submit.js +16 -24
- package/dist/actions/threshold.js +20 -30
- package/dist/actions/ui.js +25 -31
- package/dist/actions/wavelength.js +4 -6
- package/dist/app.js +25 -23
- package/dist/components/cmd_bar/01_viewer.js +24 -34
- package/dist/components/cmd_bar/02_zoom.js +18 -28
- package/dist/components/cmd_bar/03_peak.js +50 -66
- package/dist/components/cmd_bar/04_integration.js +70 -84
- package/dist/components/cmd_bar/05_multiplicity.js +42 -56
- package/dist/components/cmd_bar/06_undo_redo.js +22 -36
- package/dist/components/cmd_bar/07_pecker.js +24 -34
- package/dist/components/cmd_bar/common.js +11 -7
- package/dist/components/cmd_bar/index.js +17 -23
- package/dist/components/cmd_bar/r01_layout.js +79 -56
- package/dist/components/cmd_bar/r02_scan.js +70 -87
- package/dist/components/cmd_bar/r03_threshold.js +54 -68
- package/dist/components/cmd_bar/r04_submit.js +71 -83
- package/dist/components/cmd_bar/r05_submit_btn.js +64 -72
- package/dist/components/cmd_bar/r06_predict_btn.js +142 -152
- package/dist/components/cmd_bar/r07_wavelength_btn.js +28 -36
- package/dist/components/cmd_bar/tri_btn.js +91 -113
- package/dist/components/common/chem.js +2 -3
- package/dist/components/common/comps.js +2 -2
- package/dist/components/common/draw.js +30 -11
- package/dist/components/d3_line/index.js +154 -176
- package/dist/components/d3_line/line_focus.js +595 -739
- package/dist/components/d3_multi/index.js +153 -174
- package/dist/components/d3_multi/multi_focus.js +725 -850
- package/dist/components/d3_rect/index.js +112 -134
- package/dist/components/d3_rect/rect_focus.js +163 -208
- package/dist/components/forecast/comps.js +60 -68
- package/dist/components/forecast/ir_comps.js +49 -56
- package/dist/components/forecast/ir_viewer.js +61 -68
- package/dist/components/forecast/nmr_comps.js +62 -72
- package/dist/components/forecast/nmr_viewer.js +59 -68
- package/dist/components/forecast/section_loading.js +39 -63
- package/dist/components/forecast_viewer.js +109 -119
- package/dist/components/multi_jcamps_viewer.js +97 -113
- package/dist/components/panel/compare.js +183 -192
- package/dist/components/panel/cyclic_voltamery_data.js +149 -165
- package/dist/components/panel/graph_selection.js +143 -132
- package/dist/components/panel/index.js +112 -144
- package/dist/components/panel/info.js +125 -132
- package/dist/components/panel/multiplicity.js +215 -223
- package/dist/components/panel/multiplicity_coupling.js +108 -136
- package/dist/components/panel/multiplicity_select.js +43 -51
- package/dist/components/panel/peaks.js +130 -132
- package/dist/constants/action_type.js +23 -39
- package/dist/constants/list_layout.js +7 -4
- package/dist/constants/list_shift.js +117 -103
- package/dist/constants/list_ui.js +3 -6
- package/dist/constants/list_wavelength.js +7 -8
- package/dist/fn.js +2 -3
- package/dist/helpers/brush.js +49 -65
- package/dist/helpers/calc.js +2 -4
- package/dist/helpers/carbonFeatures.js +22 -20
- package/dist/helpers/cfg.js +49 -67
- package/dist/helpers/chem.js +450 -393
- package/dist/helpers/compass.js +92 -83
- package/dist/helpers/converter.js +52 -65
- package/dist/helpers/extractParams.js +60 -52
- package/dist/helpers/extractPeaksEdit.js +29 -25
- package/dist/helpers/focus.js +2 -6
- package/dist/helpers/format.js +416 -361
- package/dist/helpers/init.js +41 -37
- package/dist/helpers/integration.js +18 -21
- package/dist/helpers/mount.js +57 -61
- package/dist/helpers/multiplicity.js +19 -24
- package/dist/helpers/multiplicity_calc.js +39 -50
- package/dist/helpers/multiplicity_complat.js +21 -47
- package/dist/helpers/multiplicity_manual.js +49 -55
- package/dist/helpers/multiplicity_verify_basic.js +108 -111
- package/dist/helpers/shift.js +15 -23
- package/dist/helpers/zoom.js +7 -11
- package/dist/index.js +680 -630
- package/dist/layer_content.js +40 -43
- package/dist/layer_init.js +162 -184
- package/dist/layer_prism.js +38 -41
- package/dist/reducers/index.js +2 -3
- package/dist/reducers/reducer_curve.js +35 -26
- package/dist/reducers/reducer_edit_peak.js +122 -98
- package/dist/reducers/reducer_forecast.js +57 -44
- package/dist/reducers/reducer_integration.js +135 -103
- package/dist/reducers/reducer_jcamp.js +49 -44
- package/dist/reducers/reducer_layout.js +5 -6
- package/dist/reducers/reducer_manager.js +5 -6
- package/dist/reducers/reducer_meta.js +5 -6
- package/dist/reducers/reducer_multiplicity.js +100 -77
- package/dist/reducers/reducer_scan.js +17 -20
- package/dist/reducers/reducer_shift.js +115 -70
- package/dist/reducers/reducer_simulation.js +7 -8
- package/dist/reducers/reducer_status.js +5 -6
- package/dist/reducers/reducer_submit.js +12 -15
- package/dist/reducers/reducer_threshold.js +5 -6
- package/dist/reducers/reducer_ui.js +5 -6
- package/dist/reducers/reducer_voltammetry.js +156 -96
- package/dist/reducers/reducer_wavelength.js +5 -6
- package/dist/reducers/undo_redo_config.js +3 -5
- package/dist/sagas/index.js +2 -15
- package/dist/sagas/saga_edit_peak.js +54 -68
- package/dist/sagas/saga_manager.js +86 -130
- package/dist/sagas/saga_meta.js +25 -31
- package/dist/sagas/saga_multi_entities.js +40 -103
- package/dist/sagas/saga_multiplicity.js +336 -406
- package/dist/sagas/saga_ui.js +296 -475
- package/dist/setupTests.js +8 -0
- package/dist/third_party/jAnalyzer.js +66 -67
- package/dist/third_party/peakInterval.js +34 -34
- package/package.json +14 -14
- package/dist/components/cmd_bar/03_peak_bk.js +0 -139
- package/dist/components/cmd_bar/04_integration_bk.js +0 -180
- package/dist/components/cmd_bar/05_multiplicity_bk.js +0 -131
- package/dist/components/cmd_bar/r01_layout_bk.js +0 -186
- package/dist/components/cmd_bar/r06_predict_btn_bk.js +0 -220
- package/dist/components/d3_line/line_focus_bk.js +0 -825
- package/dist/components/d3_multi/index_bk.js +0 -210
- package/dist/components/d3_multi/multi_focus_bk.js +0 -533
- package/dist/components/panel/compare_bk.js +0 -256
- package/dist/components/panel/cyclic_voltamery_data_bk.js +0 -292
- package/dist/components/panel/index_bk.js +0 -178
- package/dist/components/panel/info_bk.js +0 -235
- package/dist/components/panel/multiplicity_bk.js +0 -280
- package/dist/helpers/carbonFeatures_bk.js +0 -45
- package/dist/helpers/cfg_bk.js +0 -80
- package/dist/helpers/chem_bk.js +0 -787
- package/dist/helpers/compass_bk.js +0 -149
- package/dist/helpers/converter_bk.js +0 -96
- package/dist/helpers/extractPeaksEdit_bk.js +0 -53
- package/dist/helpers/format_bk.js +0 -497
- package/dist/index_bk.js +0 -640
- package/dist/layer_content_bk.js +0 -105
- package/dist/layer_init_bk.js +0 -235
- package/dist/layer_prism_bk.js +0 -133
- package/dist/reducers/reducer_edit_peak_bk.js +0 -108
- package/dist/reducers/reducer_integration_bk.js +0 -134
- package/dist/reducers/reducer_jcamp_bk.js +0 -71
- package/dist/reducers/reducer_multiplicity_bk.js +0 -126
- package/dist/reducers/reducer_shift_bk.js +0 -88
- package/dist/reducers/reducer_voltammetry_bk.js +0 -287
- package/dist/sagas/saga_edit_peak_bk.js +0 -73
- package/dist/sagas/saga_multi_entities_bk.js +0 -106
- package/dist/sagas/saga_multiplicity_bk.js +0 -351
- package/dist/sagas/saga_ui_bk.js +0 -453
package/dist/helpers/chem.js
CHANGED
|
@@ -5,7 +5,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.convertTopic = exports.Topic2Seed = exports.ToThresEndPts = exports.ToShiftPeaks = exports.ToFrequency = exports.GetCyclicVoltaRatio = exports.GetCyclicVoltaPeakSeparate = exports.GetComparisons = exports.Feature2Peak = exports.Feature2MaxMinPeak = exports.ExtractJcamp = exports.Convert2Thres = exports.Convert2Scan = exports.Convert2Peak = exports.Convert2MaxMinPeak = exports.Convert2DValue = void 0;
|
|
8
|
-
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
9
8
|
var _jcampconverter = _interopRequireDefault(require("jcampconverter"));
|
|
10
9
|
var _reselect = require("reselect");
|
|
11
10
|
var _shift = require("./shift");
|
|
@@ -15,215 +14,223 @@ var _list_layout = require("../constants/list_layout");
|
|
|
15
14
|
var _integration = require("./integration");
|
|
16
15
|
/* eslint-disable
|
|
17
16
|
no-mixed-operators, react/function-component-definition,
|
|
18
|
-
prefer-object-spread, camelcase, no-plusplus */
|
|
17
|
+
prefer-object-spread, camelcase, no-plusplus, prefer-destructuring */
|
|
19
18
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
var getFeature = function getFeature(_, props) {
|
|
24
|
-
return props.feature;
|
|
25
|
-
};
|
|
26
|
-
var getLayout = function getLayout(state, _) {
|
|
27
|
-
return state.layout;
|
|
28
|
-
}; // eslint-disable-line
|
|
19
|
+
const getTopic = (_, props) => props.topic;
|
|
20
|
+
const getFeature = (_, props) => props.feature;
|
|
21
|
+
const getLayout = (state, _) => state.layout; // eslint-disable-line
|
|
29
22
|
|
|
30
|
-
|
|
23
|
+
const getShiftOffset = (state, _) => {
|
|
31
24
|
// eslint-disable-line
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
25
|
+
const {
|
|
26
|
+
curve,
|
|
27
|
+
shift
|
|
28
|
+
} = state;
|
|
29
|
+
const {
|
|
30
|
+
curveIdx
|
|
31
|
+
} = curve;
|
|
32
|
+
const {
|
|
33
|
+
shifts
|
|
34
|
+
} = shift;
|
|
35
|
+
const selectedShift = shifts[curveIdx];
|
|
37
36
|
if (!selectedShift) {
|
|
38
37
|
return 0.0;
|
|
39
38
|
}
|
|
40
39
|
|
|
41
40
|
// const { shift } = state;
|
|
42
|
-
|
|
43
|
-
|
|
41
|
+
const {
|
|
42
|
+
ref,
|
|
43
|
+
peak
|
|
44
|
+
} = selectedShift;
|
|
44
45
|
return (0, _shift.FromManualToOffset)(ref, peak);
|
|
45
46
|
};
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
for (
|
|
47
|
+
const calcXYK = (xs, ys, maxY, offset) => {
|
|
48
|
+
const sp = [];
|
|
49
|
+
let k = 0;
|
|
50
|
+
for (let i = 0; i < ys.length; i += 1) {
|
|
50
51
|
// no-downsample
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
52
|
+
const x = xs[i] - offset;
|
|
53
|
+
const y = ys[i];
|
|
54
|
+
const cy = y / maxY;
|
|
54
55
|
if (cy > 0.0) {
|
|
55
56
|
k += cy;
|
|
56
57
|
}
|
|
57
58
|
sp.push({
|
|
58
|
-
x
|
|
59
|
-
y
|
|
60
|
-
k
|
|
59
|
+
x,
|
|
60
|
+
y,
|
|
61
|
+
k
|
|
61
62
|
});
|
|
62
63
|
}
|
|
63
64
|
return sp;
|
|
64
65
|
};
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
for (
|
|
66
|
+
const calcXY = (xs, ys, maxY, offset) => {
|
|
67
|
+
const sp = [];
|
|
68
|
+
for (let i = 0; i < ys.length; i += 1) {
|
|
68
69
|
// no-downsample
|
|
69
|
-
|
|
70
|
-
|
|
70
|
+
const x = xs[i] - offset;
|
|
71
|
+
const y = ys[i];
|
|
71
72
|
sp.push({
|
|
72
|
-
x
|
|
73
|
-
y
|
|
73
|
+
x,
|
|
74
|
+
y
|
|
74
75
|
});
|
|
75
76
|
}
|
|
76
77
|
return sp;
|
|
77
78
|
};
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
79
|
+
const convertTopic = (topic, layout, feature, offset) => {
|
|
80
|
+
const {
|
|
81
|
+
maxY
|
|
82
|
+
} = feature;
|
|
83
|
+
const xs = topic.x;
|
|
84
|
+
const ys = topic.y;
|
|
85
|
+
const isItgDisable = _cfg.default.btnCmdIntg(layout);
|
|
83
86
|
if (!isItgDisable) return calcXYK(xs, ys, maxY, offset);
|
|
84
87
|
return calcXY(xs, ys, maxY, offset);
|
|
85
88
|
};
|
|
86
89
|
exports.convertTopic = convertTopic;
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
};
|
|
92
|
-
var calcRescaleXY = function calcRescaleXY(xs, ys, minY, maxY, show) {
|
|
93
|
-
var sp = [];
|
|
90
|
+
const Topic2Seed = exports.Topic2Seed = (0, _reselect.createSelector)(getTopic, getLayout, getFeature, getShiftOffset, convertTopic);
|
|
91
|
+
const getOthers = (_, props) => props.comparisons;
|
|
92
|
+
const calcRescaleXY = (xs, ys, minY, maxY, show) => {
|
|
93
|
+
const sp = [];
|
|
94
94
|
if (xs.length < 1) return sp;
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
var faktor = (maxY - minY) / (upperY - lowerY);
|
|
99
|
-
for (var i = 0; i < ys.length; i += 2) {
|
|
95
|
+
const [lowerY, upperY] = [Math.min(...ys), Math.max(...ys)];
|
|
96
|
+
const faktor = (maxY - minY) / (upperY - lowerY);
|
|
97
|
+
for (let i = 0; i < ys.length; i += 2) {
|
|
100
98
|
// downsample
|
|
101
|
-
|
|
102
|
-
|
|
99
|
+
const x = xs[i];
|
|
100
|
+
const y = (ys[i] - lowerY) * faktor + minY;
|
|
103
101
|
sp.push({
|
|
104
|
-
x
|
|
105
|
-
y
|
|
102
|
+
x,
|
|
103
|
+
y
|
|
106
104
|
});
|
|
107
105
|
}
|
|
108
106
|
return {
|
|
109
107
|
data: sp,
|
|
110
|
-
show
|
|
108
|
+
show
|
|
111
109
|
};
|
|
112
110
|
};
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
111
|
+
const convertComparisons = (layout, comparisons, feature) => {
|
|
112
|
+
const {
|
|
113
|
+
minY,
|
|
114
|
+
maxY
|
|
115
|
+
} = feature;
|
|
116
116
|
if (!comparisons || !(_format.default.isIrLayout(layout) || _format.default.isHplcUvVisLayout(layout) || _format.default.isXRDLayout(layout))) return [];
|
|
117
|
-
return comparisons.map(
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
117
|
+
return comparisons.map(c => {
|
|
118
|
+
const {
|
|
119
|
+
spectra,
|
|
120
|
+
show
|
|
121
|
+
} = c;
|
|
122
|
+
const topic = spectra[0].data[0];
|
|
123
|
+
const xs = topic.x;
|
|
124
|
+
const ys = topic.y;
|
|
123
125
|
return calcRescaleXY(xs, ys, minY, maxY, show);
|
|
124
126
|
});
|
|
125
127
|
};
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
var convertFrequency = function convertFrequency(layout, feature) {
|
|
128
|
+
const GetComparisons = exports.GetComparisons = (0, _reselect.createSelector)(getLayout, getOthers, getFeature, convertComparisons);
|
|
129
|
+
const convertFrequency = (layout, feature) => {
|
|
129
130
|
if (['1H', '13C', '19F', '31P', '15N', '29Si'].indexOf(layout) < 0) return false;
|
|
130
|
-
|
|
131
|
-
|
|
131
|
+
const {
|
|
132
|
+
observeFrequency
|
|
133
|
+
} = feature;
|
|
134
|
+
const freq = Array.isArray(observeFrequency) ? observeFrequency[0] : observeFrequency;
|
|
132
135
|
return parseFloat(freq) || false;
|
|
133
136
|
};
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
var upThreshold = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
|
141
|
-
var lowThreshold = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
|
|
142
|
-
var peak = [];
|
|
137
|
+
const ToFrequency = exports.ToFrequency = (0, _reselect.createSelector)(getLayout, getFeature, convertFrequency);
|
|
138
|
+
const getThreshold = state => state.threshold ? state.threshold.value * 1.0 : false;
|
|
139
|
+
const Convert2Peak = function (feature, threshold, offset) {
|
|
140
|
+
let upThreshold = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
|
141
|
+
let lowThreshold = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
|
|
142
|
+
const peak = [];
|
|
143
143
|
if (!feature || !feature.data) return peak;
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
144
|
+
const data = feature.data[0];
|
|
145
|
+
const {
|
|
146
|
+
maxY,
|
|
147
|
+
peakUp,
|
|
148
|
+
thresRef,
|
|
149
|
+
minY,
|
|
150
|
+
upperThres,
|
|
151
|
+
lowerThres,
|
|
152
|
+
operation
|
|
153
|
+
} = feature;
|
|
154
|
+
const {
|
|
155
|
+
layout
|
|
156
|
+
} = operation;
|
|
157
|
+
|
|
158
|
+
// if (!Format.isSECLayout(layout) && (upperThres || lowerThres)) {
|
|
159
|
+
if ((_format.default.isCyclicVoltaLayout(layout) || _format.default.isCDSLayout(layout)) && (upperThres || lowerThres)) {
|
|
160
|
+
let upperThresVal = upThreshold || upperThres;
|
|
155
161
|
if (!upperThresVal) {
|
|
156
162
|
upperThresVal = 1.0;
|
|
157
163
|
}
|
|
158
|
-
|
|
164
|
+
let lowerThresVal = lowThreshold || lowerThres;
|
|
159
165
|
if (!lowerThresVal) {
|
|
160
166
|
lowerThresVal = 1.0;
|
|
161
167
|
}
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
for (
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
168
|
+
const yUpperThres = parseFloat(upperThresVal) / 100.0 * maxY;
|
|
169
|
+
const yLowerThres = parseFloat(lowerThresVal) / 100.0 * minY;
|
|
170
|
+
const corrOffset = offset || 0.0;
|
|
171
|
+
for (let i = 0; i < data.y.length; i += 1) {
|
|
172
|
+
const y = data.y[i];
|
|
173
|
+
const overUpperThres = y >= yUpperThres;
|
|
174
|
+
const belowThres = y <= yLowerThres;
|
|
169
175
|
if (overUpperThres || belowThres) {
|
|
170
|
-
|
|
176
|
+
const x = data.x[i] - corrOffset;
|
|
171
177
|
peak.push({
|
|
172
|
-
x
|
|
173
|
-
y
|
|
178
|
+
x,
|
|
179
|
+
y
|
|
174
180
|
});
|
|
175
181
|
}
|
|
176
182
|
}
|
|
177
183
|
return peak;
|
|
178
184
|
}
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
for (
|
|
183
|
-
|
|
184
|
-
|
|
185
|
+
const thresVal = threshold || thresRef;
|
|
186
|
+
const yThres = Number.parseFloat((thresVal * maxY / 100.0).toFixed(10));
|
|
187
|
+
const corrOffset = offset || 0.0;
|
|
188
|
+
for (let i = 0; i < data.y.length; i += 1) {
|
|
189
|
+
const y = data.y[i];
|
|
190
|
+
const overThres = peakUp && Math.abs(y) >= yThres || !peakUp && Math.abs(y) <= yThres;
|
|
185
191
|
if (overThres) {
|
|
186
|
-
|
|
192
|
+
const x = data.x[i] - corrOffset;
|
|
187
193
|
peak.push({
|
|
188
|
-
x
|
|
189
|
-
y
|
|
194
|
+
x,
|
|
195
|
+
y
|
|
190
196
|
});
|
|
191
197
|
}
|
|
192
198
|
}
|
|
193
199
|
return peak;
|
|
194
200
|
};
|
|
195
201
|
exports.Convert2Peak = Convert2Peak;
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
var peaks = {
|
|
202
|
+
const Feature2Peak = exports.Feature2Peak = (0, _reselect.createSelector)(getFeature, getThreshold, getShiftOffset, Convert2Peak);
|
|
203
|
+
const Convert2MaxMinPeak = (layout, feature, offset) => {
|
|
204
|
+
const peaks = {
|
|
200
205
|
max: [],
|
|
201
206
|
min: [],
|
|
202
207
|
pecker: []
|
|
203
208
|
};
|
|
204
209
|
if (!_format.default.isCyclicVoltaLayout(layout) || !feature || !feature.data) return null; // eslint-disable-line
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
210
|
+
const data = feature.data[0]; // eslint-disable-line
|
|
211
|
+
const {
|
|
212
|
+
maxY,
|
|
213
|
+
minY,
|
|
214
|
+
upperThres,
|
|
215
|
+
lowerThres,
|
|
216
|
+
volammetryData
|
|
217
|
+
} = feature;
|
|
211
218
|
if (volammetryData && volammetryData.length > 0) {
|
|
212
|
-
|
|
219
|
+
const maxArr = volammetryData.map(peakData => {
|
|
213
220
|
if (peakData.max.x === '') return null;
|
|
214
221
|
return {
|
|
215
222
|
x: Number(peakData.max.x),
|
|
216
223
|
y: Number(peakData.max.y)
|
|
217
224
|
};
|
|
218
225
|
});
|
|
219
|
-
|
|
226
|
+
const minArr = volammetryData.map(peakData => {
|
|
220
227
|
if (peakData.min.x === '') return null;
|
|
221
228
|
return {
|
|
222
229
|
x: Number(peakData.min.x),
|
|
223
230
|
y: Number(peakData.min.y)
|
|
224
231
|
};
|
|
225
232
|
});
|
|
226
|
-
|
|
233
|
+
const peckerArr = volammetryData.map(peakData => {
|
|
227
234
|
if (peakData.pecker.x === '') return null;
|
|
228
235
|
return {
|
|
229
236
|
x: Number(peakData.pecker.x),
|
|
@@ -235,48 +242,49 @@ var Convert2MaxMinPeak = function Convert2MaxMinPeak(layout, feature, offset) {
|
|
|
235
242
|
peaks.pecker = peckerArr;
|
|
236
243
|
return peaks;
|
|
237
244
|
}
|
|
238
|
-
|
|
245
|
+
let upperThresVal = upperThres;
|
|
239
246
|
if (!upperThresVal) {
|
|
240
247
|
upperThresVal = 1.0;
|
|
241
248
|
}
|
|
242
|
-
|
|
249
|
+
let lowerThresVal = lowerThres;
|
|
243
250
|
if (!lowerThresVal) {
|
|
244
251
|
lowerThresVal = 1.0;
|
|
245
252
|
}
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
for (
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
253
|
+
const yUpperThres = parseFloat(upperThresVal) / 100.0 * maxY;
|
|
254
|
+
const yLowerThres = parseFloat(lowerThresVal) / 100.0 * minY;
|
|
255
|
+
const corrOffset = offset || 0.0;
|
|
256
|
+
for (let i = 0; i < data.y.length; i += 1) {
|
|
257
|
+
const y = data.y[i];
|
|
258
|
+
const overUpperThres = y >= yUpperThres;
|
|
259
|
+
const belowThres = y <= yLowerThres;
|
|
260
|
+
const x = data.x[i] - corrOffset;
|
|
254
261
|
if (overUpperThres) {
|
|
255
262
|
peaks.max.push({
|
|
256
|
-
x
|
|
257
|
-
y
|
|
263
|
+
x,
|
|
264
|
+
y
|
|
258
265
|
});
|
|
259
266
|
} else if (belowThres) {
|
|
260
267
|
peaks.min.push({
|
|
261
|
-
x
|
|
262
|
-
y
|
|
268
|
+
x,
|
|
269
|
+
y
|
|
263
270
|
});
|
|
264
271
|
}
|
|
265
272
|
}
|
|
266
273
|
return peaks;
|
|
267
274
|
};
|
|
268
275
|
exports.Convert2MaxMinPeak = Convert2MaxMinPeak;
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
maxX
|
|
274
|
-
minX
|
|
275
|
-
thresRef
|
|
276
|
-
|
|
276
|
+
const Feature2MaxMinPeak = exports.Feature2MaxMinPeak = (0, _reselect.createSelector)(getLayout, getFeature, getShiftOffset, Convert2MaxMinPeak);
|
|
277
|
+
const convertThresEndPts = (feature, threshold) => {
|
|
278
|
+
const {
|
|
279
|
+
maxY,
|
|
280
|
+
maxX,
|
|
281
|
+
minX,
|
|
282
|
+
thresRef
|
|
283
|
+
} = feature;
|
|
284
|
+
const thresVal = threshold || thresRef || 0;
|
|
277
285
|
if (!thresVal || !feature.data) return [];
|
|
278
|
-
|
|
279
|
-
|
|
286
|
+
const yThres = thresVal * maxY / 100.0;
|
|
287
|
+
const endPts = [{
|
|
280
288
|
x: minX - 200,
|
|
281
289
|
y: yThres
|
|
282
290
|
}, {
|
|
@@ -285,37 +293,45 @@ var convertThresEndPts = function convertThresEndPts(feature, threshold) {
|
|
|
285
293
|
}];
|
|
286
294
|
return endPts;
|
|
287
295
|
};
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
shift
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
+
const ToThresEndPts = exports.ToThresEndPts = (0, _reselect.createSelector)(getFeature, getThreshold, convertThresEndPts);
|
|
297
|
+
const getShiftPeak = state => {
|
|
298
|
+
const {
|
|
299
|
+
curve,
|
|
300
|
+
shift
|
|
301
|
+
} = state;
|
|
302
|
+
const {
|
|
303
|
+
curveIdx
|
|
304
|
+
} = curve;
|
|
305
|
+
const {
|
|
306
|
+
shifts
|
|
307
|
+
} = shift;
|
|
308
|
+
const selectedShift = shifts[curveIdx];
|
|
296
309
|
if (!selectedShift) {
|
|
297
310
|
return false;
|
|
298
311
|
}
|
|
299
312
|
return selectedShift.peak;
|
|
300
313
|
};
|
|
301
|
-
|
|
314
|
+
const convertSfPeaks = (peak, offset) => {
|
|
302
315
|
if (!peak || !peak.x) return [];
|
|
303
316
|
return [{
|
|
304
317
|
x: peak.x - offset,
|
|
305
318
|
y: peak.y
|
|
306
319
|
}];
|
|
307
320
|
};
|
|
308
|
-
|
|
321
|
+
const ToShiftPeaks = exports.ToShiftPeaks = (0, _reselect.createSelector)(getShiftPeak, getShiftOffset, convertSfPeaks);
|
|
309
322
|
|
|
310
323
|
// - - - - - - - - - - - - - - - - - - - - - -
|
|
311
324
|
// ExtractJcamp
|
|
312
325
|
// - - - - - - - - - - - - - - - - - - - - - -
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
spectra
|
|
326
|
+
const readLayout = jcamp => {
|
|
327
|
+
const {
|
|
328
|
+
xType,
|
|
329
|
+
spectra
|
|
330
|
+
} = jcamp;
|
|
317
331
|
if (xType && _format.default.isNmrLayout(xType)) return xType;
|
|
318
|
-
|
|
332
|
+
const {
|
|
333
|
+
dataType
|
|
334
|
+
} = spectra[0];
|
|
319
335
|
if (dataType) {
|
|
320
336
|
if (dataType.includes('INFRARED SPECTRUM')) {
|
|
321
337
|
return _list_layout.LIST_LAYOUT.IR;
|
|
@@ -347,59 +363,88 @@ var readLayout = function readLayout(jcamp) {
|
|
|
347
363
|
if (dataType.includes('SIZE EXCLUSION CHROMATOGRAPHY')) {
|
|
348
364
|
return _list_layout.LIST_LAYOUT.SEC;
|
|
349
365
|
}
|
|
366
|
+
if (dataType.includes('SORPTION-DESORPTION MEASUREMENT')) {
|
|
367
|
+
return _list_layout.LIST_LAYOUT.AIF;
|
|
368
|
+
}
|
|
369
|
+
if (dataType.includes('Emissions')) {
|
|
370
|
+
return _list_layout.LIST_LAYOUT.EMISSIONS;
|
|
371
|
+
}
|
|
372
|
+
if (dataType.includes('DLS ACF')) {
|
|
373
|
+
return _list_layout.LIST_LAYOUT.DLS_ACF;
|
|
374
|
+
}
|
|
375
|
+
if (dataType.includes('DLS intensity')) {
|
|
376
|
+
return _list_layout.LIST_LAYOUT.DLS_INTENSITY;
|
|
377
|
+
}
|
|
350
378
|
}
|
|
351
379
|
return false;
|
|
352
380
|
};
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
381
|
+
const extrSpectraShare = (spectra, layout) => spectra.map(s => Object.assign({
|
|
382
|
+
layout
|
|
383
|
+
}, s)).filter(r => r != null);
|
|
384
|
+
const extrSpectraMs = (jcamp, layout) => {
|
|
385
|
+
const scanCount = jcamp.info.$CSSCANCOUNT || 1;
|
|
386
|
+
const spc = extrSpectraShare(jcamp.spectra.slice(0, scanCount), layout);
|
|
387
|
+
let spectra = spc || [];
|
|
388
|
+
if (jcamp.info.UNITS && jcamp.info.SYMBOL) {
|
|
389
|
+
const units = jcamp.info.UNITS.split(',');
|
|
390
|
+
const symbol = jcamp.info.SYMBOL.split(',');
|
|
391
|
+
let xUnit = null;
|
|
392
|
+
let yUnit = null;
|
|
393
|
+
symbol.forEach((sym, idx) => {
|
|
394
|
+
const currSymbol = sym.replace(' ', '').toLowerCase();
|
|
395
|
+
if (currSymbol === 'x') {
|
|
396
|
+
xUnit = units[idx].trim();
|
|
397
|
+
} else if (currSymbol === 'y') {
|
|
398
|
+
yUnit = units[idx].trim();
|
|
399
|
+
}
|
|
400
|
+
});
|
|
401
|
+
spectra = spectra.map(sp => {
|
|
402
|
+
const spectrum = sp;
|
|
403
|
+
if (xUnit) {
|
|
404
|
+
spectrum.xUnit = xUnit;
|
|
405
|
+
}
|
|
406
|
+
if (yUnit) {
|
|
407
|
+
spectrum.yUnit = yUnit;
|
|
408
|
+
}
|
|
409
|
+
return spectrum;
|
|
410
|
+
});
|
|
411
|
+
}
|
|
412
|
+
return spectra;
|
|
366
413
|
};
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
414
|
+
const extrSpectraNi = (jcamp, layout) => {
|
|
415
|
+
const categorys = jcamp.info.$CSCATEGORY || ['SPECTRUM'];
|
|
416
|
+
const targetIdx = categorys.indexOf('SPECTRUM');
|
|
417
|
+
const spectrum = extrSpectraShare(jcamp.spectra, layout)[targetIdx];
|
|
371
418
|
return [spectrum] || [jcamp.spectra[0]];
|
|
372
419
|
};
|
|
373
|
-
|
|
374
|
-
|
|
420
|
+
const calcThresRef = (s, peakUp) => {
|
|
421
|
+
const ys = s && s.data[0].y;
|
|
375
422
|
if (!ys) return null;
|
|
376
|
-
|
|
377
|
-
return Math.abs(a);
|
|
378
|
-
}))) : Math.max.apply(Math, (0, _toConsumableArray2.default)(ys));
|
|
423
|
+
const ref = peakUp ? Math.min(...ys.map(a => Math.abs(a))) : Math.max(...ys);
|
|
379
424
|
return peakUp ? Math.floor(ref * 100 * 100 / s.maxY) / 100 : Math.ceil(ref * 100 * 100 / s.maxY) / 100;
|
|
380
425
|
};
|
|
381
|
-
|
|
382
|
-
|
|
426
|
+
const calcUpperThres = s => {
|
|
427
|
+
const ys = s && s.data[0].y;
|
|
383
428
|
if (!ys) return null;
|
|
384
|
-
|
|
429
|
+
const ref = Math.max(...ys);
|
|
385
430
|
return Math.floor(ref * 100 * 100 / s.maxY) / 100;
|
|
386
431
|
};
|
|
387
|
-
|
|
388
|
-
|
|
432
|
+
const calcLowerThres = s => {
|
|
433
|
+
const ys = s && s.data[0].y;
|
|
389
434
|
if (!ys) return null;
|
|
390
|
-
|
|
435
|
+
const ref = Math.min(...ys);
|
|
391
436
|
return Math.ceil(ref * 100 * 100 / s.minY) / 100;
|
|
392
437
|
};
|
|
393
|
-
|
|
394
|
-
|
|
438
|
+
const extractShift = (s, jcamp) => {
|
|
439
|
+
const shift = {
|
|
395
440
|
selectX: false,
|
|
396
441
|
solventName: false,
|
|
397
442
|
solventValue: false
|
|
398
443
|
};
|
|
399
444
|
if (!s) return shift;
|
|
400
445
|
if (s && s.sampleDescription) {
|
|
401
|
-
|
|
402
|
-
|
|
446
|
+
const desc = s.sampleDescription;
|
|
447
|
+
const info = desc.split(/;|=/);
|
|
403
448
|
return {
|
|
404
449
|
selectX: parseFloat(info[1]),
|
|
405
450
|
solventName: info[3],
|
|
@@ -412,13 +457,15 @@ var extractShift = function extractShift(s, jcamp) {
|
|
|
412
457
|
solventValue: parseFloat(jcamp.info.$CSSOLVENTVALUE) || false
|
|
413
458
|
};
|
|
414
459
|
};
|
|
415
|
-
|
|
416
|
-
|
|
460
|
+
const extractVoltammetryData = jcamp => {
|
|
461
|
+
const {
|
|
462
|
+
info
|
|
463
|
+
} = jcamp;
|
|
417
464
|
if (!info.$CSCYCLICVOLTAMMETRYDATA) return null;
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
465
|
+
const regx = /[^0-9.,E,e,-]/g;
|
|
466
|
+
const rawData = info.$CSCYCLICVOLTAMMETRYDATA.split('\n');
|
|
467
|
+
const peakStack = rawData.map(line => {
|
|
468
|
+
const splittedLine = line.replace(regx, '').split(',');
|
|
422
469
|
return {
|
|
423
470
|
max: {
|
|
424
471
|
x: splittedLine[0],
|
|
@@ -438,67 +485,71 @@ var extractVoltammetryData = function extractVoltammetryData(jcamp) {
|
|
|
438
485
|
});
|
|
439
486
|
return peakStack;
|
|
440
487
|
};
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
488
|
+
const buildPeakFeature = function (jcamp, layout, peakUp, s, thresRef) {
|
|
489
|
+
let upperThres = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : false;
|
|
490
|
+
let lowerThres = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : false;
|
|
444
491
|
// eslint-disable-line
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
492
|
+
const {
|
|
493
|
+
xType,
|
|
494
|
+
info
|
|
495
|
+
} = jcamp;
|
|
496
|
+
const subTyp = xType ? ` - ${xType}` : '';
|
|
448
497
|
return Object.assign({
|
|
449
498
|
typ: s.dataType + subTyp,
|
|
450
|
-
peakUp
|
|
451
|
-
thresRef
|
|
499
|
+
peakUp,
|
|
500
|
+
thresRef,
|
|
452
501
|
scanCount: +info.$CSSCANCOUNT,
|
|
453
502
|
scanAutoTarget: +info.$CSSCANAUTOTARGET,
|
|
454
503
|
scanEditTarget: +info.$CSSCANEDITTARGET,
|
|
455
504
|
shift: extractShift(s, jcamp),
|
|
456
505
|
operation: {
|
|
457
|
-
layout
|
|
506
|
+
layout,
|
|
458
507
|
nucleus: xType || ''
|
|
459
508
|
},
|
|
460
509
|
observeFrequency: info['.OBSERVEFREQUENCY'],
|
|
461
510
|
solventName: info['.SOLVENTNAME'],
|
|
462
|
-
upperThres
|
|
463
|
-
lowerThres
|
|
511
|
+
upperThres,
|
|
512
|
+
lowerThres,
|
|
464
513
|
volammetryData: extractVoltammetryData(jcamp)
|
|
465
514
|
}, s);
|
|
466
515
|
};
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
516
|
+
const maxArray = arr => {
|
|
517
|
+
let len = arr.length;
|
|
518
|
+
let max = -Infinity;
|
|
470
519
|
while (len--) {
|
|
471
520
|
max = arr[len] > max ? arr[len] : max;
|
|
472
521
|
}
|
|
473
522
|
return max;
|
|
474
523
|
};
|
|
475
|
-
|
|
524
|
+
const calcIntgRefArea = (spectra, stack) => {
|
|
476
525
|
if (stack.length === 0) return 1;
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
xL
|
|
484
|
-
xU
|
|
485
|
-
area
|
|
486
|
-
|
|
487
|
-
|
|
526
|
+
const data = spectra[0].data[0];
|
|
527
|
+
const xs = data.x;
|
|
528
|
+
const ys = data.y;
|
|
529
|
+
const maxY = maxArray(ys);
|
|
530
|
+
const xyk = calcXYK(xs, ys, maxY, 0);
|
|
531
|
+
const {
|
|
532
|
+
xL,
|
|
533
|
+
xU,
|
|
534
|
+
area
|
|
535
|
+
} = stack[0];
|
|
536
|
+
const rawArea = (0, _integration.getArea)(xL, xU, xyk);
|
|
537
|
+
const raw2realRatio = rawArea / area;
|
|
488
538
|
return {
|
|
489
|
-
raw2realRatio
|
|
539
|
+
raw2realRatio
|
|
490
540
|
};
|
|
491
541
|
};
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
$OBSERVEDINTEGRALS
|
|
495
|
-
$OBSERVEDMULTIPLETS
|
|
496
|
-
|
|
497
|
-
|
|
542
|
+
const buildIntegFeature = (jcamp, spectra) => {
|
|
543
|
+
const {
|
|
544
|
+
$OBSERVEDINTEGRALS,
|
|
545
|
+
$OBSERVEDMULTIPLETS
|
|
546
|
+
} = jcamp.info;
|
|
547
|
+
const regx = /[^0-9.,-]/g;
|
|
548
|
+
let stack = [];
|
|
498
549
|
if ($OBSERVEDINTEGRALS) {
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
550
|
+
const its = $OBSERVEDINTEGRALS.split('\n').slice(1);
|
|
551
|
+
const itStack = its.map(t => {
|
|
552
|
+
const ts = t.replace(regx, '').split(',');
|
|
502
553
|
return {
|
|
503
554
|
xL: parseFloat(ts[0]),
|
|
504
555
|
xU: parseFloat(ts[1]),
|
|
@@ -506,27 +557,26 @@ var buildIntegFeature = function buildIntegFeature(jcamp, spectra) {
|
|
|
506
557
|
absoluteArea: parseFloat(ts[3])
|
|
507
558
|
};
|
|
508
559
|
});
|
|
509
|
-
stack = [
|
|
560
|
+
stack = [...stack, ...itStack];
|
|
510
561
|
}
|
|
511
562
|
if ($OBSERVEDMULTIPLETS) {
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
563
|
+
const mps = $OBSERVEDMULTIPLETS.split('\n');
|
|
564
|
+
const mpStack = mps.map(m => {
|
|
565
|
+
const ms = m.replace(regx, '').split(',');
|
|
515
566
|
return {
|
|
516
567
|
xL: parseFloat(ms[1]),
|
|
517
568
|
xU: parseFloat(ms[2]),
|
|
518
569
|
area: parseFloat(ms[4])
|
|
519
570
|
};
|
|
520
571
|
});
|
|
521
|
-
stack = [
|
|
572
|
+
stack = [...stack, ...mpStack];
|
|
522
573
|
}
|
|
523
|
-
|
|
524
|
-
raw2realRatio
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
});
|
|
574
|
+
const {
|
|
575
|
+
raw2realRatio
|
|
576
|
+
} = calcIntgRefArea(spectra, stack);
|
|
577
|
+
const mStack = stack.map(st => Object.assign({}, st, {
|
|
578
|
+
area: st.area * raw2realRatio
|
|
579
|
+
}));
|
|
530
580
|
return {
|
|
531
581
|
refArea: raw2realRatio,
|
|
532
582
|
refFactor: 1,
|
|
@@ -545,91 +595,84 @@ const range = (head, tail, length) => {
|
|
|
545
595
|
};
|
|
546
596
|
*/
|
|
547
597
|
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
598
|
+
const buildSimFeature = jcamp => {
|
|
599
|
+
const {
|
|
600
|
+
$CSSIMULATIONPEAKS
|
|
601
|
+
} = jcamp.info;
|
|
602
|
+
let nmrSimPeaks = $CSSIMULATIONPEAKS ? $CSSIMULATIONPEAKS.split('\n') : [];
|
|
603
|
+
nmrSimPeaks = nmrSimPeaks.map(x => parseFloat(x).toFixed(2));
|
|
554
604
|
return {
|
|
555
|
-
nmrSimPeaks
|
|
605
|
+
nmrSimPeaks
|
|
556
606
|
};
|
|
557
607
|
};
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
$OBSERVEDMULTIPLETS
|
|
561
|
-
$OBSERVEDMULTIPLETSPEAKS
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
608
|
+
const buildMpyFeature = jcamp => {
|
|
609
|
+
const {
|
|
610
|
+
$OBSERVEDMULTIPLETS,
|
|
611
|
+
$OBSERVEDMULTIPLETSPEAKS
|
|
612
|
+
} = jcamp.info;
|
|
613
|
+
const regx = /[^A-Za-z0-9.,-]/g;
|
|
614
|
+
const regxNum = /[^0-9.]/g;
|
|
615
|
+
let stack = [];
|
|
565
616
|
if (!$OBSERVEDMULTIPLETSPEAKS) return {
|
|
566
617
|
stack: []
|
|
567
618
|
};
|
|
568
|
-
|
|
569
|
-
return p.replace(regx, '').split(',');
|
|
570
|
-
});
|
|
619
|
+
const allPeaks = $OBSERVEDMULTIPLETSPEAKS.split('\n').map(p => p.replace(regx, '').split(','));
|
|
571
620
|
if ($OBSERVEDMULTIPLETS) {
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
621
|
+
const mp = $OBSERVEDMULTIPLETS.split('\n');
|
|
622
|
+
const mpStack = mp.map(m => {
|
|
623
|
+
const ms = m.replace(regx, '').split(',');
|
|
624
|
+
const idx = ms[0];
|
|
625
|
+
let ys = [];
|
|
626
|
+
const peaks = allPeaks.map(p => {
|
|
578
627
|
if (p[0] === idx) {
|
|
579
|
-
ys = [
|
|
628
|
+
ys = [...ys, parseFloat(p[2])];
|
|
580
629
|
return {
|
|
581
630
|
x: parseFloat(p[1]),
|
|
582
631
|
y: parseFloat(p[2])
|
|
583
632
|
};
|
|
584
633
|
}
|
|
585
634
|
return null;
|
|
586
|
-
}).filter(
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
var js = m.split(',');
|
|
590
|
-
js = js[js.length - 1].split(' ').map(function (j) {
|
|
591
|
-
return parseFloat(j.replace(regxNum, ''));
|
|
592
|
-
}).filter(Boolean);
|
|
635
|
+
}).filter(r => r != null);
|
|
636
|
+
let js = m.split(',');
|
|
637
|
+
js = js[js.length - 1].split(' ').map(j => parseFloat(j.replace(regxNum, ''))).filter(Boolean);
|
|
593
638
|
return {
|
|
594
|
-
js
|
|
639
|
+
js,
|
|
595
640
|
mpyType: ms[6],
|
|
596
641
|
xExtent: {
|
|
597
642
|
xL: parseFloat(ms[1]),
|
|
598
643
|
xU: parseFloat(ms[2])
|
|
599
644
|
},
|
|
600
645
|
yExtent: {
|
|
601
|
-
yL: Math.min
|
|
602
|
-
yU: Math.max
|
|
646
|
+
yL: Math.min(...ys),
|
|
647
|
+
yU: Math.max(...ys)
|
|
603
648
|
},
|
|
604
|
-
peaks
|
|
649
|
+
peaks
|
|
605
650
|
};
|
|
606
651
|
});
|
|
607
|
-
stack = [
|
|
652
|
+
stack = [...stack, ...mpStack];
|
|
608
653
|
}
|
|
609
654
|
return {
|
|
610
|
-
stack
|
|
655
|
+
stack,
|
|
611
656
|
shift: 0,
|
|
612
657
|
smExtext: false
|
|
613
658
|
};
|
|
614
659
|
};
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
};
|
|
618
|
-
|
|
619
|
-
var nfs = {};
|
|
620
|
-
var category = jcamp.info.$CSCATEGORY;
|
|
660
|
+
const isPeakTable = s => s.dataType && (s.dataType.includes('PEAKTABLE') || s.dataType.includes('PEAK ASSIGNMENTS'));
|
|
661
|
+
const extrFeaturesNi = (jcamp, layout, peakUp, spectra) => {
|
|
662
|
+
const nfs = {};
|
|
663
|
+
const category = jcamp.info.$CSCATEGORY;
|
|
621
664
|
if (category) {
|
|
622
|
-
|
|
665
|
+
const idxEditPeak = category.indexOf('EDIT_PEAK');
|
|
623
666
|
if (idxEditPeak >= 0) {
|
|
624
|
-
|
|
625
|
-
|
|
667
|
+
const sEP = jcamp.spectra[idxEditPeak];
|
|
668
|
+
const thresRef = calcThresRef(sEP, peakUp);
|
|
626
669
|
nfs.editPeak = buildPeakFeature(jcamp, layout, peakUp, sEP, thresRef);
|
|
627
670
|
}
|
|
628
|
-
|
|
671
|
+
const idxAutoPeak = category.indexOf('AUTO_PEAK');
|
|
629
672
|
if (idxAutoPeak >= 0) {
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
nfs.autoPeak = buildPeakFeature(jcamp, layout, peakUp, sAP,
|
|
673
|
+
const sAP = jcamp.spectra[idxAutoPeak];
|
|
674
|
+
const thresRef = calcThresRef(sAP, peakUp);
|
|
675
|
+
nfs.autoPeak = buildPeakFeature(jcamp, layout, peakUp, sAP, thresRef);
|
|
633
676
|
}
|
|
634
677
|
nfs.integration = buildIntegFeature(jcamp, spectra);
|
|
635
678
|
nfs.multiplicity = buildMpyFeature(jcamp);
|
|
@@ -637,80 +680,75 @@ var extrFeaturesNi = function extrFeaturesNi(jcamp, layout, peakUp, spectra) {
|
|
|
637
680
|
return nfs;
|
|
638
681
|
}
|
|
639
682
|
// workaround for legacy design
|
|
640
|
-
|
|
641
|
-
|
|
683
|
+
const features = jcamp.spectra.map(s => {
|
|
684
|
+
const thresRef = calcThresRef(s, peakUp);
|
|
642
685
|
return isPeakTable(s) ? buildPeakFeature(jcamp, layout, peakUp, s, thresRef) : null;
|
|
643
|
-
}).filter(
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
var multiplicity = buildMpyFeature(jcamp);
|
|
648
|
-
var simulation = buildSimFeature(jcamp);
|
|
686
|
+
}).filter(r => r != null);
|
|
687
|
+
const integration = buildIntegFeature(jcamp, spectra);
|
|
688
|
+
const multiplicity = buildMpyFeature(jcamp);
|
|
689
|
+
const simulation = buildSimFeature(jcamp);
|
|
649
690
|
return {
|
|
650
691
|
editPeak: features[0],
|
|
651
692
|
autoPeak: features[1],
|
|
652
|
-
integration
|
|
653
|
-
multiplicity
|
|
654
|
-
simulation
|
|
693
|
+
integration,
|
|
694
|
+
multiplicity,
|
|
695
|
+
simulation
|
|
655
696
|
};
|
|
656
697
|
};
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
x
|
|
660
|
-
y
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
698
|
+
const getBoundary = s => {
|
|
699
|
+
const {
|
|
700
|
+
x,
|
|
701
|
+
y
|
|
702
|
+
} = s.data[0];
|
|
703
|
+
const maxX = Math.max(...x);
|
|
704
|
+
const minX = Math.min(...x);
|
|
705
|
+
const maxY = Math.max(...y);
|
|
706
|
+
const minY = Math.min(...y);
|
|
665
707
|
return {
|
|
666
|
-
maxX
|
|
667
|
-
minX
|
|
668
|
-
maxY
|
|
669
|
-
minY
|
|
708
|
+
maxX,
|
|
709
|
+
minX,
|
|
710
|
+
maxY,
|
|
711
|
+
minY
|
|
670
712
|
};
|
|
671
713
|
};
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
714
|
+
const extrFeaturesXrd = (jcamp, layout, peakUp) => {
|
|
715
|
+
const base = jcamp.spectra[0];
|
|
716
|
+
const features = jcamp.spectra.map(s => {
|
|
717
|
+
const upperThres = _format.default.isXRDLayout(layout) ? 100 : calcUpperThres(s);
|
|
718
|
+
const lowerThres = _format.default.isXRDLayout(layout) ? 100 : calcLowerThres(s);
|
|
719
|
+
const cpo = buildPeakFeature(jcamp, layout, peakUp, s, 100, upperThres, lowerThres);
|
|
720
|
+
const bnd = getBoundary(s);
|
|
679
721
|
return Object.assign({}, base, cpo, bnd);
|
|
680
|
-
}).filter(
|
|
681
|
-
|
|
682
|
-
});
|
|
683
|
-
var category = jcamp.info.$CSCATEGORY;
|
|
722
|
+
}).filter(r => r != null);
|
|
723
|
+
const category = jcamp.info.$CSCATEGORY;
|
|
684
724
|
if (category) {
|
|
685
|
-
|
|
725
|
+
const idxEditPeak = category.indexOf('EDIT_PEAK');
|
|
686
726
|
if (idxEditPeak >= 0) {
|
|
687
|
-
|
|
688
|
-
|
|
727
|
+
const sEP = jcamp.spectra[idxEditPeak];
|
|
728
|
+
const thresRef = calcThresRef(sEP, peakUp);
|
|
689
729
|
features.editPeak = buildPeakFeature(jcamp, layout, peakUp, sEP, thresRef);
|
|
690
730
|
}
|
|
691
|
-
|
|
731
|
+
const idxAutoPeak = category.indexOf('AUTO_PEAK');
|
|
692
732
|
if (idxAutoPeak >= 0) {
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
features.autoPeak = buildPeakFeature(jcamp, layout, peakUp, sAP,
|
|
733
|
+
const sAP = jcamp.spectra[idxAutoPeak];
|
|
734
|
+
const thresRef = calcThresRef(sAP, peakUp);
|
|
735
|
+
features.autoPeak = buildPeakFeature(jcamp, layout, peakUp, sAP, thresRef);
|
|
696
736
|
}
|
|
697
737
|
}
|
|
698
738
|
return features;
|
|
699
739
|
};
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
740
|
+
const extrFeaturesCylicVolta = (jcamp, layout, peakUp) => {
|
|
741
|
+
const base = jcamp.spectra[0];
|
|
742
|
+
const features = jcamp.spectra.map(s => {
|
|
743
|
+
const upperThres = _format.default.isXRDLayout(layout) ? 100 : calcUpperThres(s);
|
|
744
|
+
const lowerThres = _format.default.isXRDLayout(layout) ? 100 : calcLowerThres(s);
|
|
745
|
+
const cpo = buildPeakFeature(jcamp, layout, peakUp, s, 100, upperThres, lowerThres);
|
|
746
|
+
const bnd = getBoundary(s);
|
|
707
747
|
return Object.assign({}, base, cpo, bnd);
|
|
708
|
-
}).filter(
|
|
709
|
-
return r != null;
|
|
710
|
-
});
|
|
748
|
+
}).filter(r => r != null);
|
|
711
749
|
return features;
|
|
712
750
|
};
|
|
713
|
-
|
|
751
|
+
const extrFeaturesMs = (jcamp, layout, peakUp) => {
|
|
714
752
|
// const nfs = {};
|
|
715
753
|
// const category = jcamp.info.$CSCATEGORY;
|
|
716
754
|
// const scanCount = parseInt(jcamp.info.$CSSCANCOUNT, 10) - 1;
|
|
@@ -730,32 +768,47 @@ var extrFeaturesMs = function extrFeaturesMs(jcamp, layout, peakUp) {
|
|
|
730
768
|
// return nfs;
|
|
731
769
|
// }
|
|
732
770
|
// // workaround for legacy design
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
771
|
+
const thresRef = jcamp.info && jcamp.info.$CSTHRESHOLD * 100 || 5;
|
|
772
|
+
const base = jcamp.spectra[0];
|
|
773
|
+
const features = jcamp.spectra.map(s => {
|
|
774
|
+
const cpo = buildPeakFeature(jcamp, layout, peakUp, s, +thresRef.toFixed(4));
|
|
775
|
+
const bnd = getBoundary(s);
|
|
738
776
|
return Object.assign({}, base, cpo, bnd);
|
|
739
|
-
}).filter(
|
|
740
|
-
return r != null;
|
|
741
|
-
});
|
|
777
|
+
}).filter(r => r != null);
|
|
742
778
|
return features;
|
|
743
779
|
};
|
|
744
|
-
|
|
745
|
-
|
|
780
|
+
const extractTemperature = jcamp => {
|
|
781
|
+
if ('$CSAUTOMETADATA' in jcamp.info) {
|
|
782
|
+
const match = jcamp.info.$CSAUTOMETADATA.match(/TEMPERATURE=([\d.]+)/);
|
|
783
|
+
if (match !== null) {
|
|
784
|
+
const temperature = match[1];
|
|
785
|
+
return temperature;
|
|
786
|
+
}
|
|
787
|
+
}
|
|
788
|
+
return 'xxx';
|
|
789
|
+
};
|
|
790
|
+
const ExtractJcamp = source => {
|
|
791
|
+
const jcamp = _jcampconverter.default.convert(source, {
|
|
746
792
|
xy: true,
|
|
747
|
-
keepRecordsRegExp: /(\$CSTHRESHOLD|\$CSSCANAUTOTARGET|\$CSSCANEDITTARGET|\$CSSCANCOUNT|\$CSSOLVENTNAME|\$CSSOLVENTVALUE|\$CSSOLVENTX|\$CSCATEGORY|\$CSITAREA|\$CSITFACTOR|\$OBSERVEDINTEGRALS|\$OBSERVEDMULTIPLETS|\$OBSERVEDMULTIPLETSPEAKS|\.SOLVENTNAME|\.OBSERVEFREQUENCY|\$CSSIMULATIONPEAKS|\$CSUPPERTHRESHOLD|\$CSLOWERTHRESHOLD|\$CSCYCLICVOLTAMMETRYDATA)/ // eslint-disable-line
|
|
793
|
+
keepRecordsRegExp: /(\$CSTHRESHOLD|\$CSSCANAUTOTARGET|\$CSSCANEDITTARGET|\$CSSCANCOUNT|\$CSSOLVENTNAME|\$CSSOLVENTVALUE|\$CSSOLVENTX|\$CSCATEGORY|\$CSITAREA|\$CSITFACTOR|\$OBSERVEDINTEGRALS|\$OBSERVEDMULTIPLETS|\$OBSERVEDMULTIPLETSPEAKS|\.SOLVENTNAME|\.OBSERVEFREQUENCY|\$CSSIMULATIONPEAKS|\$CSUPPERTHRESHOLD|\$CSLOWERTHRESHOLD|\$CSCYCLICVOLTAMMETRYDATA|UNITS|SYMBOL|CSAUTOMETADATA)/ // eslint-disable-line
|
|
748
794
|
});
|
|
749
795
|
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
796
|
+
const layout = readLayout(jcamp);
|
|
797
|
+
const peakUp = !_format.default.isIrLayout(layout);
|
|
798
|
+
const spectra = _format.default.isMsLayout(layout) ? extrSpectraMs(jcamp, layout) : extrSpectraNi(jcamp, layout);
|
|
799
|
+
let features = {};
|
|
754
800
|
if (_format.default.isMsLayout(layout)) {
|
|
755
801
|
features = extrFeaturesMs(jcamp, layout, peakUp);
|
|
756
|
-
} else if (_format.default.isXRDLayout(layout)
|
|
802
|
+
} else if (_format.default.isXRDLayout(layout)) {
|
|
757
803
|
features = extrFeaturesXrd(jcamp, layout, peakUp);
|
|
758
|
-
|
|
804
|
+
const temperature = extractTemperature(jcamp);
|
|
805
|
+
return {
|
|
806
|
+
spectra,
|
|
807
|
+
features,
|
|
808
|
+
layout,
|
|
809
|
+
temperature
|
|
810
|
+
};
|
|
811
|
+
} else if (_format.default.isCyclicVoltaLayout(layout) || _format.default.isSECLayout(layout) || _format.default.isAIFLayout(layout) || _format.default.isCDSLayout(layout)) {
|
|
759
812
|
features = extrFeaturesCylicVolta(jcamp, layout, peakUp);
|
|
760
813
|
} else {
|
|
761
814
|
features = extrFeaturesNi(jcamp, layout, peakUp, spectra);
|
|
@@ -766,48 +819,52 @@ var ExtractJcamp = function ExtractJcamp(source) {
|
|
|
766
819
|
// ? extrFeaturesXrd(jcamp, layout, peakUp) : extrFeaturesNi(jcamp, layout, peakUp, spectra));
|
|
767
820
|
|
|
768
821
|
return {
|
|
769
|
-
spectra
|
|
770
|
-
features
|
|
771
|
-
layout
|
|
822
|
+
spectra,
|
|
823
|
+
features,
|
|
824
|
+
layout
|
|
772
825
|
};
|
|
773
826
|
};
|
|
774
827
|
exports.ExtractJcamp = ExtractJcamp;
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
828
|
+
const Convert2Scan = (feature, scanSt) => {
|
|
829
|
+
const {
|
|
830
|
+
scanAutoTarget,
|
|
831
|
+
scanEditTarget
|
|
832
|
+
} = feature;
|
|
833
|
+
const {
|
|
834
|
+
target,
|
|
835
|
+
isAuto
|
|
836
|
+
} = scanSt;
|
|
837
|
+
const hasEdit = !!scanEditTarget;
|
|
838
|
+
const defaultIdx = isAuto || !hasEdit ? scanAutoTarget : scanEditTarget;
|
|
782
839
|
return target || defaultIdx;
|
|
783
840
|
};
|
|
784
841
|
exports.Convert2Scan = Convert2Scan;
|
|
785
|
-
|
|
786
|
-
|
|
842
|
+
const Convert2Thres = (feature, thresSt) => {
|
|
843
|
+
const value = thresSt.value || feature.thresRef;
|
|
787
844
|
return value;
|
|
788
845
|
};
|
|
789
846
|
exports.Convert2Thres = Convert2Thres;
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
847
|
+
const Convert2DValue = function (doubleTheta) {
|
|
848
|
+
let lambda = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0.15406;
|
|
849
|
+
let isRadian = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
|
|
850
|
+
let theta = doubleTheta / 2;
|
|
794
851
|
if (isRadian) {
|
|
795
852
|
theta = theta / 180 * Math.PI;
|
|
796
853
|
}
|
|
797
|
-
|
|
798
|
-
|
|
854
|
+
const sinTheta = Math.sin(theta);
|
|
855
|
+
const dValue = lambda / (2 * sinTheta);
|
|
799
856
|
return dValue;
|
|
800
857
|
};
|
|
801
858
|
exports.Convert2DValue = Convert2DValue;
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
859
|
+
const GetCyclicVoltaRatio = (y_max_peak, y_min_peak, y_pecker) => {
|
|
860
|
+
const firstExpr = Math.abs(y_min_peak) / Math.abs(y_max_peak);
|
|
861
|
+
const secondExpr = 0.485 * Math.abs(y_pecker) / Math.abs(y_max_peak);
|
|
862
|
+
const ratio = firstExpr + secondExpr + 0.086;
|
|
806
863
|
return ratio;
|
|
807
864
|
};
|
|
808
865
|
exports.GetCyclicVoltaRatio = GetCyclicVoltaRatio;
|
|
809
|
-
|
|
810
|
-
|
|
866
|
+
const GetCyclicVoltaPeakSeparate = (x_max_peak, x_min_peak) => {
|
|
867
|
+
const delta = Math.abs(x_max_peak - x_min_peak);
|
|
811
868
|
return delta;
|
|
812
869
|
};
|
|
813
870
|
exports.GetCyclicVoltaPeakSeparate = GetCyclicVoltaPeakSeparate;
|