FITS functions
Functions for reading .FITS files.
- spookyspec.fits.fits_to_np(spec)
Convert from fits to numpy
Convert a file from fits format to two numpy arrays.
- Parameters:
spec (str) – path to .fits file containing data
- Returns:
wavelength points flux (np.array): flux points
- Return type:
lambda (np.array)
- spookyspec.fits.get_image_data(filename, order)
Get an order from a multispec fits file
Get the information from a single order in a fits file containing multiple orders of data (e.g. from an echelle spectrograph)
- Parameters:
filename (str) – Path to the .fits file containing the data
order (int) – echelle order to pull data from
- Returns
l (np.array): wavelength points f (np.array): flux points
- spookyspec.fits.read_psg(filename, col)
Read PSG-style output
Read a spectrum output from the Planetary Spectrum Generator (psg.gsfc.nasa.gov)
- Parameters:
filename (str) – path to the file containing the data
col (str) – column the rad file to read
- spookyspec.fits.read_two_column(filename)
Read a two column spectrum
Read a two column file. pandas with the python regex parsing engine is used so that the read in is ‘smart’ i.e. you don’t have to worry about whitespace so long as the file is whitespace delimited. This function also stores the fits header. That portion of the code was written by Beth Klein.
- Args
filename (str): path to file containing data
- Returns
args (2-tuple of type np.array): arguments of the Spec class kwargs (dict): keyword arguments of the Spec class
- Example
Use the lambda flux format as follows:
Header ... END 920.00003 6.58511E+09 920.00472 6.58510E+09 920.00942 6.58509E+09 920.01411 6.58507E+09 ...