Page 1 of 1

reading 1D fits files

Posted: Sat Dec 17, 2016 10:15 am
by Arnold de Bruin
Hello all,

At the moment I am busy making a program to model line (Hα) profiles....
Can anybody tell me how to read a 1D fit(s) file in VB?
Now I am using the .dat files generated by ISIS, but it would be nice to be able to read the .fit.

Regards Arnold

Re: reading 1D fits files

Posted: Wed Dec 21, 2016 1:56 am
by Tim Lester
This NASA documentation will help. It is what I used to write my c# routine for reading 1D fit files in PlotSpectra.
https://fits.gsfc.nasa.gov/fits_primer.html
When it comes to reading the data block I found I had to reverse the byte order to get sensible numbers out.

Here is a link to the source code for my routine. It may help even if you are not familiar with c#.
https://1drv.ms/t/s!AvXqhKI5kEGRjEfjmBdgpWx8yX86

Tim

Re: reading 1D fits files

Posted: Wed Dec 21, 2016 6:15 pm
by Arnold de Bruin
Great Tim!
Much appreciated :-) and thanks for sharing your code. Although I will be using vb, this will certainly help!
Btw, in my program I added:
If NAXIS>1 message "not a 1D spectrum" to avoid loading a 2D fits file ;-)

Regards Arnold