Skip to content

kapadia/fitsTableJS

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

fitsTableJS

Yes, a JavaScript library for reading FITS Binary Tables :)

Dependencies

This library is dependent upon jDataView

Installation

Include the dependent library and fitsTableJS

<script src="path/to/jdataview.js" type="text/javascript" charset="utf-8"></script>
<script src="path/to/fitsTable.js" type="text/javascript" charset="utf-8"></script>

Usage

Using an XMLHttpRequest, retrieve an array buffer or binary string of the FITS file.

var xhr = new XMLHttpRequest();
xhr.open('GET', "url/to/shazaam.fits", true);
xhr.responseType = 'arraybuffer';
xhr.onload = function(e) {
    var ft = new FitsTable(xhr.response);
};
xhr.send();

// The header must be read first
ft.readHeader();

// Then we may read the columns
ft.readColumns();

// Access the data
console.log(ft.data);

// Column names are recorded as an array
console.log(ft.columnNames);

// Number of rows and columns
console.log(ft.rows);
console.log(ft.columns);

// You can read a single row at a time and access the data
ft.readColumn();
console.log(ft.data);

Notes for me

These are the fields that describe the columns and data format in the test data.

  • TTYPE1 = 'flux '
  • TFORM1 = 'D '
  • TTYPE2 = 'best_fit'
  • TFORM2 = 'D '
  • TTYPE3 = 'wavelength'
  • TFORM3 = 'D '
  • TTYPE4 = 'and_mask'
  • TFORM4 = 'J '
  • TTYPE5 = 'or_mask '
  • TFORM5 = 'J '
  • TTYPE6 = 'inverse_variance'
  • TFORM6 = 'D'

How we do it

  • Parse for the FITS header
  • Read the above key/values
  • Unpack the binary data using jDataView

TODO:

Support the follow data types that appear in FITS binary tables:

FITS format code Description Number of 8-bit bytes
L logical (Boolean) 1
X* bit *
B Unsigned byte 1
I 16-bit integer 2
J 32-bit integer 4
K* 64-bit integer 4
A character 1
E single precision floating point 4
D double precision floating point 8
C single precision complex 8
M double precision complex 16
P* array descriptor 8
\* Not yet implemented or not yet tested

References

http://packages.python.org/pyfits/users_guide/users_table.html

BAM!

About

JavaScript library for parsing FITS binary tables

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published