While LinearPolarization can be initialized with floats, StokesPolarization forces you to use a function:
from astromodels import Constant, StokesPolarization, LinearPolarization
# This fails (TypeError: 0.5 is not of type Node)
# StokesPolarization(Q = .5, U = .5)
# This works
qpar = Constant()
qpar.k = .5
upar = Constant()
upar.k = .5
StokesPolarization(Q = qpar, U = upar)
# This works!
LinearPolarization(degree = .5, angle = 10)
# Also works
pd = Constant()
pd.k = .5
pa = Constant()
pa.k = 10
LinearPolarization(degree = pd, angle = pa)
For convenience, I think StokesPolarization should also have a condition to handle a single floating point number, like here:
|
if callable(degree): |
|
self.degree = LinearParameter("degree", degree) |
|
else: |
|
self.degree = self._get_parameter_from_input( |
|
degree, |
|
0, |
|
100, |
|
"degree", |
|
"Polarization degree", |
|
"dimensionless_unscaled", |
|
) |
|
|
|
if callable(angle): |
|
self.angle = LinearParameter("angle", angle) |
|
else: |
|
self.angle = self._get_parameter_from_input( |
|
angle, 0, 180, "angle", "Polarization angle", "deg" |
|
) |
While
LinearPolarizationcan be initialized with floats,StokesPolarizationforces you to use a function:For convenience, I think StokesPolarization should also have a condition to handle a single floating point number, like here:
astromodels/astromodels/core/polarization.py
Lines 93 to 110 in 5a10f08