Skip to content

Commit

Permalink
Add Tophat spectrum class
Browse files Browse the repository at this point in the history
  • Loading branch information
joseph-long committed May 29, 2024
1 parent 919f77c commit 0cd4877
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
14 changes: 13 additions & 1 deletion doodads/modeling/spectra.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
__all__ = [
'Spectrum',
'FITSSpectrum',
'Blackbody'
'Blackbody',
'TopHat',
]

log = logging.getLogger(__name__)
Expand Down Expand Up @@ -341,3 +342,14 @@ def __init__(self, temperature, radius, distance, wavelengths=COMMON_WAVELENGTH)
flux = physics.blackbody_flux(wavelengths, temperature, radius, distance)
self.temperature = temperature
super().__init__(wavelengths, flux, name=f"B(T={temperature}, r={radius}, d={distance})")

class TopHat(Spectrum):
def __init__(self, lambda_midpoint, full_width_at_half_max):
hwhm = full_width_at_half_max / 2
cut_on, cut_off = lambda_midpoint - hwhm, lambda_midpoint + hwhm
eps = 0.001 * full_width_at_half_max
super().__init__(
[cut_on - eps, cut_on, cut_off, cut_off + eps] * u.um,
np.array([0.0, 1.0, 1.0, 0.0]),
name=r"$\lambda_\text{eff}$ = " + f"{lambda_midpoint}," + "$\Delta \lambda$ = " + f"{full_width_at_half_max} (FWHM)"
)
1 change: 1 addition & 0 deletions doodads/ref/magaox.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

__all__ = [
'CAMSCI1_FILTERS',
'CAMSCI2_FILTERS',
'H_ALPHA',
]

Expand Down

0 comments on commit 0cd4877

Please sign in to comment.