Navigation Menu

Skip to content
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

Merged
merged 6 commits into from Dec 13, 2019

Conversation

AtreyeeS
Copy link
Member

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

@AtreyeeS AtreyeeS self-assigned this Dec 11, 2019
@AtreyeeS AtreyeeS added the docs label Dec 11, 2019
@AtreyeeS AtreyeeS added this to In Progress in DOCUMENTATION via automation Dec 11, 2019
@AtreyeeS AtreyeeS added this to the 1.0 milestone Dec 11, 2019
@codecov
Copy link

codecov bot commented Dec 11, 2019

Codecov Report

Merging #2684 into master will increase coverage by 0.03%.
The diff coverage is 100%.

Impacted file tree graph

@@            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
Impacted Files Coverage Δ
gammapy/cube/fit.py 89.62% <100%> (ø) ⬆️
gammapy/cube/psf_map.py 95.86% <0%> (-0.1%) ⬇️
gammapy/cube/edisp_map.py 95.65% <0%> (+0.03%) ⬆️
gammapy/utils/interpolation.py 94.73% <0%> (+0.07%) ⬆️
gammapy/cube/simulate.py 99.09% <0%> (+0.49%) ⬆️
gammapy/data/observations.py 78.92% <0%> (+0.82%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update fbe271a...1cb0453. Read the comment docs.

registerrier
registerrier previously approved these changes Dec 11, 2019
Copy link
Contributor

@registerrier registerrier left a 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.

"# 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",
Copy link
Contributor

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.

Copy link
Contributor

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 Show resolved Hide resolved
"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",
Copy link
Contributor

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

" - 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."
Copy link
Contributor

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.

"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"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

single

"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"
Copy link
Contributor

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.

"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."
Copy link
Contributor

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.

"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",
Copy link
Contributor

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()"
Copy link
Contributor

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?

Copy link
Member Author

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?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For how many points?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The default, 10 points

Copy link
Contributor

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.

" - 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",
Copy link
Contributor

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.

Copy link
Contributor

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.

Copy link
Contributor

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.

@AtreyeeS
Copy link
Member Author

AtreyeeS commented Dec 13, 2019

Thanks @registerrier for your comments. I have also made a small change in MapDatasetOnOff. Currently, MapDatasetOnOff.name is forced to acceptance_off which is quite confusing.

Copy link
Contributor

@registerrier registerrier left a 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.

@registerrier registerrier merged commit 8ac8dc7 into gammapy:master Dec 13, 2019
DOCUMENTATION automation moved this from In Progress to Done Dec 13, 2019
@adonath adonath modified the milestones: 1.0, 0.16 Jan 24, 2020
@adonath adonath changed the title Update image analysis tutorials Clean up image analysis tutorials Jan 31, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
No open projects
DOCUMENTATION
  
Done
Development

Successfully merging this pull request may close these issues.

None yet

3 participants