Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
Remove lon wrapping in spatial models #2366
This PR removes long wrapping in the
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
This did break the GC point source analysis in the tutorial:
So probably it's simplest to first tackle point source evaluate (see #2367) and to only merge this PR if that works without lon wrapping (or by only wrapping after taking the diff).
@adonath - this should be ready to merge.
I had to change
and then in
For now this change to use