jcampconverter 9.2.0 → 9.2.2

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.
Files changed (156) hide show
  1. package/jcampconverter.cjs +8 -0
  2. package/{lib/convert.d.ts → jcampconverter.d.ts} +222 -182
  3. package/jcampconverter.mjs +8 -0
  4. package/package.json +27 -19
  5. package/lib/2d/add2D.d.ts +0 -2
  6. package/lib/2d/add2D.d.ts.map +0 -1
  7. package/lib/2d/add2D.js +0 -17
  8. package/lib/2d/add2D.js.map +0 -1
  9. package/lib/2d/convertTo3DZ.d.ts +0 -11
  10. package/lib/2d/convertTo3DZ.d.ts.map +0 -1
  11. package/lib/2d/convertTo3DZ.js +0 -59
  12. package/lib/2d/convertTo3DZ.js.map +0 -1
  13. package/lib/2d/generateContourLines.d.ts +0 -8
  14. package/lib/2d/generateContourLines.d.ts.map +0 -1
  15. package/lib/2d/generateContourLines.js +0 -163
  16. package/lib/2d/generateContourLines.js.map +0 -1
  17. package/lib/complexChromatogram.d.ts +0 -4
  18. package/lib/complexChromatogram.d.ts.map +0 -1
  19. package/lib/complexChromatogram.js +0 -49
  20. package/lib/complexChromatogram.js.map +0 -1
  21. package/lib/convert.d.ts.map +0 -1
  22. package/lib/convert.js +0 -412
  23. package/lib/convert.js.map +0 -1
  24. package/lib/convertToFloatArray.d.ts +0 -2
  25. package/lib/convertToFloatArray.d.ts.map +0 -1
  26. package/lib/convertToFloatArray.js +0 -11
  27. package/lib/convertToFloatArray.js.map +0 -1
  28. package/lib/createTree.d.ts +0 -29
  29. package/lib/createTree.d.ts.map +0 -1
  30. package/lib/createTree.js +0 -101
  31. package/lib/createTree.js.map +0 -1
  32. package/lib/index.d.ts +0 -3
  33. package/lib/index.d.ts.map +0 -1
  34. package/lib/index.js +0 -8
  35. package/lib/index.js.map +0 -1
  36. package/lib/parse/fastParseXYData.d.ts +0 -2
  37. package/lib/parse/fastParseXYData.d.ts.map +0 -1
  38. package/lib/parse/fastParseXYData.js +0 -193
  39. package/lib/parse/fastParseXYData.js.map +0 -1
  40. package/lib/parse/parsePeakTable.d.ts +0 -2
  41. package/lib/parse/parsePeakTable.d.ts.map +0 -1
  42. package/lib/parse/parsePeakTable.js +0 -67
  43. package/lib/parse/parsePeakTable.js.map +0 -1
  44. package/lib/parse/parseXYA.d.ts +0 -2
  45. package/lib/parse/parseXYA.d.ts.map +0 -1
  46. package/lib/parse/parseXYA.js +0 -51
  47. package/lib/parse/parseXYA.js.map +0 -1
  48. package/lib/postProcessing.d.ts +0 -2
  49. package/lib/postProcessing.d.ts.map +0 -1
  50. package/lib/postProcessing.js +0 -93
  51. package/lib/postProcessing.js.map +0 -1
  52. package/lib/postProcessingNMR.d.ts +0 -2
  53. package/lib/postProcessingNMR.d.ts.map +0 -1
  54. package/lib/postProcessingNMR.js +0 -95
  55. package/lib/postProcessingNMR.js.map +0 -1
  56. package/lib/prepareNtuplesDatatable.d.ts +0 -2
  57. package/lib/prepareNtuplesDatatable.d.ts.map +0 -1
  58. package/lib/prepareNtuplesDatatable.js +0 -87
  59. package/lib/prepareNtuplesDatatable.js.map +0 -1
  60. package/lib/prepareSpectrum.d.ts +0 -2
  61. package/lib/prepareSpectrum.d.ts.map +0 -1
  62. package/lib/prepareSpectrum.js +0 -10
  63. package/lib/prepareSpectrum.js.map +0 -1
  64. package/lib/profiling.d.ts +0 -2
  65. package/lib/profiling.d.ts.map +0 -1
  66. package/lib/profiling.js +0 -13
  67. package/lib/profiling.js.map +0 -1
  68. package/lib/simpleChromatogram.d.ts +0 -2
  69. package/lib/simpleChromatogram.d.ts.map +0 -1
  70. package/lib/simpleChromatogram.js +0 -16
  71. package/lib/simpleChromatogram.js.map +0 -1
  72. package/lib-esm/2d/add2D.d.ts +0 -2
  73. package/lib-esm/2d/add2D.d.ts.map +0 -1
  74. package/lib-esm/2d/add2D.js +0 -11
  75. package/lib-esm/2d/add2D.js.map +0 -1
  76. package/lib-esm/2d/convertTo3DZ.d.ts +0 -11
  77. package/lib-esm/2d/convertTo3DZ.d.ts.map +0 -1
  78. package/lib-esm/2d/convertTo3DZ.js +0 -53
  79. package/lib-esm/2d/convertTo3DZ.js.map +0 -1
  80. package/lib-esm/2d/generateContourLines.d.ts +0 -8
  81. package/lib-esm/2d/generateContourLines.d.ts.map +0 -1
  82. package/lib-esm/2d/generateContourLines.js +0 -160
  83. package/lib-esm/2d/generateContourLines.js.map +0 -1
  84. package/lib-esm/complexChromatogram.d.ts +0 -4
  85. package/lib-esm/complexChromatogram.d.ts.map +0 -1
  86. package/lib-esm/complexChromatogram.js +0 -43
  87. package/lib-esm/complexChromatogram.js.map +0 -1
  88. package/lib-esm/convert.d.ts +0 -182
  89. package/lib-esm/convert.d.ts.map +0 -1
  90. package/lib-esm/convert.js +0 -405
  91. package/lib-esm/convert.js.map +0 -1
  92. package/lib-esm/convertToFloatArray.d.ts +0 -2
  93. package/lib-esm/convertToFloatArray.d.ts.map +0 -1
  94. package/lib-esm/convertToFloatArray.js +0 -8
  95. package/lib-esm/convertToFloatArray.js.map +0 -1
  96. package/lib-esm/createTree.d.ts +0 -29
  97. package/lib-esm/createTree.d.ts.map +0 -1
  98. package/lib-esm/createTree.js +0 -97
  99. package/lib-esm/createTree.js.map +0 -1
  100. package/lib-esm/index.d.ts +0 -3
  101. package/lib-esm/index.d.ts.map +0 -1
  102. package/lib-esm/index.js +0 -3
  103. package/lib-esm/index.js.map +0 -1
  104. package/lib-esm/parse/fastParseXYData.d.ts +0 -2
  105. package/lib-esm/parse/fastParseXYData.d.ts.map +0 -1
  106. package/lib-esm/parse/fastParseXYData.js +0 -190
  107. package/lib-esm/parse/fastParseXYData.js.map +0 -1
  108. package/lib-esm/parse/parsePeakTable.d.ts +0 -2
  109. package/lib-esm/parse/parsePeakTable.d.ts.map +0 -1
  110. package/lib-esm/parse/parsePeakTable.js +0 -64
  111. package/lib-esm/parse/parsePeakTable.js.map +0 -1
  112. package/lib-esm/parse/parseXYA.d.ts +0 -2
  113. package/lib-esm/parse/parseXYA.d.ts.map +0 -1
  114. package/lib-esm/parse/parseXYA.js +0 -48
  115. package/lib-esm/parse/parseXYA.js.map +0 -1
  116. package/lib-esm/postProcessing.d.ts +0 -2
  117. package/lib-esm/postProcessing.d.ts.map +0 -1
  118. package/lib-esm/postProcessing.js +0 -87
  119. package/lib-esm/postProcessing.js.map +0 -1
  120. package/lib-esm/postProcessingNMR.d.ts +0 -2
  121. package/lib-esm/postProcessingNMR.d.ts.map +0 -1
  122. package/lib-esm/postProcessingNMR.js +0 -92
  123. package/lib-esm/postProcessingNMR.js.map +0 -1
  124. package/lib-esm/prepareNtuplesDatatable.d.ts +0 -2
  125. package/lib-esm/prepareNtuplesDatatable.d.ts.map +0 -1
  126. package/lib-esm/prepareNtuplesDatatable.js +0 -84
  127. package/lib-esm/prepareNtuplesDatatable.js.map +0 -1
  128. package/lib-esm/prepareSpectrum.d.ts +0 -2
  129. package/lib-esm/prepareSpectrum.d.ts.map +0 -1
  130. package/lib-esm/prepareSpectrum.js +0 -7
  131. package/lib-esm/prepareSpectrum.js.map +0 -1
  132. package/lib-esm/profiling.d.ts +0 -2
  133. package/lib-esm/profiling.d.ts.map +0 -1
  134. package/lib-esm/profiling.js +0 -10
  135. package/lib-esm/profiling.js.map +0 -1
  136. package/lib-esm/simpleChromatogram.d.ts +0 -2
  137. package/lib-esm/simpleChromatogram.d.ts.map +0 -1
  138. package/lib-esm/simpleChromatogram.js +0 -13
  139. package/lib-esm/simpleChromatogram.js.map +0 -1
  140. package/src/2d/add2D.js +0 -11
  141. package/src/2d/convertTo3DZ.js +0 -55
  142. package/src/2d/generateContourLines.js +0 -166
  143. package/src/complexChromatogram.js +0 -49
  144. package/src/convert.js +0 -412
  145. package/src/convertToFloatArray.js +0 -7
  146. package/src/createTree.js +0 -100
  147. package/src/index.js +0 -2
  148. package/src/parse/fastParseXYData.js +0 -175
  149. package/src/parse/parsePeakTable.js +0 -69
  150. package/src/parse/parseXYA.js +0 -50
  151. package/src/postProcessing.js +0 -93
  152. package/src/postProcessingNMR.js +0 -99
  153. package/src/prepareNtuplesDatatable.js +0 -85
  154. package/src/prepareSpectrum.js +0 -4
  155. package/src/profiling.js +0 -9
  156. package/src/simpleChromatogram.js +0 -12
