Gaiana / nirdust

Nirdust is a python package that uses K-band (2.2 micrometers) spectra to measure the temperature of the dust heated by a type 2 Active Galactic Nuclei (AGN) accretion disk.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Use Astropy API to create a Fittable1DModel

mchalela opened this issue · comments

Change custom_model to Fittable1DModel to allow parallelization.

nirdust/nirdust.py

Lines 46 to 77 in 76d8591

@custom_model
def normalized_blackbody(nu, T=None):
"""Normalize blackbody model.
The equation for calculating the blackbody model is the same as in
the Astropy blackbody model except that the "scale" parameter is
eliminated, i.e. is allways equal to 1.
The normalization is performed by dividing the blackbody flux by its
numerical mean.
Parameters
----------
nu: SpectralAxis object
Frequency axis in units of Hz.
T: float, default is None
Temperature of the blackbody.
Returns
-------
out: normalized blackbody model.
"""
cv = c.value
kv = k_B.value
hv = h.value
bb = 2 * hv * nu ** 3 / (cv ** 2 * (np.exp(hv * nu / (kv * T)) - 1))
mean = np.mean(bb)
return bb / mean