-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: peaks, signals, ranges, zones with id (#1732)
* chore: black filling in peak shapes * fix(fft): ensure length is a power of two ensure that data has the same length pad data to the next power of two close: #1688 * chore: update ml-gsd n prerelease nmr-processing * chore: update pre-release nmr-processing * chore: less code * chore: return caret * chore: remove unexpected data-test-id * chore: fix fft * chore: update nmr-processing
- Loading branch information
Showing
7 changed files
with
84 additions
and
21 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import { xSequentialFill } from 'ml-spectra-processing'; | ||
|
||
import { Datum1D } from '../../../types/data1d'; | ||
|
||
export function padDataToNextPowerOfTwo( | ||
datum1D: Datum1D, | ||
digitalFilterApplied: boolean, | ||
) { | ||
const { x, re, im } = datum1D.data; | ||
const size = nextPowerOfTwo(x.length); | ||
|
||
let newRE = new Float64Array(size); | ||
let newIM = new Float64Array(size); | ||
|
||
const pointsToShift = getPointsToShift(datum1D); | ||
|
||
newRE.set(re.slice(0, length - pointsToShift)); | ||
newIM.set(im.slice(0, length - pointsToShift)); | ||
|
||
if (pointsToShift > 0 && digitalFilterApplied) { | ||
newRE.set(re.slice(re.length - pointsToShift), size - pointsToShift); | ||
newIM.set(im.slice(re.length - pointsToShift), size - pointsToShift); | ||
} | ||
|
||
const newX = xSequentialFill({ | ||
from: x[0], | ||
size, | ||
step: x[1] - x[0], | ||
}) as Float64Array; | ||
|
||
datum1D.data = { ...datum1D.data, ...{ re: newRE, im: newIM, x: newX } }; | ||
} | ||
|
||
function getPointsToShift(datum1D: Datum1D) { | ||
let grpdly = datum1D.info?.digitalFilter || 0; | ||
return grpdly > 0 ? Math.floor(grpdly) : 0; | ||
} | ||
|
||
function nextPowerOfTwo(n: number) { | ||
if (n === 0) return 1; | ||
n--; | ||
n |= n >> 1; | ||
n |= n >> 2; | ||
n |= n >> 4; | ||
n |= n >> 8; | ||
n |= n >> 16; | ||
return n + 1; | ||
} |