nmr-processing
Advanced tools
Comparing version 7.3.0 to 7.4.0
// sources: | ||
// https://en.wikipedia.org/wiki/Gyromagnetic_ratio | ||
// TODO: #13 can we have a better source and more digits ? @jwist | ||
export const gyromagneticRatio = { | ||
export const GYROMAGNETIC_RATIO = { | ||
'1H': 267.52218744e6, | ||
@@ -6,0 +5,0 @@ '2H': 41.065e6, |
@@ -22,2 +22,3 @@ export * from './constants/gyromagneticRatio'; | ||
export * from './utilities/rangeFromSignal'; | ||
export * from './utilities/getFrequency'; | ||
export * from './xy/xyAutoPeaksPicking'; | ||
@@ -24,0 +25,0 @@ export * from './xy/xyAutoRangesPicking'; |
import { generateSpectrum2D } from 'spectrum-generator'; | ||
export function signals2DToZ(signals, options = {}) { | ||
let { from = -1, to = 12, nbPoints = 512, width = 0.02 } = options; | ||
let { from = -1, to = 12, nbPoints = 512, width = 0.02, factor = 3, } = options; | ||
const peaks = signals.reduce((acc, { x, y }) => { | ||
@@ -11,3 +11,3 @@ acc.x.push(x.delta); | ||
width = ensureXYNumber(width); | ||
return generateSpectrum2D(peaks, { | ||
return generateSpectrum2D(mergeClosePeaks(peaks), { | ||
generator: { | ||
@@ -20,2 +20,3 @@ from: ensureXYNumber(from), | ||
width, | ||
factor, | ||
}, | ||
@@ -25,5 +26,19 @@ }); | ||
function ensureXYNumber(input) { | ||
let result = typeof input !== 'object' ? { x: input, y: input } : input; | ||
return result; | ||
return typeof input !== 'object' ? { x: input, y: input } : { ...input }; | ||
} | ||
function mergeClosePeaks(peaksIn) { | ||
let peaks = JSON.parse(JSON.stringify(peaksIn)); | ||
for (let i = 0; i < peaks.x.length; i++) { | ||
for (let j = i + 1; j < peaks.x.length; j++) { | ||
if (peaks.x[i] === peaks.x[j] && peaks.y[i] === peaks.y[j]) { | ||
peaks.z[i] += peaks.z[j]; | ||
peaks.x.splice(j, 1); | ||
peaks.y.splice(j, 1); | ||
peaks.z.splice(j, 1); | ||
j--; | ||
} | ||
} | ||
} | ||
return peaks; | ||
} | ||
//# sourceMappingURL=signals2DToZ.js.map |
@@ -1,20 +0,6 @@ | ||
export declare const gyromagneticRatio: { | ||
'1H': number; | ||
'2H': number; | ||
'3H': number; | ||
'3He': number; | ||
'7Li': number; | ||
'13C': number; | ||
'14N': number; | ||
'15N': number; | ||
'17O': number; | ||
'19F': number; | ||
'23Na': number; | ||
'27Al': number; | ||
'29Si': number; | ||
'31P': number; | ||
'57Fe': number; | ||
'63Cu': number; | ||
'67Zn': number; | ||
'129Xe': number; | ||
export declare type Nuclei = '1H' | '2H' | '3H' | '3He' | '7Li' | '13C' | '14N' | '15N' | '17O' | '19F' | '23Na' | '27Al' | '29Si' | '31P' | '57Fe' | '63Cu' | '67Zn' | '129Xe'; | ||
declare type GyromagneticRatio = { | ||
[key in Nuclei]: number; | ||
}; | ||
export declare const GYROMAGNETIC_RATIO: GyromagneticRatio; | ||
export {}; |
@@ -5,5 +5,4 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.gyromagneticRatio = void 0; | ||
// TODO: #13 can we have a better source and more digits ? @jwist | ||
exports.gyromagneticRatio = { | ||
exports.GYROMAGNETIC_RATIO = void 0; | ||
exports.GYROMAGNETIC_RATIO = { | ||
'1H': 267.52218744e6, | ||
@@ -10,0 +9,0 @@ '2H': 41.065e6, |
@@ -22,2 +22,3 @@ export * from './constants/gyromagneticRatio'; | ||
export * from './utilities/rangeFromSignal'; | ||
export * from './utilities/getFrequency'; | ||
export * from './xy/xyAutoPeaksPicking'; | ||
@@ -24,0 +25,0 @@ export * from './xy/xyAutoRangesPicking'; |
@@ -38,2 +38,3 @@ "use strict"; | ||
__exportStar(require("./utilities/rangeFromSignal"), exports); | ||
__exportStar(require("./utilities/getFrequency"), exports); | ||
__exportStar(require("./xy/xyAutoPeaksPicking"), exports); | ||
@@ -40,0 +41,0 @@ __exportStar(require("./xy/xyAutoRangesPicking"), exports); |
@@ -26,2 +26,3 @@ import type { XYNumber } from 'spectrum-generator'; | ||
width?: number | XYNumber; | ||
factor?: number | XYNumber; | ||
} | ||
@@ -28,0 +29,0 @@ export interface Peak2DSeries { |
@@ -6,3 +6,3 @@ "use strict"; | ||
function signals2DToZ(signals, options = {}) { | ||
let { from = -1, to = 12, nbPoints = 512, width = 0.02 } = options; | ||
let { from = -1, to = 12, nbPoints = 512, width = 0.02, factor = 3, } = options; | ||
const peaks = signals.reduce((acc, { x, y }) => { | ||
@@ -15,3 +15,3 @@ acc.x.push(x.delta); | ||
width = ensureXYNumber(width); | ||
return (0, spectrum_generator_1.generateSpectrum2D)(peaks, { | ||
return (0, spectrum_generator_1.generateSpectrum2D)(mergeClosePeaks(peaks), { | ||
generator: { | ||
@@ -24,2 +24,3 @@ from: ensureXYNumber(from), | ||
width, | ||
factor, | ||
}, | ||
@@ -30,5 +31,19 @@ }); | ||
function ensureXYNumber(input) { | ||
let result = typeof input !== 'object' ? { x: input, y: input } : input; | ||
return result; | ||
return typeof input !== 'object' ? { x: input, y: input } : { ...input }; | ||
} | ||
function mergeClosePeaks(peaksIn) { | ||
let peaks = JSON.parse(JSON.stringify(peaksIn)); | ||
for (let i = 0; i < peaks.x.length; i++) { | ||
for (let j = i + 1; j < peaks.x.length; j++) { | ||
if (peaks.x[i] === peaks.x[j] && peaks.y[i] === peaks.y[j]) { | ||
peaks.z[i] += peaks.z[j]; | ||
peaks.x.splice(j, 1); | ||
peaks.y.splice(j, 1); | ||
peaks.z.splice(j, 1); | ||
j--; | ||
} | ||
} | ||
} | ||
return peaks; | ||
} | ||
//# sourceMappingURL=signals2DToZ.js.map |
{ | ||
"name": "nmr-processing", | ||
"version": "7.3.0", | ||
"version": "7.4.0", | ||
"description": "Pure functions allowing to process NMR spectra.", | ||
@@ -5,0 +5,0 @@ "main": "./lib/index.js", |
@@ -6,3 +6,27 @@ // sources: | ||
export const gyromagneticRatio = { | ||
export type Nuclei = | ||
| '1H' | ||
| '2H' | ||
| '3H' | ||
| '3He' | ||
| '7Li' | ||
| '13C' | ||
| '14N' | ||
| '15N' | ||
| '17O' | ||
| '19F' | ||
| '23Na' | ||
| '27Al' | ||
| '29Si' | ||
| '31P' | ||
| '57Fe' | ||
| '63Cu' | ||
| '67Zn' | ||
| '129Xe'; | ||
type GyromagneticRatio = { | ||
[key in Nuclei]: number; | ||
}; | ||
export const GYROMAGNETIC_RATIO: GyromagneticRatio = { | ||
'1H': 267.52218744e6, | ||
@@ -9,0 +33,0 @@ '2H': 41.065e6, |
@@ -28,2 +28,3 @@ export * from './constants/gyromagneticRatio'; | ||
export * from './utilities/rangeFromSignal'; | ||
export * from './utilities/getFrequency'; | ||
@@ -30,0 +31,0 @@ export * from './xy/xyAutoPeaksPicking'; |
@@ -29,2 +29,3 @@ import { generateSpectrum2D } from 'spectrum-generator'; | ||
width?: number | XYNumber; | ||
factor?: number | XYNumber; | ||
} | ||
@@ -42,3 +43,9 @@ | ||
) { | ||
let { from = -1, to = 12, nbPoints = 512, width = 0.02 } = options; | ||
let { | ||
from = -1, | ||
to = 12, | ||
nbPoints = 512, | ||
width = 0.02, | ||
factor = 3, | ||
} = options; | ||
@@ -56,3 +63,4 @@ const peaks = signals.reduce<Peak2DSeries>( | ||
width = ensureXYNumber(width); | ||
return generateSpectrum2D(peaks, { | ||
return generateSpectrum2D(mergeClosePeaks(peaks), { | ||
generator: { | ||
@@ -65,2 +73,3 @@ from: ensureXYNumber(from), | ||
width, | ||
factor, | ||
}, | ||
@@ -70,5 +79,20 @@ }); | ||
function ensureXYNumber(input: number | XYNumber): XYNumber { | ||
let result = typeof input !== 'object' ? { x: input, y: input } : input; | ||
return result; | ||
function ensureXYNumber(input: number | XYNumber) { | ||
return typeof input !== 'object' ? { x: input, y: input } : { ...input }; | ||
} | ||
function mergeClosePeaks(peaksIn: Peak2DSeries) { | ||
let peaks = JSON.parse(JSON.stringify(peaksIn)); | ||
for (let i = 0; i < peaks.x.length; i++) { | ||
for (let j = i + 1; j < peaks.x.length; j++) { | ||
if (peaks.x[i] === peaks.x[j] && peaks.y[i] === peaks.y[j]) { | ||
peaks.z[i] += peaks.z[j]; | ||
peaks.x.splice(j, 1); | ||
peaks.y.splice(j, 1); | ||
peaks.z.splice(j, 1); | ||
j--; | ||
} | ||
} | ||
} | ||
return peaks; | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
4198579
532
115684