-
-
Notifications
You must be signed in to change notification settings - Fork 127
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
71 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import astropy.io.fits as fits | ||
from astropy.table import Table | ||
from astropy.units import Quantity, Unit | ||
from specutils.io.registers import data_loader | ||
from specutils import Spectrum1D | ||
|
||
SIXDFGS_PRIMARY_HDU_KEYWORDS = ["OBSRA", "OBSDEC", "Z", "Z_HELIO", "QUALITY"] | ||
COUNTS_PER_SECOND = Unit("counts/s", parse_strict="silent") | ||
|
||
|
||
def identify_6dfgs_tabular_fits(origin, *args, **kwargs): | ||
""" | ||
Identify if the current file is a 6dFGS file (stored as a table) | ||
""" | ||
with fits.open(args[0]) as hdulist: | ||
if len(hdulist) != 2: | ||
return False | ||
primary_hdu = hdulist[0] | ||
if primary_hdu.header["NAXIS"] != 0: | ||
return False | ||
for keyword in SIXDFGS_PRIMARY_HDU_KEYWORDS: | ||
if keyword not in primary_hdu.header: | ||
return False | ||
return True | ||
|
||
|
||
@data_loader("6dFGS-tabular", | ||
identifier=identify_6dfgs_tabular_fits,dtype=Spectrum1D, | ||
extensions=["fit", "fits"]) | ||
def sixdfgs_tabular_fits_loader(filename, **kwargs): | ||
""" | ||
Load the tabular variant of a 6dF Galaxy Survey (6dFGS) file. | ||
6dFGS used the Six-degree Field instrument on the UK Schmidt Telescope | ||
(UKST) at the Siding Spring Observatory (SSO) near Coonabarabran, | ||
Australia. Further details can be found at http://www.6dfgs.net/, or | ||
https://docs.datacentral.org.au/6dfgs/. Catalogues and spectra were | ||
produced, with the spectra being provided as both fits tables and as fits | ||
images. This loads the tabular variant of the spectra. Note that this does | ||
not include uncertainties - uncertainties are only provided in the image | ||
variants. | ||
Parameters | ||
---------- | ||
file_name: str | ||
The path to the FITS file | ||
Returns | ||
------- | ||
data: Spectrum1D | ||
The 6dF spectrum that is represented by the data in this table. | ||
""" | ||
with fits.open(filename) as hdulist: | ||
header = hdulist[0].header | ||
table = Table.read(hdulist) | ||
flux = Quantity(table["FLUX"]) | ||
wavelength = Quantity(table["WAVE"]) | ||
|
||
if flux.unit == COUNTS_PER_SECOND: | ||
flux._unit = Unit("count/s") | ||
meta = {"header": header} | ||
|
||
return Spectrum1D(flux=flux, spectral_axis=wavelength, meta=meta) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters