Skip to content

Commit

Permalink
Merge pull request #1018 from kecnry/spectrum1d-read-flux-in-counts
Browse files Browse the repository at this point in the history
support Spectrum1D reading from file with flux in counts
  • Loading branch information
pllim authored Feb 23, 2023
2 parents 8356796 + fec6908 commit 75a6cba
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion specutils/io/parsing_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ def _find_spectral_column(table, columns_to_search, spectral_axis):
u.spectral_density() equivalencies. If none meet that criterion,
look for other likely length units such as 'adu' or 'cts/s'.
"""
additional_valid_units = [u.Unit('adu'), u.Unit('ct/s')]
additional_valid_units = [u.Unit('adu'), u.Unit('ct/s'), u.Unit('count')]
found_column = None

# First, search for a column with units compatible with Janskies
Expand Down
12 changes: 12 additions & 0 deletions specutils/tests/test_spectrum1d.py
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,18 @@ def test_create_with_uncertainty():
Spectrum1D(spectral_axis=wavelengths*u.um, flux=flux, uncertainty=uncertainty)


@pytest.mark.parametrize("flux_unit", ["adu", "ct/s", "count"])
def test_flux_unit_io_roundtrip(tmp_path, flux_unit):
# regression test for https://github.com/astropy/specutils/pull/1018
fname = str(tmp_path / 'flux_unit_io_roundtrip.fits')
sp = Spectrum1D(flux=np.ones(11) * u.Unit(flux_unit),
spectral_axis=np.arange(1, 12) * u.Unit('Hz'))
sp.write(fname, overwrite=True)

sp_load = Spectrum1D.read(fname)
assert sp_load.flux.unit == sp.flux.unit


@pytest.mark.filterwarnings('ignore::astropy.io.fits.verify.VerifyWarning')
@remote_access([{'id': '1481190', 'filename': 'L5g_0355+11_Cruz09.fits'}])
def test_read_linear_solution(remote_data_path):
Expand Down

0 comments on commit 75a6cba

Please sign in to comment.