Skip to content

Repository files navigation

fits-js

FITS file format implementation for JavaScript runtimes

Issues · Contributing · Docs

CI codecov npm version License

Note

This project is in early development and is not recommended for production usage, but feedback is very welcome on GitHub.

About

FITS (Flexible Image Transport System) is the container format astronomy runs on. Telescopes, sky surveys, and public data archives store images and tabular catalogs as FITS. A sequence of header-and-data units holds N-dimensional image arrays, binary and ASCII tables, and optionally tile-compressed image data.

fits-js reads and writes FITS in TypeScript. The parser handles the full header grammar (including CONTINUE and HIERARCH), the image decoder covers every BITPIX with astropy-parity scaling, and I/O goes through a small web-standard byte-source interface, so the same code runs on Node, Bun, Deno, Cloudflare Workers, and the browser. @fits-js/core carries no runtime dependencies.

Quick start

npm install @fits-js/core
import { NodeFileReader, openFits, readImage } from "@fits-js/core";

const reader = await NodeFileReader.open("data/image.fits");
try {
  const { hdus } = await openFits(reader);
  const region = { start: [0, 0], shape: [16, 16] };
  const { data } = await readImage(hdus[0], reader, { region });
  console.log(data.slice(0, 8));
} finally {
  await reader.close();
}

openFits enumerates HDUs and reads only header blocks. readImage with a region reads only the bytes that region covers, so a small cutout from a multi-gigabyte cube stays cheap. HttpRangeReader and BlobReader are the byte-source adapters for URLs and browser File inputs.

Requires Node 22 or later. In the browser, any environment with fetch, Blob, and TypedArray works.

Packages

Package Description
@fits-js/core Parser, image decoder, and four RandomAccessReader implementations (in-memory, Blob/File, Node file, HTTP Range)

Documentation

Full docs at prustic.github.io/fits-js.

Contribution

fits-js is free and open source, licensed under Apache-2.0.

Security

If you discover a security vulnerability, please see SECURITY.md for how to report it responsibly.

About

TypeScript implementation of the FITS file format

Topics

Resources

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages