We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
PiecewiseNormSpatialModel
I came across this problem in #5082
Create PiecewiseNormSpatialModel
from gammapy.maps import WcsGeom, MapCoord import astropy.units as u geom = WcsGeom.create(skydir=(0, 0), npix=(2, 2), binsz=0.3, frame="galactic") coords = MapCoord.create(geom.footprint) coords["lon"] *= u.deg coords["lat"] *= u.deg model = PiecewiseNormSpatialModel(coords, frame="galactic") model.to_dict()
Out[104]: {'spatial': {'type': 'PiecewiseNormSpatialModel', 'frame': 'galactic', 'parameters': [{'name': 'norm_0', 'value': 1.0}, {'name': 'norm_1', 'value': 1.0}, {'name': 'norm_2', 'value': 1.0}, {'name': 'norm_3', 'value': 1.0}], 'lon': {'data': [0.15, 0.15, -0.14999999999997726, -0.14999999999997726], 'unit': 'deg'}, 'lat': {'data': [-0.15, 0.15, 0.15, -0.15], 'unit': 'deg'}}}
Creating a new instance from the dict changes the lon values:
PiecewiseNormSpatialModel.from_dict(model.to_dict()).to_dict()
{'spatial': {'type': 'PiecewiseNormSpatialModel', 'frame': 'galactic', 'parameters': [{'name': 'norm_0', 'value': 1.0}, {'name': 'norm_1', 'value': 1.0}, {'name': 'norm_2', 'value': 1.0}, {'name': 'norm_3', 'value': 1.0}], 'lon': {'data': [-359.85, -359.85, -0.14999999999997726, -0.14999999999997726], 'unit': 'deg'}, 'lat': {'data': [-0.15, 0.15, 0.15, -0.15], 'unit': 'deg'}}}
This is because of the wrapping of the Angle in the init of the class
gammapy/gammapy/modeling/models/spatial.py
Lines 1668 to 1673 in 90459a5
But: Why are the lon values not getting wrapped in the creation of the first model above?
The text was updated successfully, but these errors were encountered:
QRemy
Successfully merging a pull request may close this issue.
I came across this problem in #5082
Example
Create
PiecewiseNormSpatialModel
Creating a new instance from the dict changes the lon values:
This is because of the wrapping of the Angle in the init of the class
gammapy/gammapy/modeling/models/spatial.py
Lines 1668 to 1673 in 90459a5
But: Why are the lon values not getting wrapped in the creation of the first model above?
The text was updated successfully, but these errors were encountered: