Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem when model parameters is a astropy.units.Magnitude #330

Open
jianyangli opened this issue May 3, 2022 · 0 comments
Open

Problem when model parameters is a astropy.units.Magnitude #330

jianyangli opened this issue May 3, 2022 · 0 comments
Assignees
Labels
photometry potential bug automated label to indicate issue reports

Comments

@jianyangli
Copy link
Contributor

High-level problem description

When any model parameter is an astropy.units.Magnitude type, model evaluation fails.

What did you do?

import astropy.units as u
import sbpy.units as sbu
from sbpy.photometry import HG

sbu.enable() # enable sbpy units

hg = HG(3.4 * sbu.VEGAmag, 0.12)
print(hg(30 * u.deg))

What did you expect?

Print out the value of HG phase function at 30 deg phase angle:

4.75 VEGAmag

What did really happen?

The above code snippet will throw a UnitTypeError, stating that 'Quantity instances require normal units, not <class 'astropy.units.function.logarithmic.MagUnit'> instance.'

The fundamental reason is because astropy.modleing.Model evaluates model value by assembling the parameter value and unit into an astropy.units.Quantity. But a MagUnit type cannot make a Quantity, but a Magnitude type.

This issue is reported by astropy/astropy#13133, and is current being addressed with PR astropy/astropy#13158. Once this issue is fixed in astropy, sbpy should be updated accordingly or checked to make sure this issue is also resolved.

Provide information on your environment:

operating system and version: MacOSX 10.15.7
sbpy version: '0.2.3.dev223+g9eb0523'
astropy version: '5.0.4'
numpy version: '1.22.3'

@jianyangli jianyangli added the potential bug automated label to indicate issue reports label May 3, 2022
@jianyangli jianyangli self-assigned this May 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
photometry potential bug automated label to indicate issue reports
Projects
None yet
Development

No branches or pull requests

1 participant