multiplet-analysis
Advanced tools
Comparing version 1.0.0 to 1.0.1
129
lib/index.js
@@ -6,3 +6,3 @@ 'use strict'; | ||
var maxY = require('ml-array-xy-max-y'); | ||
var fftJs = require('fft-js'); | ||
var FFT = require('fft.js'); | ||
@@ -12,2 +12,3 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } | ||
var maxY__default = /*#__PURE__*/_interopDefaultLegacy(maxY); | ||
var FFT__default = /*#__PURE__*/_interopDefaultLegacy(FFT); | ||
@@ -247,10 +248,5 @@ function appendDebug( | ||
) { | ||
//let y1 = deco(y, jStar, sign, 1, chopTail, multiplicity); // dir left to right | ||
//let y2 = deco(y, jStar, sign, -1, chopTail, multiplicity); // dir right to left | ||
let nbLines = parseInt(2 * multiplicity, 10); // 1 for doublet (spin 1/2) 2, for spin 1, etc... never tested... | ||
let y1 = decofast1(y, jStar, sign, nbLines, jStar); | ||
// console.log(`y1 :: ` + y1); | ||
let y2 = decofast2(y, jStar, sign, nbLines, jStar); | ||
// console.log(`y2 :: ` + y2); | ||
return sign * scalarProduct(y1, y2, 1, incrementForSpeed); | ||
@@ -272,4 +268,2 @@ } | ||
let finishingRightPoint = y.length / 2; | ||
// console.log(y); | ||
// console.log(integral); | ||
@@ -283,4 +277,2 @@ for (let i = 1; i < y.length / 2; i++) { | ||
finishingLeftPoint = i; | ||
// console.log( " 1<< " + finishingLeftPoint); | ||
break; | ||
@@ -295,9 +287,5 @@ } | ||
finishingRightPoint = i; | ||
// console.log( " 2>>" + finishingRightPoint); | ||
break; | ||
} | ||
} | ||
//startingLeftFirstPoint = 1; //////////////////////////////// | ||
//startingRightFirstPoint = 1; //////////////////////////////// | ||
let scalarProductReference; | ||
@@ -307,4 +295,2 @@ let scalarProductNewValue; | ||
scalarProductReference = scalarProduct(y, y, -1, 1); | ||
// console.log("========="); | ||
// console.log(0 + " " + scalarProductReference); | ||
@@ -315,3 +301,2 @@ // set boudaries of search keep 90% of spectrum | ||
scalarProductNewValue = scalarProduct(y, y, -1, 1, i, y.length); | ||
// console.log(i + " " + scalarProductNewValue); | ||
@@ -325,3 +310,2 @@ if (scalarProductNewValue > scalarProductReference) { | ||
scalarProductNewValue = scalarProduct(y, y, -1, 1, 0, y.length - i); | ||
// console.log(-i + " " + scalarProductNewValue); | ||
@@ -356,8 +340,5 @@ if (scalarProductNewValue > scalarProductReference) { | ||
let scaIncrement = (x[x.length - 1] - x[0]) / (x.length - 1); // delta one pt | ||
//let scaPt = x[0] - scaIncrement / 2; // move to limit side - not middle of first point (half a pt left...) | ||
let scaPt = x[0]; // move to limit side - not middle of first point (half a pt left...) | ||
let trueWidth = scaIncrement * x.length; | ||
let scaIncrementInterp = trueWidth / numberOfPointOutput; | ||
//scaPt += scaIncrement / 2; // move from limit side to middle of first pt | ||
// set scale | ||
@@ -374,3 +355,4 @@ for (let i = 0; i < numberOfPointOutput; i++) { | ||
let an = [...Array(nextPowerTwoInput)].map(() => Array(2).fill(0)); // n x 2 array | ||
const fft = new FFT__default['default'](nextPowerTwoInput); | ||
const an = fft.createComplexArray(); | ||
const halfNumPt = Math.floor(y.length / 2); // may ignore last pt... if odd number | ||
@@ -380,27 +362,22 @@ const halfNumPtB = y.length - halfNumPt; | ||
for (let i = 0; i < halfNumPt; i++) { | ||
an[shiftMultiplet + i + halfNumPtB][0] = y[i]; //Re | ||
an[shiftMultiplet + i + halfNumPtB][1] = 0; //Im | ||
an[(shiftMultiplet + i + halfNumPtB) * 2] = y[i]; | ||
} | ||
for (let i = 0; i < halfNumPtB; i++) { | ||
an[i][0] = y[i + halfNumPt]; //Re | ||
an[i][1] = 0; //Im | ||
an[i * 2] = y[i + halfNumPt]; | ||
} | ||
let timeDomain = fftJs.ifft(an); | ||
timeDomain[0][0] = timeDomain[0][0] / 2; // divide first point by 2 Re | ||
timeDomain[0][1] = timeDomain[0][1] / 2; // divide first point by 2 Im | ||
const timeDomain = fft.createComplexArray(); | ||
fft.inverseTransform(timeDomain, an); | ||
timeDomain[0] /= 2; // divide first point by 2 Re | ||
timeDomain[1] /= 2; // divide first point by 2 Im | ||
// move to larger array... | ||
let timeDomainZeroFilled = [...Array(nextPowerTwoOut)].map(() => | ||
Array(2).fill(0), | ||
); // n x 2 array | ||
for (let i = 0; i < halfNumPt; i++) { | ||
timeDomainZeroFilled[i][0] = timeDomain[i][0]; //* Math.cos((phase / 180) * Math.PI) + | ||
timeDomainZeroFilled[i][1] = timeDomain[i][1]; //* Math.cos((phase / 180) * Math.PI) - | ||
const fft2 = new FFT__default['default'](nextPowerTwoOut); | ||
let timeDomainZeroFilled = fft2.createComplexArray(); | ||
for (let i = 0; i < halfNumPt * 2; i++) { | ||
timeDomainZeroFilled[i] = timeDomain[i]; //* Math.cos((phase / 180) * Math.PI) | ||
} | ||
for (let i = halfNumPt; i < nextPowerTwoInput; i++) { | ||
// zero filling | ||
timeDomainZeroFilled[i][0] = 0; | ||
timeDomainZeroFilled[i][1] = 0; | ||
} | ||
let interpolatedSpectrum = fftJs.fft(timeDomainZeroFilled); | ||
const interpolatedSpectrum = fft2.createComplexArray(); | ||
fft2.transform(interpolatedSpectrum, timeDomainZeroFilled); | ||
const halfNumPt2 = Math.floor(numberOfPointOutput / 2); | ||
@@ -413,8 +390,8 @@ | ||
let tmp = | ||
interpolatedSpectrum[i][0] * Math.cos(phaseRad) + | ||
interpolatedSpectrum[i][1] * Math.sin(phaseRad); // only Re now... | ||
interpolatedSpectrum[i][1] = | ||
-interpolatedSpectrum[i][0] * Math.sin(phaseRad) + | ||
interpolatedSpectrum[i][1] * Math.cos(phaseRad); // only Re now... | ||
interpolatedSpectrum[i][0] = tmp; | ||
interpolatedSpectrum[i * 2] * Math.cos(phaseRad) + | ||
interpolatedSpectrum[i * 2 + 1] * Math.sin(phaseRad); // only Re now... | ||
interpolatedSpectrum[i * 2 + 1] = | ||
-interpolatedSpectrum[i * 2] * Math.sin(phaseRad) + | ||
interpolatedSpectrum[i * 2 + 1] * Math.cos(phaseRad); // only Re now... | ||
interpolatedSpectrum[i * 2] = tmp; | ||
} | ||
@@ -430,21 +407,20 @@ } | ||
let vecty = 0; | ||
// sumNorms = 0; | ||
if (appliedPhaseCorrectionType > 0) { | ||
// if ( true ) { | ||
for (let loop = 0; loop < 2 * halfNumPt2; loop++) { | ||
if (interpolatedSpectrum[loop][0] !== 0) { | ||
if (interpolatedSpectrum[loop * 2] !== 0) { | ||
localPhaseRad = Math.atan( | ||
interpolatedSpectrum[loop][1] / interpolatedSpectrum[loop][0], | ||
interpolatedSpectrum[loop * 2 + 1] / | ||
interpolatedSpectrum[loop * 2], | ||
); | ||
} else { | ||
localPhaseRad = | ||
(Math.sign(interpolatedSpectrum[loop][1]) * Math.PI) / 2.0; | ||
(Math.sign(interpolatedSpectrum[loop * 2 + 1]) * Math.PI) / 2.0; | ||
} | ||
norm = Math.sqrt( | ||
interpolatedSpectrum[loop][1] * interpolatedSpectrum[loop][1] + | ||
interpolatedSpectrum[loop][0] * interpolatedSpectrum[loop][0], | ||
interpolatedSpectrum[loop * 2 + 1] * | ||
interpolatedSpectrum[loop * 2 + 1] + | ||
interpolatedSpectrum[loop * 2] * interpolatedSpectrum[loop * 2], | ||
); | ||
vectx += Math.cos(localPhaseRad) * norm; | ||
vecty += Math.sin(localPhaseRad) * norm; | ||
// sumNorms += norm; | ||
} | ||
@@ -465,8 +441,8 @@ if (vectx !== 0) { | ||
let tmp = | ||
interpolatedSpectrum[loop][0] * Math.cos(phaseRad) + | ||
interpolatedSpectrum[loop][1] * Math.sin(phaseRad); // only Re now... | ||
interpolatedSpectrum[loop][1] = | ||
-interpolatedSpectrum[loop][0] * Math.sin(phaseRad) + | ||
interpolatedSpectrum[loop][1] * Math.cos(phaseRad); // only Re now... | ||
interpolatedSpectrum[loop][0] = tmp; | ||
interpolatedSpectrum[loop * 2] * Math.cos(phaseRad) + | ||
interpolatedSpectrum[loop * 2 + 1] * Math.sin(phaseRad); // only Re now... | ||
interpolatedSpectrum[loop * 2 + 1] = | ||
-interpolatedSpectrum[loop * 2] * Math.sin(phaseRad) + | ||
interpolatedSpectrum[loop * 2 + 1] * Math.cos(phaseRad); // only Re now... | ||
interpolatedSpectrum[loop * 2] = tmp; | ||
} | ||
@@ -480,6 +456,6 @@ } | ||
for (let i = 0; i < halfNumPt2; i++) { | ||
spectrum[i] = interpolatedSpectrum[halfNumPt2 + dropPoints + i][0]; // only Re now... | ||
spectrum[i] = interpolatedSpectrum[(halfNumPt2 + dropPoints + i) * 2]; // only Re now... | ||
} | ||
for (let i = 0; i < halfNumPt2; i++) { | ||
spectrum[i + halfNumPt2] = interpolatedSpectrum[i][0]; | ||
spectrum[i + halfNumPt2] = interpolatedSpectrum[i * 2]; | ||
} | ||
@@ -582,3 +558,2 @@ if (returnedPhase > 360.0) { | ||
); | ||
//if (debug) console.log(`interpolating`); | ||
@@ -594,15 +569,2 @@ spectrum = returned.spectrum; | ||
/// for testing break symmetry before running... | ||
/* | ||
movedBy = 120; | ||
if (movedBy > 0) { | ||
spe = spe.slice(0, spe.length - movedBy); | ||
sca = sca.slice(0, sca.length - movedBy); | ||
} | ||
if (movedBy < 0) { | ||
spe = spe.slice(-movedBy, spe.length); | ||
sca = sca.slice(-movedBy, sca.length); | ||
}*/ | ||
/// end | ||
resolutionPpm = | ||
@@ -622,6 +584,3 @@ Math.abs(scale[0] - scale[scale.length - 1]) / (scale.length - 1); | ||
//if (!debug) { | ||
//incrementForSpeed = (1 + 0.5 / minimalResolution) | 0; // not enough.... some peak sneek between points | ||
incrementForSpeed = (1 + 0.3 / minimalResolution) | 0; // 1 could be set better (according to line widht ?!) | ||
//} | ||
for ( | ||
@@ -674,4 +633,2 @@ let loopoverJvalues = 1; | ||
); | ||
//console.log(`recuded size to :: ` + maxTestedPt); | ||
//console.log(`recuded size to :: ` + maxTestedPt + " = " + (maxTestedPt*resolutionHz)); | ||
} | ||
@@ -714,4 +671,2 @@ } | ||
while (curIncrementForSpeed > 1) { | ||
//console.log(`curIncrementForSpeed:: ` + curIncrementForSpeed); | ||
curIncrementForSpeed = Math.floor(curIncrementForSpeed / 2); // get smaller and smaller step | ||
@@ -728,3 +683,2 @@ let froms = topPosJ - 2 * curIncrementForSpeed; // maybe 1 is enough.... | ||
) { | ||
// if (( scalProd[jStarFine] === -1) || true) { // this was a bad idea because precision reduced with earlyer tests | ||
scalProd[jStarFine] = measureDeco( | ||
@@ -759,4 +713,2 @@ spectrum, | ||
// if (debug) console.log(`J:: ${topPosJ * resolutionHz}`); | ||
result.j.push({ | ||
@@ -775,5 +727,2 @@ multiplicity: 'd', | ||
} | ||
/*console.log( | ||
`${jStar} J* = ${JStarArray[jStar]} ${scalProd[jStar]} lenght ${y.length}`, | ||
);*/ | ||
} | ||
@@ -780,0 +729,0 @@ |
{ | ||
"name": "multiplet-analysis", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "", | ||
@@ -14,4 +14,6 @@ "main": "lib/index.js", | ||
"eslint-fix": "npm run eslint -- --fix", | ||
"prepublishOnly": "rollup -c", | ||
"test": "npm run test-coverage && npm run eslint", | ||
"prepack": "rollup -c", | ||
"prettier": "prettier --check src", | ||
"prettier-write": "prettier --write src", | ||
"test": "npm run test-coverage && npm run eslint && npm run prettier", | ||
"test-coverage": "jest --coverage", | ||
@@ -42,16 +44,16 @@ "test-only": "jest" | ||
"devDependencies": { | ||
"@babel/plugin-transform-modules-commonjs": "^7.13.8", | ||
"eslint": "^7.22.0", | ||
"eslint-config-cheminfo": "^5.2.3", | ||
"@babel/plugin-transform-modules-commonjs": "^7.14.0", | ||
"eslint": "^7.26.0", | ||
"eslint-config-cheminfo": "^5.2.4", | ||
"esm": "^3.2.25", | ||
"fft.js": "^4.0.4", | ||
"jest": "^26.6.3", | ||
"jest-matcher-deep-close-to": "^2.0.1", | ||
"nmr-simulation": "^1.0.21", | ||
"prettier": "^2.2.1", | ||
"rollup": "^2.42.4" | ||
"prettier": "^2.3.0", | ||
"rollup": "^2.47.0" | ||
}, | ||
"dependencies": { | ||
"fft-js": "0.0.12", | ||
"fft.js": "^4.0.4", | ||
"ml-array-xy-max-y": "^1.0.2" | ||
} | ||
} |
@@ -0,0 +0,0 @@ # multiplet-analysis |
@@ -0,0 +0,0 @@ export function appendDebug( |
@@ -0,0 +0,0 @@ export function decofast1(yi, jStar, sign, nbLines, addspace = 0) { |
@@ -95,3 +95,2 @@ /** | ||
); | ||
//if (debug) console.log(`interpolating`); | ||
@@ -107,15 +106,2 @@ spectrum = returned.spectrum; | ||
/// for testing break symmetry before running... | ||
/* | ||
movedBy = 120; | ||
if (movedBy > 0) { | ||
spe = spe.slice(0, spe.length - movedBy); | ||
sca = sca.slice(0, sca.length - movedBy); | ||
} | ||
if (movedBy < 0) { | ||
spe = spe.slice(-movedBy, spe.length); | ||
sca = sca.slice(-movedBy, sca.length); | ||
}*/ | ||
/// end | ||
resolutionPpm = | ||
@@ -135,6 +121,3 @@ Math.abs(scale[0] - scale[scale.length - 1]) / (scale.length - 1); | ||
//if (!debug) { | ||
//incrementForSpeed = (1 + 0.5 / minimalResolution) | 0; // not enough.... some peak sneek between points | ||
incrementForSpeed = (1 + 0.3 / minimalResolution) | 0; // 1 could be set better (according to line widht ?!) | ||
//} | ||
for ( | ||
@@ -187,4 +170,2 @@ let loopoverJvalues = 1; | ||
); | ||
//console.log(`recuded size to :: ` + maxTestedPt); | ||
//console.log(`recuded size to :: ` + maxTestedPt + " = " + (maxTestedPt*resolutionHz)); | ||
} | ||
@@ -227,4 +208,2 @@ } | ||
while (curIncrementForSpeed > 1) { | ||
//console.log(`curIncrementForSpeed:: ` + curIncrementForSpeed); | ||
curIncrementForSpeed = Math.floor(curIncrementForSpeed / 2); // get smaller and smaller step | ||
@@ -241,3 +220,2 @@ let froms = topPosJ - 2 * curIncrementForSpeed; // maybe 1 is enough.... | ||
) { | ||
// if (( scalProd[jStarFine] === -1) || true) { // this was a bad idea because precision reduced with earlyer tests | ||
scalProd[jStarFine] = measureDeco( | ||
@@ -272,4 +250,2 @@ spectrum, | ||
// if (debug) console.log(`J:: ${topPosJ * resolutionHz}`); | ||
result.j.push({ | ||
@@ -288,5 +264,2 @@ multiplicity: 'd', | ||
} | ||
/*console.log( | ||
`${jStar} J* = ${JStarArray[jStar]} ${scalProd[jStar]} lenght ${y.length}`, | ||
);*/ | ||
} | ||
@@ -293,0 +266,0 @@ |
@@ -12,11 +12,6 @@ import { decofast1, decofast2 } from './deco'; | ||
) { | ||
//let y1 = deco(y, jStar, sign, 1, chopTail, multiplicity); // dir left to right | ||
//let y2 = deco(y, jStar, sign, -1, chopTail, multiplicity); // dir right to left | ||
let nbLines = parseInt(2 * multiplicity, 10); // 1 for doublet (spin 1/2) 2, for spin 1, etc... never tested... | ||
let y1 = decofast1(y, jStar, sign, nbLines, jStar); | ||
// console.log(`y1 :: ` + y1); | ||
let y2 = decofast2(y, jStar, sign, nbLines, jStar); | ||
// console.log(`y2 :: ` + y2); | ||
return sign * scalarProduct(y1, y2, 1, incrementForSpeed); | ||
} |
@@ -16,4 +16,2 @@ import { scalarProduct } from './scalarProduct'; | ||
let finishingRightPoint = y.length / 2; | ||
// console.log(y); | ||
// console.log(integral); | ||
@@ -27,4 +25,2 @@ for (let i = 1; i < y.length / 2; i++) { | ||
finishingLeftPoint = i; | ||
// console.log( " 1<< " + finishingLeftPoint); | ||
break; | ||
@@ -39,9 +35,5 @@ } | ||
finishingRightPoint = i; | ||
// console.log( " 2>>" + finishingRightPoint); | ||
break; | ||
} | ||
} | ||
//startingLeftFirstPoint = 1; //////////////////////////////// | ||
//startingRightFirstPoint = 1; //////////////////////////////// | ||
let scalarProductReference; | ||
@@ -51,4 +43,2 @@ let scalarProductNewValue; | ||
scalarProductReference = scalarProduct(y, y, -1, 1); | ||
// console.log("========="); | ||
// console.log(0 + " " + scalarProductReference); | ||
@@ -59,3 +49,2 @@ // set boudaries of search keep 90% of spectrum | ||
scalarProductNewValue = scalarProduct(y, y, -1, 1, i, y.length); | ||
// console.log(i + " " + scalarProductNewValue); | ||
@@ -69,3 +58,2 @@ if (scalarProductNewValue > scalarProductReference) { | ||
scalarProductNewValue = scalarProduct(y, y, -1, 1, 0, y.length - i); | ||
// console.log(-i + " " + scalarProductNewValue); | ||
@@ -72,0 +60,0 @@ if (scalarProductNewValue > scalarProductReference) { |
@@ -0,0 +0,0 @@ export function getGeneralPascal(n, spin = 0.5) { |
@@ -0,0 +0,0 @@ export function scalarProduct( |
@@ -0,0 +0,0 @@ export function symmetrize(y) { |
@@ -1,2 +0,2 @@ | ||
import { fft, ifft } from 'fft-js'; | ||
import FFT from 'fft.js'; | ||
@@ -14,8 +14,5 @@ export function trigInterpolate( | ||
let scaIncrement = (x[x.length - 1] - x[0]) / (x.length - 1); // delta one pt | ||
//let scaPt = x[0] - scaIncrement / 2; // move to limit side - not middle of first point (half a pt left...) | ||
let scaPt = x[0]; // move to limit side - not middle of first point (half a pt left...) | ||
let trueWidth = scaIncrement * x.length; | ||
let scaIncrementInterp = trueWidth / numberOfPointOutput; | ||
//scaPt += scaIncrement / 2; // move from limit side to middle of first pt | ||
// set scale | ||
@@ -32,3 +29,4 @@ for (let i = 0; i < numberOfPointOutput; i++) { | ||
let an = [...Array(nextPowerTwoInput)].map(() => Array(2).fill(0)); // n x 2 array | ||
const fft = new FFT(nextPowerTwoInput); | ||
const an = fft.createComplexArray(); | ||
const halfNumPt = Math.floor(y.length / 2); // may ignore last pt... if odd number | ||
@@ -38,27 +36,22 @@ const halfNumPtB = y.length - halfNumPt; | ||
for (let i = 0; i < halfNumPt; i++) { | ||
an[shiftMultiplet + i + halfNumPtB][0] = y[i]; //Re | ||
an[shiftMultiplet + i + halfNumPtB][1] = 0; //Im | ||
an[(shiftMultiplet + i + halfNumPtB) * 2] = y[i]; | ||
} | ||
for (let i = 0; i < halfNumPtB; i++) { | ||
an[i][0] = y[i + halfNumPt]; //Re | ||
an[i][1] = 0; //Im | ||
an[i * 2] = y[i + halfNumPt]; | ||
} | ||
let timeDomain = ifft(an); | ||
timeDomain[0][0] = timeDomain[0][0] / 2; // divide first point by 2 Re | ||
timeDomain[0][1] = timeDomain[0][1] / 2; // divide first point by 2 Im | ||
const timeDomain = fft.createComplexArray(); | ||
fft.inverseTransform(timeDomain, an); | ||
timeDomain[0] /= 2; // divide first point by 2 Re | ||
timeDomain[1] /= 2; // divide first point by 2 Im | ||
// move to larger array... | ||
let timeDomainZeroFilled = [...Array(nextPowerTwoOut)].map(() => | ||
Array(2).fill(0), | ||
); // n x 2 array | ||
for (let i = 0; i < halfNumPt; i++) { | ||
timeDomainZeroFilled[i][0] = timeDomain[i][0]; //* Math.cos((phase / 180) * Math.PI) + | ||
timeDomainZeroFilled[i][1] = timeDomain[i][1]; //* Math.cos((phase / 180) * Math.PI) - | ||
const fft2 = new FFT(nextPowerTwoOut); | ||
let timeDomainZeroFilled = fft2.createComplexArray(); | ||
for (let i = 0; i < halfNumPt * 2; i++) { | ||
timeDomainZeroFilled[i] = timeDomain[i]; //* Math.cos((phase / 180) * Math.PI) | ||
} | ||
for (let i = halfNumPt; i < nextPowerTwoInput; i++) { | ||
// zero filling | ||
timeDomainZeroFilled[i][0] = 0; | ||
timeDomainZeroFilled[i][1] = 0; | ||
} | ||
let interpolatedSpectrum = fft(timeDomainZeroFilled); | ||
const interpolatedSpectrum = fft2.createComplexArray(); | ||
fft2.transform(interpolatedSpectrum, timeDomainZeroFilled); | ||
const halfNumPt2 = Math.floor(numberOfPointOutput / 2); | ||
@@ -71,8 +64,8 @@ | ||
let tmp = | ||
interpolatedSpectrum[i][0] * Math.cos(phaseRad) + | ||
interpolatedSpectrum[i][1] * Math.sin(phaseRad); // only Re now... | ||
interpolatedSpectrum[i][1] = | ||
-interpolatedSpectrum[i][0] * Math.sin(phaseRad) + | ||
interpolatedSpectrum[i][1] * Math.cos(phaseRad); // only Re now... | ||
interpolatedSpectrum[i][0] = tmp; | ||
interpolatedSpectrum[i * 2] * Math.cos(phaseRad) + | ||
interpolatedSpectrum[i * 2 + 1] * Math.sin(phaseRad); // only Re now... | ||
interpolatedSpectrum[i * 2 + 1] = | ||
-interpolatedSpectrum[i * 2] * Math.sin(phaseRad) + | ||
interpolatedSpectrum[i * 2 + 1] * Math.cos(phaseRad); // only Re now... | ||
interpolatedSpectrum[i * 2] = tmp; | ||
} | ||
@@ -88,21 +81,20 @@ } | ||
let vecty = 0; | ||
// sumNorms = 0; | ||
if (appliedPhaseCorrectionType > 0) { | ||
// if ( true ) { | ||
for (let loop = 0; loop < 2 * halfNumPt2; loop++) { | ||
if (interpolatedSpectrum[loop][0] !== 0) { | ||
if (interpolatedSpectrum[loop * 2] !== 0) { | ||
localPhaseRad = Math.atan( | ||
interpolatedSpectrum[loop][1] / interpolatedSpectrum[loop][0], | ||
interpolatedSpectrum[loop * 2 + 1] / | ||
interpolatedSpectrum[loop * 2], | ||
); | ||
} else { | ||
localPhaseRad = | ||
(Math.sign(interpolatedSpectrum[loop][1]) * Math.PI) / 2.0; | ||
(Math.sign(interpolatedSpectrum[loop * 2 + 1]) * Math.PI) / 2.0; | ||
} | ||
norm = Math.sqrt( | ||
interpolatedSpectrum[loop][1] * interpolatedSpectrum[loop][1] + | ||
interpolatedSpectrum[loop][0] * interpolatedSpectrum[loop][0], | ||
interpolatedSpectrum[loop * 2 + 1] * | ||
interpolatedSpectrum[loop * 2 + 1] + | ||
interpolatedSpectrum[loop * 2] * interpolatedSpectrum[loop * 2], | ||
); | ||
vectx += Math.cos(localPhaseRad) * norm; | ||
vecty += Math.sin(localPhaseRad) * norm; | ||
// sumNorms += norm; | ||
} | ||
@@ -123,8 +115,8 @@ if (vectx !== 0) { | ||
let tmp = | ||
interpolatedSpectrum[loop][0] * Math.cos(phaseRad) + | ||
interpolatedSpectrum[loop][1] * Math.sin(phaseRad); // only Re now... | ||
interpolatedSpectrum[loop][1] = | ||
-interpolatedSpectrum[loop][0] * Math.sin(phaseRad) + | ||
interpolatedSpectrum[loop][1] * Math.cos(phaseRad); // only Re now... | ||
interpolatedSpectrum[loop][0] = tmp; | ||
interpolatedSpectrum[loop * 2] * Math.cos(phaseRad) + | ||
interpolatedSpectrum[loop * 2 + 1] * Math.sin(phaseRad); // only Re now... | ||
interpolatedSpectrum[loop * 2 + 1] = | ||
-interpolatedSpectrum[loop * 2] * Math.sin(phaseRad) + | ||
interpolatedSpectrum[loop * 2 + 1] * Math.cos(phaseRad); // only Re now... | ||
interpolatedSpectrum[loop * 2] = tmp; | ||
} | ||
@@ -138,6 +130,6 @@ } | ||
for (let i = 0; i < halfNumPt2; i++) { | ||
spectrum[i] = interpolatedSpectrum[halfNumPt2 + dropPoints + i][0]; // only Re now... | ||
spectrum[i] = interpolatedSpectrum[(halfNumPt2 + dropPoints + i) * 2]; // only Re now... | ||
} | ||
for (let i = 0; i < halfNumPt2; i++) { | ||
spectrum[i + halfNumPt2] = interpolatedSpectrum[i][0]; | ||
spectrum[i + halfNumPt2] = interpolatedSpectrum[i * 2]; | ||
} | ||
@@ -144,0 +136,0 @@ if (returnedPhase > 360.0) { |
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
66102
1651
+ Addedfft.js@^4.0.4
+ Addedfft.js@4.0.4(transitive)
- Removedfft-js@0.0.12
- Removedbit-twiddle@1.0.2(transitive)
- Removedcommander@2.7.1(transitive)
- Removedfft-js@0.0.12(transitive)
- Removedgraceful-readlink@1.0.1(transitive)