Correct map evaluator to avoid memory overload #3529
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.
Description
This pull request corrects the
MapEvaluator
to avoid huge memory load when working with small extension sources. This was due to the fact that the upsampled geometry was not properly cutout. To alleviate this issue and solve the code duplication issue, all the oversampling and the cutout logic is left toSpatailModel.integrate_geom
.Initially, we kept the upsampled
geom
object on theMapEvaluator
to avoid re-creating one each time a call tointegrate_geom
is made that requires oversampling the geometry. CreatingWcsGeom
does come at a cost in term of computing time.Yet for now it seems simpler to fully rely on the
SpatialModel.integrate_geom
which consistently performs oversampling downsampling and reprojection. From a CPU time benchmark where the extension of PKS 2155 is fitted with HESS DR1, the current implementation is actually (twice) faster than the previous one.A test is added that ensures that
MapEvaluator.compute_flux_spatial
yields correct result with relative accuracy of 1e-4 for varying source size. Note that this does not really test the very large memory usage. Is there a way to do so?Dear reviewer