Remove lon wrapping in spatial models #2366
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR removes long wrapping in the
__init__
of spatial models.Currently the code wraps to lon = -180 to +180, with the intent to get correct results at lon = 0 and to avoid wrapping issues with 0 = 360, and I think because it's considered user friendly to have a "standard range" for lon and to never get e.g. lon = 181 deg or lon = 361 deg or lon = -185 deg.
I think it would be better to not wrap at all: if a user puts a starting value of lon = 200 deg, fine, it's their choice. Changing this to -160 deg in model init will be confusing for them. Also wrapping to any fixed range means fitting a source at the edge of that range will be problematic, because the lon value is jumping by 360 deg. So with the current implementation one cannot fit a source at or near 180 deg. Not wrapping avoids this issue.
As discussed offline with @adonath and @QRemy a week or two ago, in the future we might want to add logic to the source fitting to avoid sources leaving the sky map to get more user-friendly behaviour, i.e. the optimiser finding a source position more often. But "inside a sky map" does not correspond to a simple min/max limit on lon, we'll have to implement this in a different way (and that can be Gammapy v2.0, not urgent at all, Fermi ST or other codes don't have that).
@adonath - While working on this I noticed one possible issue with
SkyPointSource
evaluation, I'll open a separate issue for that.