Astrometry.js
Extract star pixel coordinates from a FITS image using JavaScript
Install / Use
/learn @zfedoran/Astrometry.jsREADME
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 <small>(Node.js)</small>
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 <small>(Browser)</small>
<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|
Related Skills
node-connect
349.2kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
109.5kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
349.2kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
349.2kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