@@ -1,69 +0,0 @@
1
- const removeCommentRegExp = /\$\$.*/;
2
- const peakTableSplitRegExp = /[,\t ]+/;
3
-
4
- export default function parsePeakTable(spectrum, value, result) {
5
- spectrum.isPeaktable = true;
6
-
7
- if (!spectrum.variables || Object.keys(spectrum.variables) === 2) {
8
- parseXY(spectrum, value, result);
9
- } else {
10
- parseXYZ(spectrum, value, result);
11
- }
12
-
13
- // we will add the data in the variables
14
- if (spectrum.variables) {
15
- for (let key in spectrum.variables) {
16
- spectrum.variables[key].data = spectrum.data[key];
17
- }
18
- }
19
- }
20
-
21
- function parseXY(spectrum, value, result) {
22
- let currentData = { x: [], y: [] };
23
- spectrum.data = currentData;
24
-
25
- // counts for around 20% of the time
26
- let lines = value.split(/,? *,?[;\r\n]+ */);
27
-
28
- for (let i = 1; i < lines.length; i++) {
29
- let values = lines[i]
30
- .trim()
31
- .replace(removeCommentRegExp, '')
32
- .split(peakTableSplitRegExp);
33
- if (values.length % 2 === 0) {
34
- for (let j = 0; j < values.length; j = j + 2) {
35
- // takes around 40% of the time to add and parse the 2 values nearly exclusively because of Number
36
- currentData.x.push(Number(values[j]) * spectrum.xFactor);
37
- currentData.y.push(Number(values[j + 1]) * spectrum.yFactor);
38
- }
39
- } else {
40
- result.logs.push(`Format error: ${values}`);
41
- }
42
- }
43
- }
44
-
45
- function parseXYZ(spectrum, value, result) {
46
- let currentData = {};
47
- let variables = Object.keys(spectrum.variables);
48
- let numberOfVariables = variables.length;
49
- variables.forEach((variable) => (currentData[variable] = []));
50
- spectrum.data = currentData;
51
-
52
- // counts for around 20% of the time
53
- let lines = value.split(/,? *,?[;\r\n]+ */);
54
-
55
- for (let i = 1; i < lines.length; i++) {
56
- let values = lines[i]
57
- .trim()
58
- .replace(removeCommentRegExp, '')
59
- .split(peakTableSplitRegExp);
60
- if (values.length % numberOfVariables === 0) {
61
- for (let j = 0; j < values.length; j++) {
62
- // todo should try to find a xFactor (y, ...)
63
- currentData[variables[j % numberOfVariables]].push(Number(values[j]));
64
- }
65
- } else {
66
- result.logs.push(`Format error: ${values}`);
67
- }
68
- }
69
- }
@@ -1,50 +0,0 @@
1
- /*
2
- (5.4.4) ##РЕАК ASSIGNMENTS= (STRING). List
3
- of peak assignments for components or functional groups
4
- in the forms ##РЕАК ASSIGNMENTS= (ХУА),
5
- (XYW А), (ХУМА), (XYMW А). Each entry is surrounded Ьу parentheses and starts а new line. У, W (peak
6
- width), and М (multiplicity) values are optional. The
7
- symbol А stands for а string detailing the assignment
8
- and must Ье enclosed Ьу angle brackets. If the peak width
9
- value is included, then the function used to calculate the
10
- peak width must Ье detailed in а $$ comment on the
11
- line(s) below ##PEAKASSIGNMENTS=. Priority OPTIONAL. N.B.: ##РЕАК ASSIGNMENTS= is the preferred method of transmitting peak information when
12
- the assignments are known.
13
- */
14
-
15
- export default function parseXYA(spectrum, value) {
16
- spectrum.isXYAdata = true;
17
- const currentData = {};
18
- spectrum.data = currentData;
19
-
20
- let lines = value.split(/\r?\n/);
21
- const variables = lines[0]
22
- .replace(/^.*?([A-Z]+).*$/, '$1')
23
- .split('')
24
- .map((variable) => variable.toLowerCase());
25
-
26
- for (let i = 1; i < lines.length; i++) {
27
- const fields = lines[i].replace(/^\((.*)\)$/, '$1').split(/ *, */);
28
- for (let j = 0; j < variables.length; j++) {
29
- let value = fields[j];
30
- switch (variables[j]) {
31
- case 'x':
32
- case 'y':
33
- case 'w':
34
- value = Number.parseFloat(value);
35
- break;
36
- case 'a':
37
- value = value.replace(/^<(.*)>$/, '$1');
38
- break;
39
- case 'm':
40
- break;
41
- default:
42
- continue;
43
- }
44
- if (!currentData[variables[j]]) {
45
- currentData[variables[j]] = [];
46
- }
47
- currentData[variables[j]].push(value);
48
- }
49
- }
50
- }
@@ -1,93 +0,0 @@
1
- import { parseString } from 'dynamic-typing';
2
-
3
- import add2D from './2d/add2D';
4
- import { complexChromatogram } from './complexChromatogram';
5
- import postProcessingNMR from './postProcessingNMR';
6
- import profiling from './profiling';
7
- import simpleChromatogram from './simpleChromatogram';
8
-
9
- export default function postProcessing(entriesFlat, result, options) {
10
- // converting Hz to ppm
11
- postProcessingNMR(entriesFlat);
12
-
13
- createArray(entriesFlat, options);
14
-
15
- for (let entry of entriesFlat) {
16
- if (Object.keys(entry.ntuples).length > 0) {
17
- let newNtuples = [];
18
- let keys = Object.keys(entry.ntuples);
19
- for (let i = 0; i < keys.length; i++) {
20
- let key = keys[i];
21
- let values = entry.ntuples[key];
22
- for (let j = 0; j < values.length; j++) {
23
- if (!newNtuples[j]) newNtuples[j] = {};
24
- newNtuples[j][key] = values[j];
25
- }
26
- }
27
- entry.ntuples = newNtuples;
28
- }
29
-
30
- if (entry.twoD && options.wantXY) {
31
- add2D(entry, options);
32
-
33
- profiling(result, 'Finished countour plot calculation', options);
34
-
35
- if (!options.keepSpectra) {
36
- delete entry.spectra;
37
- }
38
- }
39
-
40
- // maybe it is a GC (HPLC) / MS. In this case we add a new format
41
- if (options.chromatogram) {
42
- if (entry.spectra.length > 1) {
43
- complexChromatogram(entry);
44
- } else {
45
- simpleChromatogram(entry);
46
- }
47
- profiling(result, 'Finished chromatogram calculation', options);
48
- }
49
-
50
- delete entry.tmp;
51
- }
52
- }
53
-
54
- function createArray(entriesFlat, options) {
55
- for (const entry of entriesFlat) {
56
- for (const key in entry.meta) {
57
- const value = entry.meta[key];
58
- if (typeof value === 'string') {
59
- if (value[0] === '{') {
60
- // could be an array
61
- if (value[value.length - 1] === '}') {
62
- const array = value
63
- .slice(1, -1)
64
- .split(/[,; ]+/)
65
- .filter((e) => e);
66
- for (let i = 0; i < array.length; i++) {
67
- entry.meta[key + String(i)] = options.dynamicTyping
68
- ? parseString(array[i])
69
- : array[i];
70
- }
71
- }
72
- } else if (value[0] === '(') {
73
- const lines = value.split(/\r?\n/);
74
- const regexp = /^\((?<from>\d+)\.\.(?<to>\d+)\)$/;
75
- if (regexp.test(lines[0])) {
76
- // parsing '(0..63)'
77
- const [from, to] = lines[0].match(regexp).slice(1).map(Number);
78
- const array = lines
79
- .slice(1)
80
- .join(' ')
81
- .split(/[,; ]+/)
82
- .filter((e) => e);
83
- for (let i = from; i <= to; i++) {
84
- entry.meta[key + String(i)] = options.dynamicTyping
85
- ? parseString(array[i - from])
86
- : array[i - from];
87
- }
88
- }
89
- }
90
- }
91
- }
92
- }
93
- }
@@ -1,99 +0,0 @@
1
- import { gyromagneticRatio } from 'gyromagnetic-ratio';
2
-
3
- export default function postProcessingNMR(entriesFlat) {
4
- // specific NMR functions
5
-
6
- for (let entry of entriesFlat) {
7
- let observeFrequency = 0;
8
- let shiftOffsetVal = 0;
9
- for (let spectrum of entry.spectra) {
10
- if (entry.ntuples && entry.ntuples.symbol) {
11
- if (!observeFrequency && spectrum.observeFrequency) {
12
- observeFrequency = spectrum.observeFrequency;
13
- }
14
- if (!shiftOffsetVal && spectrum.shiftOffsetVal) {
15
- shiftOffsetVal = spectrum.shiftOffsetVal;
16
- }
17
- } else {
18
- observeFrequency = spectrum.observeFrequency;
19
- shiftOffsetVal = spectrum.shiftOffsetVal;
20
- }
21
-
22
- if (observeFrequency) {
23
- if (spectrum.xUnits && spectrum.xUnits.toUpperCase().includes('HZ')) {
24
- spectrum.xUnits = 'PPM';
25
- spectrum.xFactor = spectrum.xFactor / observeFrequency;
26
- spectrum.firstX = spectrum.firstX / observeFrequency;
27
- spectrum.lastX = spectrum.lastX / observeFrequency;
28
- spectrum.deltaX = spectrum.deltaX / observeFrequency;
29
- for (let i = 0; i < spectrum.data.x.length; i++) {
30
- spectrum.data.x[i] /= observeFrequency;
31
- }
32
- }
33
- }
34
- if (shiftOffsetVal && spectrum.xUnits.toLowerCase().includes('ppm')) {
35
- let shift = spectrum.firstX - shiftOffsetVal;
36
- spectrum.firstX = spectrum.firstX - shift;
37
- spectrum.lastX = spectrum.lastX - shift;
38
- for (let i = 0; i < spectrum.data.x.length; i++) {
39
- spectrum.data.x[i] -= shift;
40
- }
41
- }
42
-
43
- // we will check if some nucleus are missing ...
44
- if (entry.ntuples && entry.ntuples.nucleus && entry.ntuples.symbol) {
45
- for (let i = 0; i < entry.ntuples.nucleus.length; i++) {
46
- let symbol = entry.ntuples.symbol[i];
47
- let nucleus = entry.ntuples.nucleus[i];
48
- if (symbol.match(/^[F|T]/) && !nucleus) {
49
- if (symbol.match(/[F|T]1/)) {
50
- // if F1 is defined we will use F2
51
- if (entry.tmp.$NUC2) {
52
- entry.ntuples.nucleus[i] = entry.tmp.$NUC2;
53
- } else {
54
- let f2index = entry.ntuples.symbol.indexOf(
55
- symbol.replace(/^([F|T]).*/, '$12'),
56
- );
57
- if (f2index && entry.ntuples.nucleus[f2index]) {
58
- entry.ntuples.nucleus[i] = entry.ntuples.nucleus[f2index];
59
- }
60
- }
61
- }
62
- if (symbol.match(/[F|T]2/)) {
63
- entry.ntuples.nucleus[i] = entry.tmp.$NUC1;
64
- }
65
- }
66
- if (symbol.match(/[F|T]2/)) {
67
- entry.yType = entry.ntuples.nucleus[0];
68
- }
69
- }
70
- }
71
-
72
- if (
73
- observeFrequency &&
74
- entry.ntuples &&
75
- entry.ntuples.symbol &&
76
- entry.ntuples.nucleus
77
- ) {
78
- let unit = '';
79
- let pageSymbolIndex = entry.ntuples.symbol.indexOf(spectrum.pageSymbol);
80
- if (entry.ntuples.units && entry.ntuples.units[pageSymbolIndex]) {
81
- unit = entry.ntuples.units[pageSymbolIndex];
82
- }
83
- if (unit !== 'PPM') {
84
- if (pageSymbolIndex !== 0) {
85
- throw Error('Not sure about this ntuples format');
86
- }
87
-
88
- let ratio0 = gyromagneticRatio[entry.ntuples.nucleus[0]];
89
- let ratio1 = gyromagneticRatio[entry.ntuples.nucleus[1]];
90
- if (!ratio0 || !ratio1) {
91
- throw Error('Problem with determination of gyromagnetic ratio');
92
- }
93
- let ratio = (ratio0 / ratio1) * observeFrequency;
94
- spectrum.pageValue /= ratio;
95
- }
96
- }
97
- }
98
- }
99
- }
@@ -1,85 +0,0 @@
1
- export default function prepareNtuplesDatatable(currentEntry, spectrum, kind) {
2
- let xIndex = -1;
3
- let yIndex = -1;
4
- let firstVariable = '';
5
- let secondVariable = '';
6
- if (kind.indexOf('++') > 0) {
7
- firstVariable = kind.replace(/.*\(([a-zA-Z0-9]+)\+\+.*/, '$1');
8
- secondVariable = kind.replace(/.*\.\.([a-zA-Z0-9]+).*/, '$1');
9
- } else {
10
- kind = kind.replace(/[^a-zA-Z]/g, '');
11
- firstVariable = kind.charAt(0);
12
- secondVariable = kind.charAt(1);
13
- spectrum.variables = {};
14
- for (let symbol of kind) {
15
- let lowerCaseSymbol = symbol.toLowerCase();
16
- let index = currentEntry.ntuples.symbol.indexOf(symbol);
17
- if (index === -1) throw Error(`Symbol undefined: ${symbol}`);
18
- spectrum.variables[lowerCaseSymbol] = {};
19
- for (let key in currentEntry.ntuples) {
20
- if (currentEntry.ntuples[key][index]) {
21
- spectrum.variables[lowerCaseSymbol][key.replace(/^var/, '')] =
22
- currentEntry.ntuples[key][index];
23
- }
24
- }
25
- }
26
- }
27
- xIndex = currentEntry.ntuples.symbol.indexOf(firstVariable);
28
- yIndex = currentEntry.ntuples.symbol.indexOf(secondVariable);
29
-
30
- if (xIndex === -1) xIndex = 0;
31
- if (yIndex === -1) yIndex = 0;
32
-
33
- if (currentEntry.ntuples.first) {
34
- if (currentEntry.ntuples.first.length > xIndex) {
35
- spectrum.firstX = currentEntry.ntuples.first[xIndex];
36
- }
37
- if (currentEntry.ntuples.first.length > yIndex) {
38
- spectrum.firstY = currentEntry.ntuples.first[yIndex];
39
- }
40
- }
41
- if (currentEntry.ntuples.last) {
42
- if (currentEntry.ntuples.last.length > xIndex) {
43
- spectrum.lastX = currentEntry.ntuples.last[xIndex];
44
- }
45
- if (currentEntry.ntuples.last.length > yIndex) {
46
- spectrum.lastY = currentEntry.ntuples.last[yIndex];
47
- }
48
- }
49
- if (
50
- currentEntry.ntuples.vardim &&
51
- currentEntry.ntuples.vardim.length > xIndex
52
- ) {
53
- spectrum.nbPoints = currentEntry.ntuples.vardim[xIndex];
54
- }
55
- if (currentEntry.ntuples.factor) {
56
- if (currentEntry.ntuples.factor.length > xIndex) {
57
- spectrum.xFactor = currentEntry.ntuples.factor[xIndex];
58
- }
59
- if (currentEntry.ntuples.factor.length > yIndex) {
60
- spectrum.yFactor = currentEntry.ntuples.factor[yIndex];
61
- }
62
- }
63
- if (currentEntry.ntuples.units) {
64
- if (currentEntry.ntuples.units.length > xIndex) {
65
- if (
66
- currentEntry.ntuples.varname &&
67
- currentEntry.ntuples.varname[xIndex]
68
- ) {
69
- spectrum.xUnits = `${currentEntry.ntuples.varname[xIndex]} [${currentEntry.ntuples.units[xIndex]}]`;
70
- } else {
71
- spectrum.xUnits = currentEntry.ntuples.units[xIndex];
72
- }
73
- }
74
- if (currentEntry.ntuples.units.length > yIndex) {
75
- if (
76
- currentEntry.ntuples.varname &&
77
- currentEntry.ntuples.varname[yIndex]
78
- ) {
79
- spectrum.yUnits = `${currentEntry.ntuples.varname[yIndex]} [${currentEntry.ntuples.units[yIndex]}]`;
80
- } else {
81
- spectrum.yUnits = currentEntry.ntuples.units[yIndex];
82
- }
83
- }
84
- }
85
- }
@@ -1,4 +0,0 @@
1
- export default function prepareSpectrum(spectrum) {
2
- if (!spectrum.xFactor) spectrum.xFactor = 1;
3
- if (!spectrum.yFactor) spectrum.yFactor = 1;
4
- }
package/src/profiling.js DELETED
@@ -1,9 +0,0 @@
1
- export default function profiling(result, action, options = {}) {
2
- options.logger?.trace(action);
3
- if (result.profiling) {
4
- result.profiling.push({
5
- action,
6
- time: Date.now() - options.start,
7
- });
8
- }
9
- }
@@ -1,12 +0,0 @@
1
- export default function simpleChromatogram(result) {
2
- let data = result.spectra[0].data;
3
- result.chromatogram = {
4
- times: data.x.slice(),
5
- series: {
6
- intensity: {
7
- dimension: 1,
8
- data: data.y.slice(),
9
- },
10
- },
11
- };
12
- }