diff --git a/CHANGES.rst b/CHANGES.rst index f5bc53d4..54d36046 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -14,6 +14,17 @@ sbpy.photometry - Added Rubin Observatory's LSSTCam filter set to `bandpass()`. [#431] +Bug Fixes +--------- + +sbpy.spectroscopy +^^^^^^^^^^^^^^^^^ + +- Avoid deprecation warning on flux_unit and wave_unit keyword arguments in + `sbpy.spectroscopy.sources.SpectralSource.from_file` when using synphot's + read_fits_spec. [#447] + + v0.6.0 (2025-12-02) =================== diff --git a/sbpy/spectroscopy/sources.py b/sbpy/spectroscopy/sources.py index d17ec662..fd2d3463 100644 --- a/sbpy/spectroscopy/sources.py +++ b/sbpy/spectroscopy/sources.py @@ -137,11 +137,18 @@ def from_file(cls, filename, wave_unit=None, flux_unit=None, # URL cache because synphot.SourceSpectrum.from_file does not if _is_url(filename): - fn = download_file(filename, cache=True) + fn = download_file(filename, cache=cache) else: fn = filename - spec = read_spec(fn, wave_unit=wave_unit, flux_unit=flux_unit) + # flux_unit and wave_unit were deprecated for FITS files in synphot 1.4; + # only use them if requested + read_kwargs = {} + if wave_unit is not None: + read_kwargs["wave_unit"] = wave_unit + read_kwargs["flux_unit"] = flux_unit + + spec = read_spec(fn, **read_kwargs) i = np.isfinite(spec[1] * spec[2]) source = synphot.SourceSpectrum( synphot.Empirical1D, points=spec[1][i], lookup_table=spec[2][i],