multiplet-analysis
Advanced tools
Comparing version 0.2.0 to 0.3.0
@@ -0,1 +1,5 @@ | ||
# [0.3.0](https://github.com/cheminfo/multiplet-analysis/compare/v0.2.0...v0.3.0) (2020-09-11) | ||
# [0.2.0](https://github.com/cheminfo/multiplet-analysis/compare/v0.1.0...v0.2.0) (2020-07-27) | ||
@@ -2,0 +6,0 @@ |
@@ -5,7 +5,9 @@ 'use strict'; | ||
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; } | ||
var maxY = _interopDefault(require('ml-array-xy-max-y')); | ||
var maxY = require('ml-array-xy-max-y'); | ||
var fftJs = require('fft-js'); | ||
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } | ||
var maxY__default = /*#__PURE__*/_interopDefaultLegacy(maxY); | ||
function appendDebug( | ||
@@ -255,3 +257,43 @@ xin, | ||
function measureSymShift(y) { | ||
function measureSymShift(y, options) { | ||
let minimalIntegralKeptInMultiplet = 90.0; | ||
if (options !== undefined) { | ||
minimalIntegralKeptInMultiplet = options; | ||
} | ||
// set boundaries for integration (avoid chopping too much of the multiplet) | ||
let integral = new Float64Array(y.length); | ||
integral[0] = Math.abs(y[0]); | ||
for (let i = 1; i < y.length; i++) { | ||
integral[i] = integral[i - 1] + Math.abs(y[i]); | ||
} | ||
let finishingLeftPoint = y.length / 2; | ||
let finishingRightPoint = y.length / 2; | ||
// console.log(y); | ||
// console.log(integral); | ||
for (let i = 1; i < y.length / 2; i++) { | ||
if ( | ||
(integral[integral.length - 1] - integral[i - 1]) / | ||
integral[integral.length - 1] < | ||
minimalIntegralKeptInMultiplet / 100.0 | ||
) { | ||
finishingLeftPoint = i; | ||
// console.log( " 1<< " + finishingLeftPoint); | ||
break; | ||
} | ||
} | ||
for (let i = 1; i < y.length / 2; i++) { | ||
if ( | ||
integral[integral.length - i - 1] / integral[integral.length - 1] < | ||
minimalIntegralKeptInMultiplet / 100.0 | ||
) { | ||
finishingRightPoint = i; | ||
// console.log( " 2>>" + finishingRightPoint); | ||
break; | ||
} | ||
} | ||
//startingLeftFirstPoint = 1; //////////////////////////////// | ||
//startingRightFirstPoint = 1; //////////////////////////////// | ||
let scalarProductReference; | ||
@@ -261,5 +303,11 @@ let scalarProductNewValue; | ||
scalarProductReference = scalarProduct(y, y, -1, 1); | ||
// console.log("========="); | ||
// console.log(0 + " " + scalarProductReference); | ||
// set boudaries of search keep 90% of spectrum | ||
// search left... | ||
for (let i = 1; i < y.length / 2; i++) { | ||
for (let i = 1; i < finishingLeftPoint; i++) { | ||
scalarProductNewValue = scalarProduct(y, y, -1, 1, i, y.length); | ||
// console.log(i + " " + scalarProductNewValue); | ||
if (scalarProductNewValue > scalarProductReference) { | ||
@@ -270,4 +318,6 @@ scalarProductReference = scalarProductNewValue; | ||
} | ||
for (let i = 1; i < y.length / 2; i++) { | ||
for (let i = 1; i < finishingRightPoint; i++) { | ||
scalarProductNewValue = scalarProduct(y, y, -1, 1, 0, y.length - i); | ||
// console.log(-i + " " + scalarProductNewValue); | ||
if (scalarProductNewValue > scalarProductReference) { | ||
@@ -752,3 +802,3 @@ scalarProductReference = scalarProductNewValue; | ||
let maxAmplitudePosition = maxY({ x: scale, y: spectrum }); | ||
let maxAmplitudePosition = maxY__default['default']({ x: scale, y: spectrum }); | ||
result.chemShift = scale[maxAmplitudePosition.index]; | ||
@@ -755,0 +805,0 @@ return result; |
{ | ||
"name": "multiplet-analysis", | ||
"version": "0.2.0", | ||
"version": "0.3.0", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -31,2 +31,3 @@ # multiplet-analysis | ||
node -r esm examples/dd-exp.js; # to simulate from a user-defined spin system | ||
node -r esm examples/asymDoublet.js; # to simulate from a user-defined spin system | ||
``` | ||
@@ -33,0 +34,0 @@ |
import { scalarProduct } from './scalarProduct'; | ||
export function measureSymShift(y) { | ||
export function measureSymShift(y, options) { | ||
let minimalIntegralKeptInMultiplet = 90.0; | ||
if (options !== undefined) { | ||
minimalIntegralKeptInMultiplet = options; | ||
} | ||
// set boundaries for integration (avoid chopping too much of the multiplet) | ||
let integral = new Float64Array(y.length); | ||
integral[0] = Math.abs(y[0]); | ||
for (let i = 1; i < y.length; i++) { | ||
integral[i] = integral[i - 1] + Math.abs(y[i]); | ||
} | ||
let finishingLeftPoint = y.length / 2; | ||
let finishingRightPoint = y.length / 2; | ||
// console.log(y); | ||
// console.log(integral); | ||
for (let i = 1; i < y.length / 2; i++) { | ||
if ( | ||
(integral[integral.length - 1] - integral[i - 1]) / | ||
integral[integral.length - 1] < | ||
minimalIntegralKeptInMultiplet / 100.0 | ||
) { | ||
finishingLeftPoint = i; | ||
// console.log( " 1<< " + finishingLeftPoint); | ||
break; | ||
} | ||
} | ||
for (let i = 1; i < y.length / 2; i++) { | ||
if ( | ||
integral[integral.length - i - 1] / integral[integral.length - 1] < | ||
minimalIntegralKeptInMultiplet / 100.0 | ||
) { | ||
finishingRightPoint = i; | ||
// console.log( " 2>>" + finishingRightPoint); | ||
break; | ||
} | ||
} | ||
//startingLeftFirstPoint = 1; //////////////////////////////// | ||
//startingRightFirstPoint = 1; //////////////////////////////// | ||
let scalarProductReference; | ||
@@ -8,5 +48,11 @@ let scalarProductNewValue; | ||
scalarProductReference = scalarProduct(y, y, -1, 1); | ||
// console.log("========="); | ||
// console.log(0 + " " + scalarProductReference); | ||
// set boudaries of search keep 90% of spectrum | ||
// search left... | ||
for (let i = 1; i < y.length / 2; i++) { | ||
for (let i = 1; i < finishingLeftPoint; i++) { | ||
scalarProductNewValue = scalarProduct(y, y, -1, 1, i, y.length); | ||
// console.log(i + " " + scalarProductNewValue); | ||
if (scalarProductNewValue > scalarProductReference) { | ||
@@ -17,4 +63,6 @@ scalarProductReference = scalarProductNewValue; | ||
} | ||
for (let i = 1; i < y.length / 2; i++) { | ||
for (let i = 1; i < finishingRightPoint; i++) { | ||
scalarProductNewValue = scalarProduct(y, y, -1, 1, 0, y.length - i); | ||
// console.log(-i + " " + scalarProductNewValue); | ||
if (scalarProductNewValue > scalarProductReference) { | ||
@@ -21,0 +69,0 @@ scalarProductReference = scalarProductNewValue; |
69675
1742
109