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

Add exposure image computation #511

Merged
merged 20 commits into from Apr 18, 2016

Conversation

Projects
None yet
2 participants
@JouvinLea
Contributor

JouvinLea commented Apr 14, 2016

I added the computation of the exposure for the images.
For the moment I define it in two ways make_exposure_one_obs() and make_exposure_one_obs2(). I wanted to discuss with you which is the best.
I also added the excess images.

  1. for make_exposure_one_obs(), excess/exposure will give the integrated flux over the energy range used to compute the images.

  2. for make_exposure_one_obs2(), excess/exposure will give the differential flux at the center of the energy_range used to compute the images.

We think the best is to use the integrated flux but maybe you have some ideas about that?

Show outdated Hide outdated gammapy/scripts/image_pipe.py Outdated
Show outdated Hide outdated gammapy/scripts/image_pipe.py Outdated

@cdeil cdeil changed the title from Exposure to Exposure image computation Apr 14, 2016

@cdeil

This comment has been minimized.

Show comment
Hide comment
@cdeil

cdeil Apr 14, 2016

Member

@JouvinLea - Thanks for working on this!

I discussed this with @adonath ... we want the exposure to be computed so that

differential flux = excess / exposure

(because it's slightly simpler and also that's how it's done in HAP / the HESS survey).

An alternative option to implement exposure images would be to always first compute an exposure cube
http://docs.gammapy.org/en/latest/api/gammapy.cube.exposure_cube.html

and then use this method to compute the integral exposure:
http://docs.gammapy.org/en/latest/api/gammapy.cube.SpectralCube.html?highlight=spectralcube#gammapy.cube.SpectralCube.integral_flux_image
It should be generalised a bit and renames energy_integral_power_law_weighted or something.

If you want to do this I can explain how in detail.
If you want to continue with what you have here, that's OK as well for now, but please leave a TODO comment that this could / should be re-implemented using the exposure_cube function and the spectral_cube.integral_flux_image method.

Member

cdeil commented Apr 14, 2016

@JouvinLea - Thanks for working on this!

I discussed this with @adonath ... we want the exposure to be computed so that

differential flux = excess / exposure

(because it's slightly simpler and also that's how it's done in HAP / the HESS survey).

An alternative option to implement exposure images would be to always first compute an exposure cube
http://docs.gammapy.org/en/latest/api/gammapy.cube.exposure_cube.html

and then use this method to compute the integral exposure:
http://docs.gammapy.org/en/latest/api/gammapy.cube.SpectralCube.html?highlight=spectralcube#gammapy.cube.SpectralCube.integral_flux_image
It should be generalised a bit and renames energy_integral_power_law_weighted or something.

If you want to do this I can explain how in detail.
If you want to continue with what you have here, that's OK as well for now, but please leave a TODO comment that this could / should be re-implemented using the exposure_cube function and the spectral_cube.integral_flux_image method.

@cdeil cdeil added the feature label Apr 14, 2016

@cdeil cdeil added this to the 0.4 milestone Apr 14, 2016

@cdeil cdeil self-assigned this Apr 14, 2016

Show outdated Hide outdated gammapy/utils/energy.py Outdated
@JouvinLea

This comment has been minimized.

Show comment
Hide comment
@JouvinLea

JouvinLea Apr 15, 2016

Contributor

@cdeil
Hi,
thanks for your suggestion! I will not have the time to re-implement it with the spectral cube for now so this is ok for you I prefer leave it as it is and add a todo comment.
I'm not sure about the exposure but maybe I can name one of the method make_exposure() and the other one make_exposure_power_law_weighted() ? Like this the user can choose what he wants?

I though that it was easier to cut the energy range of the map in linear energy bins since this is only there to compute the integral. You are not agree?

Contributor

JouvinLea commented Apr 15, 2016

@cdeil
Hi,
thanks for your suggestion! I will not have the time to re-implement it with the spectral cube for now so this is ok for you I prefer leave it as it is and add a todo comment.
I'm not sure about the exposure but maybe I can name one of the method make_exposure() and the other one make_exposure_power_law_weighted() ? Like this the user can choose what he wants?

I though that it was easier to cut the energy range of the map in linear energy bins since this is only there to compute the integral. You are not agree?

@cdeil

This comment has been minimized.

Show comment
Hide comment
@cdeil

cdeil Apr 15, 2016

Member

thanks for your suggestion! I will not have the time to re-implement it with the spectral cube for now so this is ok for you I prefer leave it as it is and add a todo comment.

OK

I'm not sure about the exposure but maybe I can name one of the method make_exposure() and the other one make_exposure_power_law_weighted() ? Like this the user can choose what he wants?

You pick names!
(the ones I was suggesting were for the more general SpectralCube class, here just make_exposure is OK, no?)

I though that it was easier to cut the energy range of the map in linear energy bins since this is only there to compute the integral. You are not agree?

Both linear and log equal-width energy bins give the same result for very fine binning.
For a given number of bins, equal-log binning is usually always better, because then quantities are more constant in gamma-ray astronomy within the bins.

But there's several places where equal-log integrals are implemented already.
If this is roughly working for now, OK to leave as-is.
(will be changed to use the equal-log binning integration in SpectralCube.integral_flux_image at some point anyways)

Let me know if you have any further questions or when this is ready to be merged.

Member

cdeil commented Apr 15, 2016

thanks for your suggestion! I will not have the time to re-implement it with the spectral cube for now so this is ok for you I prefer leave it as it is and add a todo comment.

OK

I'm not sure about the exposure but maybe I can name one of the method make_exposure() and the other one make_exposure_power_law_weighted() ? Like this the user can choose what he wants?

You pick names!
(the ones I was suggesting were for the more general SpectralCube class, here just make_exposure is OK, no?)

I though that it was easier to cut the energy range of the map in linear energy bins since this is only there to compute the integral. You are not agree?

Both linear and log equal-width energy bins give the same result for very fine binning.
For a given number of bins, equal-log binning is usually always better, because then quantities are more constant in gamma-ray astronomy within the bins.

But there's several places where equal-log integrals are implemented already.
If this is roughly working for now, OK to leave as-is.
(will be changed to use the equal-log binning integration in SpectralCube.integral_flux_image at some point anyways)

Let me know if you have any further questions or when this is ready to be merged.

@JouvinLea

This comment has been minimized.

Show comment
Hide comment
@JouvinLea

JouvinLea Apr 16, 2016

Contributor

ok let’s go this because I don’t really have the time to work a lot on this!!
ok for make exposure that will give the differential flux when you do excess/exposure.
But may be we can live the one that give the integrated flux if you do excess/exposure and by giving it another name? but I don’t have an idea for the name? and maybe let the user choose what he prefers ?
Le 15 avr. 2016 à 20:57, Christoph Deil notifications@github.com a écrit :

thanks for your suggestion! I will not have the time to re-implement it with the spectral cube for now so this is ok for you I prefer leave it as it is and add a todo comment.

OK

I'm not sure about the exposure but maybe I can name one of the method make_exposure() and the other one make_exposure_power_law_weighted() ? Like this the user can choose what he wants?

You pick names!
(the ones I was suggesting were for the more general SpectralCube class, here just make_exposure is OK, no?)

I though that it was easier to cut the energy range of the map in linear energy bins since this is only there to compute the integral. You are not agree?

Both linear and log equal-width energy bins give the same result for very fine binning.
For a given number of bins, equal-log binning is usually always better, because then quantities are more constant in gamma-ray astronomy within the bins.

But there's several places where equal-log integrals are implemented already.
If this is roughly working for now, OK to leave as-is.
(will be changed to use the equal-log binning integration in SpectralCube.integral_flux_image at some point anyways)

Let me know if you have any further questions or when this is ready to be merged.


You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub

Contributor

JouvinLea commented Apr 16, 2016

ok let’s go this because I don’t really have the time to work a lot on this!!
ok for make exposure that will give the differential flux when you do excess/exposure.
But may be we can live the one that give the integrated flux if you do excess/exposure and by giving it another name? but I don’t have an idea for the name? and maybe let the user choose what he prefers ?
Le 15 avr. 2016 à 20:57, Christoph Deil notifications@github.com a écrit :

thanks for your suggestion! I will not have the time to re-implement it with the spectral cube for now so this is ok for you I prefer leave it as it is and add a todo comment.

OK

I'm not sure about the exposure but maybe I can name one of the method make_exposure() and the other one make_exposure_power_law_weighted() ? Like this the user can choose what he wants?

You pick names!
(the ones I was suggesting were for the more general SpectralCube class, here just make_exposure is OK, no?)

I though that it was easier to cut the energy range of the map in linear energy bins since this is only there to compute the integral. You are not agree?

Both linear and log equal-width energy bins give the same result for very fine binning.
For a given number of bins, equal-log binning is usually always better, because then quantities are more constant in gamma-ray astronomy within the bins.

But there's several places where equal-log integrals are implemented already.
If this is roughly working for now, OK to leave as-is.
(will be changed to use the equal-log binning integration in SpectralCube.integral_flux_image at some point anyways)

Let me know if you have any further questions or when this is ready to be merged.


You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub

@JouvinLea

This comment has been minimized.

Show comment
Hide comment
@JouvinLea

JouvinLea Apr 16, 2016

Contributor

Maybe we can call it make_exposure_weighted_spectrum the one that will give the integrated flux ?

Le 16 avr. 2016 à 18:53, Lea Jouvin ljouvin@apc.in2p3.fr a écrit :

ok let’s go this because I don’t really have the time to work a lot on this!!
ok for make exposure that will give the differential flux when you do excess/exposure.
But may be we can live the one that give the integrated flux if you do excess/exposure and by giving it another name? but I don’t have an idea for the name? and maybe let the user choose what he prefers ?
Le 15 avr. 2016 à 20:57, Christoph Deil notifications@github.com a écrit :

thanks for your suggestion! I will not have the time to re-implement it with the spectral cube for now so this is ok for you I prefer leave it as it is and add a todo comment.

OK

I'm not sure about the exposure but maybe I can name one of the method make_exposure() and the other one make_exposure_power_law_weighted() ? Like this the user can choose what he wants?

You pick names!
(the ones I was suggesting were for the more general SpectralCube class, here just make_exposure is OK, no?)

I though that it was easier to cut the energy range of the map in linear energy bins since this is only there to compute the integral. You are not agree?

Both linear and log equal-width energy bins give the same result for very fine binning.
For a given number of bins, equal-log binning is usually always better, because then quantities are more constant in gamma-ray astronomy within the bins.

But there's several places where equal-log integrals are implemented already.
If this is roughly working for now, OK to leave as-is.
(will be changed to use the equal-log binning integration in SpectralCube.integral_flux_image at some point anyways)

Let me know if you have any further questions or when this is ready to be merged.


You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub

Contributor

JouvinLea commented Apr 16, 2016

Maybe we can call it make_exposure_weighted_spectrum the one that will give the integrated flux ?

Le 16 avr. 2016 à 18:53, Lea Jouvin ljouvin@apc.in2p3.fr a écrit :

ok let’s go this because I don’t really have the time to work a lot on this!!
ok for make exposure that will give the differential flux when you do excess/exposure.
But may be we can live the one that give the integrated flux if you do excess/exposure and by giving it another name? but I don’t have an idea for the name? and maybe let the user choose what he prefers ?
Le 15 avr. 2016 à 20:57, Christoph Deil notifications@github.com a écrit :

thanks for your suggestion! I will not have the time to re-implement it with the spectral cube for now so this is ok for you I prefer leave it as it is and add a todo comment.

OK

I'm not sure about the exposure but maybe I can name one of the method make_exposure() and the other one make_exposure_power_law_weighted() ? Like this the user can choose what he wants?

You pick names!
(the ones I was suggesting were for the more general SpectralCube class, here just make_exposure is OK, no?)

I though that it was easier to cut the energy range of the map in linear energy bins since this is only there to compute the integral. You are not agree?

Both linear and log equal-width energy bins give the same result for very fine binning.
For a given number of bins, equal-log binning is usually always better, because then quantities are more constant in gamma-ray astronomy within the bins.

But there's several places where equal-log integrals are implemented already.
If this is roughly working for now, OK to leave as-is.
(will be changed to use the equal-log binning integration in SpectralCube.integral_flux_image at some point anyways)

Let me know if you have any further questions or when this is ready to be merged.


You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub

@cdeil

This comment has been minimized.

Show comment
Hide comment
@cdeil

cdeil Apr 16, 2016

Member

ok let’s go this

You mean I should merge now.
Or did you still want to make edits here?

The name isn't so important for now.

Member

cdeil commented Apr 16, 2016

ok let’s go this

You mean I should merge now.
Or did you still want to make edits here?

The name isn't so important for now.

@JouvinLea

This comment has been minimized.

Show comment
Hide comment
@JouvinLea

JouvinLea Apr 16, 2016

Contributor

no I will make some edit before you merge!
Le 16 avr. 2016 à 19:14, Christoph Deil notifications@github.com a écrit :

ok let’s go this

You mean I should merge now.
Or did you still want to make edits here?

The name isn't so important for now.


You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub

Contributor

JouvinLea commented Apr 16, 2016

no I will make some edit before you merge!
Le 16 avr. 2016 à 19:14, Christoph Deil notifications@github.com a écrit :

ok let’s go this

You mean I should merge now.
Or did you still want to make edits here?

The name isn't so important for now.


You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub

Lea Jouvin added some commits Apr 16, 2016

Show outdated Hide outdated gammapy/scripts/image_pipe.py Outdated
Show outdated Hide outdated gammapy/scripts/image_pipe.py Outdated
Show outdated Hide outdated gammapy/scripts/image_pipe.py Outdated
Lea Jouvin
@@ -16,6 +20,16 @@
class ImageAnalysis(object):
"""Gammapy 2D image based analysis.
Fill a `~gammapy.image.SkyMapCollection`:

This comment has been minimized.

@JouvinLea

JouvinLea Apr 16, 2016

Contributor

is it what you want?
How to have new line between each maps description in the docstring?

@JouvinLea

JouvinLea Apr 16, 2016

Contributor

is it what you want?
How to have new line between each maps description in the docstring?

This comment has been minimized.

@cdeil

cdeil Apr 16, 2016

Member

Yes, this is what I wanted.

You have to put bullets and an empty line before the first bullet for Sphinx to render it correctly.

Like this:

Fill a `~gammapy.image.SkyMapCollection`:

* counts : counts for one obs
* bkg : bkg model for one obs
@cdeil

cdeil Apr 16, 2016

Member

Yes, this is what I wanted.

You have to put bullets and an empty line before the first bullet for Sphinx to render it correctly.

Like this:

Fill a `~gammapy.image.SkyMapCollection`:

* counts : counts for one obs
* bkg : bkg model for one obs

Lea Jouvin added some commits Apr 16, 2016

Lea Jouvin
Lea Jouvin
Lea Jouvin
Show outdated Hide outdated gammapy/scripts/image_pipe.py Outdated
Show outdated Hide outdated gammapy/scripts/image_pipe.py Outdated
Show outdated Hide outdated gammapy/scripts/image_pipe.py Outdated
Show outdated Hide outdated gammapy/scripts/image_pipe.py Outdated

Lea Jouvin added some commits Apr 17, 2016

Show outdated Hide outdated gammapy/scripts/image_pipe.py Outdated
Lea Jouvin
Show outdated Hide outdated gammapy/scripts/image_pipe.py Outdated
Show outdated Hide outdated gammapy/scripts/image_pipe.py Outdated

Lea Jouvin added some commits Apr 17, 2016

Lea Jouvin
Lea Jouvin
ok
Lea Jouvin
Show outdated Hide outdated gammapy/scripts/image_pipe.py Outdated
Show outdated Hide outdated gammapy/scripts/image_pipe.py Outdated
Show outdated Hide outdated gammapy/scripts/image_pipe.py Outdated
Show outdated Hide outdated gammapy/scripts/image_pipe.py Outdated
@cdeil

This comment has been minimized.

Show comment
Hide comment
@cdeil

cdeil Apr 17, 2016

Member

I'm offline now.
Please leave another comment when this is ready and I'll merge tomorrow.

Member

cdeil commented Apr 17, 2016

I'm offline now.
Please leave another comment when this is ready and I'll merge tomorrow.

Lea Jouvin
self.maps["total_excess"].data = excess
def make_exposure(self, obs_id, spectral_index=2.3, for_integral_flux=False):
r"""Compute the exposure map for one observation.

This comment has been minimized.

@JouvinLea

JouvinLea Apr 17, 2016

Contributor

the r doesn't solve the problem for the docstring...

@JouvinLea

JouvinLea Apr 17, 2016

Contributor

the r doesn't solve the problem for the docstring...

@@ -3,7 +3,11 @@
unicode_literals)
import logging
import numpy as np
from scipy import interpolate

This comment has been minimized.

@cdeil

cdeil Apr 18, 2016

Member

Imports of optional dependencies like scipy need to be put in the function or method where it's used.
Build fail: https://travis-ci.org/gammapy/gammapy/jobs/123775918#L1428

@cdeil

cdeil Apr 18, 2016

Member

Imports of optional dependencies like scipy need to be put in the function or method where it's used.
Build fail: https://travis-ci.org/gammapy/gammapy/jobs/123775918#L1428

@cdeil cdeil merged commit bf9efe4 into gammapy:master Apr 18, 2016

1 of 2 checks passed

continuous-integration/travis-ci/pr The Travis CI build failed
Details
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
@cdeil

This comment has been minimized.

Show comment
Hide comment
@cdeil

cdeil Apr 18, 2016

Member

I fixed the scipy import and the exposure docstring in 5637902 and merged this PR.
The issue was extra spaces between :math: and the following backtick.

Thanks!

Member

cdeil commented Apr 18, 2016

I fixed the scipy import and the exposure docstring in 5637902 and merged this PR.
The issue was extra spaces between :math: and the following backtick.

Thanks!

@cdeil cdeil changed the title from Exposure image computation to Add exposure image computation Apr 20, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment