apodization
TypeScript icon, indicating that this package has built-in type declarations

2.0.0 • Public • Published

window-functions

NPM version build status Test coverage npm download

window function applier and some shapes.

Installation

$ npm i window-functions

Usage

It is possible to import the functions directly. Those function accepts an object with options and returns a function (i: number) => number to avoid constants calculation for each call.

import { lorentzToGauss } from 'apodization';
const gm = lorentzToGauss({ gaussianHz: 0.2, exponentialHz: 0, center: 0.5, length: 500, dw = 0.01 });
const value = gm(250); //returns the max value of the gaussian;

Current supported shapes:

Exponential Lorentz to gauss

It is possible to apply a window function directly to data (number[]). It does not change the original data by default but it is possible to pass an array in output property.

import { applyWindow, exponential } from 'apodization';
const data = [1,2,3,4,5];
const exponentialFunc = exponential({ dw: 0.1, lb: 0.2, start: 0 })
const result = applyWindow(data, {
  func: exponential,
  start: 0,
  output: data //inplace modification
});

It is possible to call a window function by:

import { getFunction } from 'apodization';

const shapeOptions = { 
  dw = 0.01,
  center: 0.5, 
  length: 500,
  gaussianHz: 0.2, 
  exponentialHz: 0, 
};

const func = getFunction({
  kind: 'lorentzToGauss',
  ...shapeOptions,
});

console.log(func(250)); //value of window function of index 250

License

MIT

Readme

Keywords

none

Package Sidebar

Install

npm i apodization

Weekly Downloads

2

Version

2.0.0

License

MIT

Unpacked Size

38.8 kB

Total Files

75

Last publish

Collaborators

  • jobo322