Skip to content

Commit 49c7fd4

Browse files
committed
make it possible to initialize XraySpectrum1D without inputs
1 parent bdc5a41 commit 49c7fd4

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

specutils/spectra/xrayspectrum1d.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,14 +75,19 @@ class XraySpectrum1D(Spectrum1D):
7575
7676
rmf
7777
"""
78-
def __init__(self, bin_lo, bin_hi, bin_unit, counts, exposure,
79-
arf=None, rmf=None, rest_value=0.0 * u.angstrom, **kwargs):
78+
def __init__(self, bin_lo=None, bin_hi=None, bin_unit=None,
79+
counts=None, exposure=1.0, arf=None, rmf=None,
80+
rest_value=0.0 * u.angstrom, **kwargs):
8081
try:
8182
axis_unit = u.Unit(bin_unit)
8283
except ValueError:
8384
axis_unit = _unit_parser(bin_unit)
8485

85-
bin_mid = 0.5 * (bin_lo + bin_hi) * axis_unit
86+
if (bin_lo is not None) and (bin_hi is not None):
87+
bin_mid = 0.5 * (bin_lo + bin_hi) * axis_unit
88+
else:
89+
bin_mid = None
90+
8691
Spectrum1D.__init__(self, spectral_axis=bin_mid, flux=counts,
8792
rest_value=rest_value, **kwargs)
8893

specutils/tests/test_xrayspectrum1d.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
from astropy.modeling.powerlaws import PowerLaw1D
44
from specutils import XraySpectrum1D
55

6+
def test_init_spectrum():
7+
test = XraySpectrum1D()
8+
return
9+
610
def test_create_from_arrays():
711
# Test that XraySpectrum1D can be initialized
812
amp0, alpha0 = 3.e-3, 2.0

0 commit comments

Comments
 (0)