npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

taylorwin

v1.0.1

Published

Taylor windows. Suppress sidelobes! Design antenna arrays! Design linear filters!

Downloads

13

Readme

Taylor windows

This is a dependency-free ES2015 module lets you create Taylor windows in JavaScript.

In signal processing, a “window” is a sequence of carefully-chosen numbers that, when multiplied by a sequence of data of the same length, shapes the data’s spectrum (frequency domain representation) in some desirable way.

Another word for “windowing” some data with a “window” (or “taper”) is “apodization”.

Technical background

Perhaps the classic way to motivate windowing data is the problem of separating sinusoids close in frequency. Suppose an instrument is playing A4 (nominally 440 Hz) loudly and another, much softer, instrument is trying to match the note: let the second instrument be 30 dB below the first, and at 443 Hz. If you compute spectrum of the raw clip, you’ll see the loud instrument at 440 Hz, but no sign of the quieter instrument. However, if you window the audio clip with a Taylor window and then find its spectrum, you’ll see the bump at 443 Hz.

Unwindowed vs Taylor-window of synthetic audio clip

The weak 443 Hz sinusoid is lost among the sidelobes of the strong 440 Hz one in the unwindowed spectrum (thin blue, above). With a Taylor window designed to suppress sidelobes to 35 dB below the mainlobe, it has a chance of being noticed. The Matlab code to generate the above:

N = 1000; % samples
fs = 1000; % Hz
t = [0 : N - 1]' / fs; % s
x = sin(2 * pi * t * 440) + 0.0316 * sin(2 * pi * t * (440 + 3));

Nfft = 1024 * 8;
f = ([0 : Nfft - 1] / Nfft - 0.5) * fs; % Hz
spectrum = @(x) fftshift(db20(fft(x, Nfft) / N));
plot(f, spectrum(x), f, spectrum(x .* arf.taylorwin(N, 4, -35)))

Apart from a canonical example that flagrantly breaks these generalizations, generally windows are

  • (nearly) symmetric around their mid-points,
  • positive, and
  • (very) close to zero near the start and end, and rise to a peak at the middle.

Install

Rollup/ES2015 First, the good news: this is a bona fide ES2015 module. Now, the bad news—I’m not really sure how one “installs” ES2015 modules.

Browser Download the minified dist/taylorwin.min.js and optionally the sourcemap dist/taylorwin.js.map. Add <script src="taylorwin.min.js"></script>, which creates a taylorwin global function.

Node.js Use npm to install the module: in the shell, run

$ npm install --save taylorwin

Then, in Node,

> const taylorwin = require('taylorwin');

API

The Taylor window, popular in radar circles, has monotonically-decreasing sidelobes, whose level can be tuned. It is specified by three parameters:

  1. its length N,
  2. the number of nearly-constant sidelobes, nbar, an integer, and
  3. the minimum gap between mainlobe and highest SideLobe Level, SLL, in dB. SLL’s sign is ignored.

Example: create a 64-point Taylor window with four nearly-constant sidelobes at least 35 dB below the mainlobe:

const win = taylorwin(64, 4, 35);
console.log(win);
// [0.5314814093605702, 0.5434274192579622, 0.5670876845563506, 0.6019759550596127,...]

Development

  1. Clone this repo: $ git clone https://github.com/fasiha/taylorwin.js.git.
  2. Install dependencies: $ npm install (just development dependencies).
  3. Create a new branch: $ git checkout -b my-new-feature.
  4. Make some changes, probably in src/taylorwin.js.
  5. Add some tests to test/taylorwin-test.js.
  6. Run the tests: $ npm run prebuild && npm run test. (prebuild runs Rollup/Babel to make a UMD JavaScript file for browser/Node).
  7. If you come up with something you’d like me to review, fork this repo in Gibhub.com, configure a remote for your already-cloned repo to point to this repo, push to it, and make a pull request. GitHub Help has voluminous documentation on how this can work. If this is too much trouble, just open an issue and say your peace.
  8. Otherwise, since this is Unlicense/public domain, run npm run build and do whatever you want with the resulting dist/ directory.

References

The implementation is based on Carrara, Goodman, Majewski, Spotlight synthetic aperture radar: signal processing algorithms, Artech House, 1995, specifically Appendix D.2, pages 512–513.

I also tried reading Taylor’s six-decades-new paper to find out more about these mysterious F weights, but didn’t get far. That reference is T.T. Taylor, “Design of line-source antennas for narrow beamwidth and low side lobes,” Transactions of the IRE Professional Group on Antennas and Propagation, v. 3, no. 1, pp. 16–28, Jan. 1955: DOI.

MATLAB’s documentation on taylorwin (from their expensive Signal Processing Toolbox) may be useful.

License

Unlicense/public domain. If it breaks anything, I didn’t do it. Free to use in commercial/closed-source-land. No citation required—in fact, if you use this, keep it to yourself.