Coder Social home page Coder Social logo

zfedoran / astrometry.js Goto Github PK

View Code? Open in Web Editor NEW
7.0 1.0 2.0 15.91 MB

Extract star pixel coordinates from a FITS image using JavaScript

License: BSD 3-Clause "New" or "Revised" License

JavaScript 0.06% Makefile 0.75% Python 5.55% C 80.58% Gnuplot 0.01% Awk 0.04% C++ 2.28% Objective-C 0.23% Shell 0.18% Perl 0.01% PHP 0.01% Roff 0.31% CMake 0.05% Fortran 1.03% TeX 7.39% Lex 0.12% Yacc 1.35% Batchfile 0.02% Smarty 0.03%
astrophotography astrometry fitsio stars emscripten

astrometry.js's Introduction

astrometry.js

Extract star pixel coordinates from a FITS image using JavaScript (supported on Node.js and your Browser)

image2xy

A port of the blind image2xy solver utility from astrometry.net using Emscripten.


Install (Node.js)

npm install astrometry.js

Usage

Read a FITS image file into a buffer (or Uint8Array in the browser, see browser example below))

const fs = require('fs');
const buf = fs.readFileSync('./example.fits');

const image2xy = require('astrometry.js').image2xy;

const result = image2xy(buf, { verbose: true, extension: 0 });

Install (Browser)

<script src="https://cdn.jsdelivr.net/npm/astrometry.js"></script>

Usage

You'll need to do a little bit of work to get a file buffer on the browser. Live example.

var reader = new FileReader();

reader.onload = function (e) {
    // Get the image file as a buffer
    var buf = new Uint8Array(e.currentTarget.result);

    // Get a fits file buffer containing a star list
    const results = astrometry(buf, { verbose: true, extension: 0 });
};

reader.readAsArrayBuffer(file);

Example

The following shows an example output.

const result = image2xy(buf, { verbose: true, extension: 0 });

>   infile=fits_buf.fits
    outfile=fits_buf.xy.fits
    nhdus=1
    Got naxis=2, na1=4096, na2=4096
    simplexy: nx=4096, ny=4096
    simplexy: dpsf=1.000000, plim=8.000000, dlim=1.000000, saddle=5.000000
    simplexy: maxper=1000, maxnpeaks=10000, maxsize=2000, halfbox=100
    simplexy: median smoothing...
    simplexy: measuring image noise (sigma)...
    Sampling sigma at 42025 points
    Nsigma=0.7, s=13.132
    simplexy: found sigma=13.132.
    simplexy: finding objects...
    simplexy: found 734 blobs
    simplexy: finding peaks...
    simplexy: found 743 sources.

Options

You may use the same options that image2xy supports by providing the flags directly, or you may use the following human friendly versions.

Options List
Option Flag Type Description
help 'h' boolean Print available options and usage instructions
verbose 'v' boolean Print verbose messages
extension 'e' number Read from a single FITS extension
downsampleFactor 'D' number Downsample, if necessary, by this many factors of two
medianFilteringScale 's' number Set median-filter box size (default 100 pixels)
psfWidth 'w' number Set Gaussian PSF sigma (default 1 pixel)
noiseLevel 'g' number Set image noise level
peakSigma 'p' number Set significance level of peaks (default 8 sigmas)
saddleLevel 'a' number Set saddle level joining peaks (default 5 sigmas)
disableBackgroundSubtraction 'b' boolean Don't do (median-based) background subtraction
backgroundLevel 'G' number Subtract this 'global' background value; implies -b
outputFilename 'o' filename Write XYlist to given filename.
backgroundSubtractedImageName 'S' filename Save background-subtracted image to this filename (FITS float image)
backgroundImageName 'B' filename Save background image to filename
smoothedImageName 'U' filename Save smoothed background-subtracted image to filename
maskImageName 'M' filename Save mask image to filename
blobImageName 'C' filename Save connected-components image to filename

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.