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
Clean up image analysis tutorials #2684
Conversation
Codecov Report
@@ Coverage Diff @@
## master #2684 +/- ##
==========================================
+ Coverage 91.62% 91.66% +0.03%
==========================================
Files 142 142
Lines 15934 15972 +38
==========================================
+ Hits 14600 14640 +40
+ Misses 1334 1332 -2
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @AtreyeeS !
I have left a few inline comments to improve a bit the presentation.
tutorials/ring_background.ipynb
Outdated
"# Ring Background Estimation\n", | ||
"\n", | ||
"## Context:\n", | ||
"Classically, image analysis in IACT have often relied on the ring background model to get a background estimate. This method typically involves extracting a ring around a trial source position to estimate the background strength. To correct for the varying camera acceptance within the field of view, an acceptance correction function is used to compute the normalisation for each position of the ring. To read more about this method, see [here.](https://arxiv.org/abs/astro-ph/0610959)\n", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could explain more precisely that when you want to produce a map you have to account for the large residual hadronic background to create an excess map, assumed to be a map go gamma-ray events. In the absence of a solid template bkg model it is not possible to obtain reliable background model a priori. It was often found necessary in classical cherenkov astronomy to perform a local renormalization of the existing templates, usually with a ring kernel. This assumes that most of the events are background and requires to have an exclusion mask to remove regions with bright signal from the estimation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then you can give an objective:
Create an excess (gamma-ray events) map of MSH 15-52 as well as a significance map to determine how solid the signal is.
tutorials/ring_background.ipynb
Outdated
"The analysis workflow is roughly\n", | ||
" - Compute the sky maps keeping each observation separately using the `Analysis` class\n", | ||
" - Estimate the background using the `RingBackgroundMaker`\n", | ||
" - Compute significance and excess maps using `compute_lima_on_off_image`\n", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here it is a 'correlated excess map', but that might be too jargon
tutorials/ring_background.ipynb
Outdated
" - Estimate the background using the `RingBackgroundMaker`\n", | ||
" - Compute significance and excess maps using `compute_lima_on_off_image`\n", | ||
" \n", | ||
"The Li&Ma images thus computed can be used for normal modelling and fitting." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not really. Only the normalized background can.
tutorials/ring_background.ipynb
Outdated
"metadata": {}, | ||
"source": [ | ||
"### Create a stacked dataset\n", | ||
"Now, we extract the background for each dataset and then stack the maps together to create a sinngle stacked map for further analysis" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
single
tutorials/ring_background.ipynb
Outdated
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"This `stacked_on_off` has `on` and `off` counts and acceptance maps which we will use in all further analysis" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you should explain what acceptance_on
and acceptance_off
stand for.
tutorials/ring_background.ipynb
Outdated
"metadata": {}, | ||
"source": [ | ||
"## Compute Li&Ma maps\n", | ||
"We need to convolve our maps with an apprpriate smoothing kernel. Since astropy convolution kernels only accept integers, we first convert our required size in degrees to int depending on our pixel size." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Those are not Li&Ma maps but correlated excess and significance map.
The former is the integrated excess in circles of a given size, while the latter gives the significance of this excess. This significance is computed according to the Li & Ma expression for ON and OFF Poisson measurements and refer to the stat doc.
tutorials/ring_background.ipynb
Outdated
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"It is often important to look at the signficance distribution outside the exclusion region to understand if the exclusion regions were properly estimated.\n", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
to check that the background estimation is not contaminated by gamma-ray events. This can be the case when exclusion regions are not large enough.
"outputs": [], | ||
"source": [ | ||
"# To see the best fit values along with the errors\n", | ||
"analysis.fit_result.parameters.to_table()" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about showing more here. For instance computing and plotting position error contours for the source position? Does it slow down the notebook a lot?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On my machine, adding a call to analysis.fit.minos_contour
increases the execution time form 20 secs to 33 secs. Perhaps this should better reside on the models notebook?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For how many points?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The default, 10 points
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK. Then leave as is. Just mention the modeling/fitting notebook for now.
tutorials/modeling_2D.ipynb
Outdated
" - To understand how a generel modelling and fiiting works in gammapy, please refer to the [analysis_3d tutorial](analysis_3d.ipynb)\n", | ||
"\n", | ||
"## Context:\n", | ||
"Classically, images analysis in IACTs has been done using a ring background analysis. To understand how this works in gammapy, please refer to the [ring_background tutorial](ring_background.ipynb). Recently, with the availabilty of background IRFs with DL3 data, we can directly do spatial modelling in 2D. Of course, you can also extract maps using the ring background method and then use the same for modelling as described here.\n", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think you need to mention ring analysis here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The context here is that you want the determine the position and morphology of an object. To do so, you don't necessarily have to resort to a full 3D fitting but can perform a simple image fitting, in particular in an energy range where the PSF does not vary strongly or if you want to explore a possible energy dependance of the morphology.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would give the objective. Here localize a source and/or constrain its morphology.
Thanks @registerrier for your comments. I have also made a small change in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @AtreyeeS . NO more comments from my side.
This pull request cleans up the image analysis tutorials as described in #2576
I have tried to add some context à la
light_curve_flare
notebook