[AstroPy] Blackbody plus power law fitting

Derek Homeier derek at astro.physik.uni-goettingen.de
Mon Apr 19 11:08:28 EDT 2021


On 19 Apr 2021, at 3:40 pm, Rudolf Baer <rbaer25 at gmail.com> wrote:
> 
> model_1 = models.PowerLaw1D([1, 1, 1])

This seems to be a typo? This would define a PowerLaw1D with a list (or array-like) as amplitude
and should already raise a ValueError unless your input `x` happened to have shape (3, ) as well.
To define a model with amplitude=1, x_0=1, alpha=1, use PowerLaw1D(1, 1, 1) (or just the defaults… ;-)

> model_2 = models.BlackBody(1800*u.K,5)
> model_1_2=model_1+model_2
> print(model_1_2)
> 
> x and y are the input data (x: lambda, y: flux) given without units. By definition the blackbody temperature is in Kelvin. This leads to  a Unit conversion error in the combined model. Do I have a basic mistake in the code or what is the solution. Any help would be much appreciated.
> 
The error arises from the fact that a BlackBody() model always returns flux density as a Quantity
(by default in `u/Unit('erg / (cm2 Hz s sr)’)`), thus you need to define the PowerLaw1D with `amplitude`
also as a Quantity in compatible units (e.g. the above, or  'Jy / sr', or 'W / (m2 * micron * sr)' if you set
the BlackBody `scale` parameter to a F_lambda unit as well or enable `spectral_density` equivalencies).

HTH
						Derek



More information about the AstroPy mailing list