Created using the existing fitsToKdb repo from: https://github.com/jpneill/fitsToKdb
./include/k.h can be found here: https://github.com/KxSystems/kdb/blob/master/c/c/k.h
Both slightly modified to work better with a given example.
fitsToKdb also requires the use of the CFITSIO library found here:
https://heasarc.gsfc.nasa.gov/docs/software/fitsio/
For installing the library, Copy and run:
apt update apt install build-essential pkg-config libcfitsio-dev
Verify the install:
pkg-config --modversion cfitsio pkg-config --cflags --libs cfitsio
gcc -O2 -fPIC -shared \ $(pkg-config --cflags cfitsio) \ -I./include \ fitsToKdb.c \ -o fitsToKdb.so \ $(pkg-config --libs cfitsio)
Examples can be found here https://www.sdss4.org/
Model schema description sample can be found here https://data.sdss.org/datamodel/files/SPECTRO_REDUX/specObj.html
To import the module and build the table:
//To read in 500 rows from the second chunk(HDU) of data q)fitsToKdb:use`kx.fitsToKdb q)tab:fitsToKdb.createPartialTab[`$"example/example1.fits";500;2] q)count tab 500 //to get the full tab q)fitsToKdb:use`kx.fitsToKdb q)tab:fitsToKdb.createTab[`$"example/example1.fits";0;2] q)count tab 1843200
Typically the first HDU in these types of files is an image, which is outside the scope of analysis for this module.
As such, the below error will appear
q)fitsToKdb:use`kx.fitsToKdb q)tab:fitsToKdb.createTab[`$"example/example1.fits";500;1] 'Unable to open FITS table