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 example script for cube background models #338

Merged
merged 19 commits into from Sep 3, 2015

Conversation

Projects
None yet
2 participants
@mapazarr
Member

mapazarr commented Aug 25, 2015

The script uses the same model (except for absolute normalization) to produce a true cube bg model and a reco cube bg model. The models can be used to test the cube bg model production and can be compared to each other using the plot_bg_cube_model_comparison.py example script.

@mapazarr

This comment has been minimized.

Show comment
Hide comment
@mapazarr

mapazarr Aug 25, 2015

Member

Und noch einen Kaffee! :-)
Mergen?

Member

mapazarr commented Aug 25, 2015

Und noch einen Kaffee! :-)
Mergen?

@cdeil

This comment has been minimized.

Show comment
Hide comment
@cdeil

cdeil Aug 26, 2015

Member

@mapazarr – Thanks for adding this!

As with your other recent PRs I'm OK with merging this without much review, but still I'd like to do some review to avoid accumulating more and more technical debt in Gammapy, i.e. things that need to be reviewed / tested / cleaned up later.

Member

cdeil commented Aug 26, 2015

@mapazarr – Thanks for adding this!

As with your other recent PRs I'm OK with merging this without much review, but still I'd like to do some review to avoid accumulating more and more technical debt in Gammapy, i.e. things that need to be reviewed / tested / cleaned up later.

@cdeil cdeil added the feature label Aug 26, 2015

@cdeil cdeil added this to the 0.4 milestone Aug 26, 2015

@cdeil cdeil self-assigned this Aug 26, 2015

@cdeil cdeil changed the title from Added example script to produce true and reco bg cube model. to Add example script to produce true and reco bg cube model Aug 26, 2015

@cdeil

This comment has been minimized.

Show comment
Hide comment
@cdeil

cdeil Aug 26, 2015

Member

Please don't use minus - in Python file names, use underscore _ instead.

Member

cdeil commented Aug 26, 2015

Please don't use minus - in Python file names, use underscore _ instead.

Show outdated Hide outdated gammapy/background/cube.py Outdated
Show outdated Hide outdated gammapy/datasets/make.py Outdated
"""Integral of the cube images (`~astropy.units.Quantity`)
Calculate the integral of each energy bin (slice) in the
cube. Returns an array of integrals.

This comment has been minimized.

@cdeil

cdeil Aug 26, 2015

Member

Again, from the method name and docstring it's not obvious to me what this does.

It looks to me like this is computing a 1-dim npred array for each energy bin?

@cdeil

cdeil Aug 26, 2015

Member

Again, from the method name and docstring it's not obvious to me what this does.

It looks to me like this is computing a 1-dim npred array for each energy bin?

This comment has been minimized.

@mapazarr

mapazarr Sep 3, 2015

Member

Done (similar to the previous one).

@mapazarr

mapazarr Sep 3, 2015

Member

Done (similar to the previous one).

Show outdated Hide outdated gammapy/datasets/make.py Outdated
Show outdated Hide outdated gammapy/datasets/make.py Outdated
Show outdated Hide outdated gammapy/datasets/make.py Outdated
Show outdated Hide outdated gammapy/datasets/make.py Outdated
Show outdated Hide outdated CHANGES.rst Outdated
@cdeil

This comment has been minimized.

Show comment
Hide comment
@cdeil

cdeil Aug 27, 2015

Member

@mapazarr – There's a merge conflict (probably in the changelog) now that #337 is merged. Please rebase against master.

Member

cdeil commented Aug 27, 2015

@mapazarr – There's a merge conflict (probably in the changelog) now that #337 is merged. Please rebase against master.

@mapazarr mapazarr referenced this pull request Sep 3, 2015

Closed

Improve cube bg model production #333

1 of 20 tasks complete
@mapazarr

This comment has been minimized.

Show comment
Hide comment
@mapazarr

mapazarr Sep 3, 2015

Member

Ok, now true and reco are very similar:
https://hess-confluence.desy.de/confluence/display/HESS/HESS+Open+Source+Tools+-+HOWTO+create+cube+background+models+using+Gammapy#HESSOpenSourceTools-HOWTOcreatecubebackgroundmodelsusingGammapy-Comparisontrue/reco

bg_cube_model_comparison_group27_sim_improved_true_method

I'm not sure if we still need to investigate the differences. @cdeil what is your opinion?

For me, I think I have reached my goal in this PR: have similar true/reco models. I will implement the comments from the code review tomorrow.

Member

mapazarr commented Sep 3, 2015

Ok, now true and reco are very similar:
https://hess-confluence.desy.de/confluence/display/HESS/HESS+Open+Source+Tools+-+HOWTO+create+cube+background+models+using+Gammapy#HESSOpenSourceTools-HOWTOcreatecubebackgroundmodelsusingGammapy-Comparisontrue/reco

bg_cube_model_comparison_group27_sim_improved_true_method

I'm not sure if we still need to investigate the differences. @cdeil what is your opinion?

For me, I think I have reached my goal in this PR: have similar true/reco models. I will implement the comments from the code review tomorrow.

@mapazarr

This comment has been minimized.

Show comment
Hide comment
@mapazarr

mapazarr Sep 3, 2015

Member

@cdeil there seems to be some incompatibility issues between numpy 1.6 or 1.7 and astropy in the travis-ci allowed failure jobs.

I killed the jobs, because they were stuck and taking forever: > 25 min.

Member

mapazarr commented Sep 3, 2015

@cdeil there seems to be some incompatibility issues between numpy 1.6 or 1.7 and astropy in the travis-ci allowed failure jobs.

I killed the jobs, because they were stuck and taking forever: > 25 min.

@cdeil

This comment has been minimized.

Show comment
Hide comment
@cdeil

cdeil Sep 3, 2015

Member

I think the best is to finish this PR this week and leave the investigation of the remaining differences true / reco to the future. IMO this is just task number 21 😄 in #333 ... I'll try to work on that myself in the coming months or get a student.

Member

cdeil commented Sep 3, 2015

I think the best is to finish this PR this week and leave the investigation of the remaining differences true / reco to the future. IMO this is just task number 21 😄 in #333 ... I'll try to work on that myself in the coming months or get a student.

@cdeil

This comment has been minimized.

Show comment
Hide comment
@cdeil

cdeil Sep 3, 2015

Member

@cdeil there seems to be some incompatibility issues between numpy 1.6 or 1.7 and astropy in the travis-ci allowed failure jobs.

I'm short on time this week, my suggestion would be to just ignore this.
(or file a separate issue if you like.)

Member

cdeil commented Sep 3, 2015

@cdeil there seems to be some incompatibility issues between numpy 1.6 or 1.7 and astropy in the travis-ci allowed failure jobs.

I'm short on time this week, my suggestion would be to just ignore this.
(or file a separate issue if you like.)

@mapazarr

This comment has been minimized.

Show comment
Hide comment
@mapazarr

mapazarr Sep 3, 2015

Member

This takes care that MeV units will be used for the bg rates per default. There is though a flag to avoid this if desired (turned off per default).

Member

mapazarr commented on gammapy/background/cube.py in e0a3b68 Sep 3, 2015

This takes care that MeV units will be used for the bg rates per default. There is though a flag to avoid this if desired (turned off per default).

This comment has been minimized.

Show comment
Hide comment
@cdeil

cdeil Sep 3, 2015

Member

This seems like a random location to force units to a default.
Shouldn't this happen at the time of object construction or read / write?

Member

cdeil replied Sep 3, 2015

This seems like a random location to force units to a default.
Shouldn't this happen at the time of object construction or read / write?

This comment has been minimized.

Show comment
Hide comment
@mapazarr

mapazarr Sep 3, 2015

Member

It is not random: this is the function where the bg cube gets its bg rate units, and is called each time a cube is created.
If we put it in read or write, the cube might still be using other units in the meanwhile. I think read should read the cube as it is in the file, and write should only write, not interpret the results.

But now that you mention it, this is not the right place, since this function is inside the generic Cube container class, and we don't want to force MeV for all cubes, right? I'll move the units forcing to the make_bg_cube_model function.

Member

mapazarr replied Sep 3, 2015

It is not random: this is the function where the bg cube gets its bg rate units, and is called each time a cube is created.
If we put it in read or write, the cube might still be using other units in the meanwhile. I think read should read the cube as it is in the file, and write should only write, not interpret the results.

But now that you mention it, this is not the right place, since this function is inside the generic Cube container class, and we don't want to force MeV for all cubes, right? I'll move the units forcing to the make_bg_cube_model function.

Show outdated Hide outdated gammapy/background/cube.py Outdated
@@ -12,7 +12,7 @@
]
def make_bg_cube_model(observation_table, fits_path, method='default'):
def make_bg_cube_model(observation_table, fits_path, method='default', do_not_force_mev_units=False):

This comment has been minimized.

@mapazarr

mapazarr Sep 3, 2015

Member

OK, I moved the enforcing of the units here. This seems the right place, since it is the function that creates the cubes.

@mapazarr

mapazarr Sep 3, 2015

Member

OK, I moved the enforcing of the units here. This seems the right place, since it is the function that creates the cubes.

Show outdated Hide outdated gammapy/background/make.py Outdated
@cdeil

This comment has been minimized.

Show comment
Hide comment
@cdeil

cdeil Sep 3, 2015

Member

@mapazarr – I'm going to bed in 10 min. Do you have any question here or are you all set?

Feel free to merge if you think this is ready or let me know if you want me to have another look tomorrow morning ...

Member

cdeil commented Sep 3, 2015

@mapazarr – I'm going to bed in 10 min. Do you have any question here or are you all set?

Feel free to merge if you think this is ready or let me know if you want me to have another look tomorrow morning ...

@mapazarr

This comment has been minimized.

Show comment
Hide comment
@mapazarr

mapazarr Sep 3, 2015

Member

Ok, I addressed all comments, and travis-ci is green, so I'm merging this now.

Member

mapazarr commented Sep 3, 2015

Ok, I addressed all comments, and travis-ci is green, so I'm merging this now.

mapazarr added a commit that referenced this pull request Sep 3, 2015

Merge pull request #338 from mapazarr/plots_for_last_gsoc_post
Add example script to produce true and reco bg cube model

@mapazarr mapazarr merged commit a8acc4a into gammapy:master Sep 3, 2015

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
@mapazarr

This comment has been minimized.

Show comment
Hide comment
@mapazarr

mapazarr Sep 6, 2015

Member

@cdeil I forgot one last thing. I'd like to add the plot comparing true/reco:

bg_cube_model_comparison_group27_sim_improved_true_method

to the high-level docs, at the end of:

http://gammapy.readthedocs.org/en/latest/background/make_models.html#datasets-for-testing

I think it would help illustrate the capabilities of bg cube production. The file is 260 kB; is it ok, or is it too big?

Member

mapazarr commented Sep 6, 2015

@cdeil I forgot one last thing. I'd like to add the plot comparing true/reco:

bg_cube_model_comparison_group27_sim_improved_true_method

to the high-level docs, at the end of:

http://gammapy.readthedocs.org/en/latest/background/make_models.html#datasets-for-testing

I think it would help illustrate the capabilities of bg cube production. The file is 260 kB; is it ok, or is it too big?

@cdeil

This comment has been minimized.

Show comment
Hide comment
@cdeil

cdeil Sep 6, 2015

Member

@mapazarr – That is a nice Figure and it would be good to have in the docs.

But indeed, I'd prefer to keep the gammapy repo small and to have all example datasets and images such as this one in gammapy-extra. So please put this on the list of things to do for background modeling.

If you like, you can already put the image here for now:
https://github.com/gammapy/gammapy-extra/tree/master/figures
and then we'll properly include it in the Sphinx build later, when gammapy-extra is integrated better.

Member

cdeil commented Sep 6, 2015

@mapazarr – That is a nice Figure and it would be good to have in the docs.

But indeed, I'd prefer to keep the gammapy repo small and to have all example datasets and images such as this one in gammapy-extra. So please put this on the list of things to do for background modeling.

If you like, you can already put the image here for now:
https://github.com/gammapy/gammapy-extra/tree/master/figures
and then we'll properly include it in the Sphinx build later, when gammapy-extra is integrated better.

@mapazarr

This comment has been minimized.

Show comment
Hide comment
@mapazarr

mapazarr Sep 7, 2015

Member

Ok, adressing the figure issue in #347.

Member

mapazarr commented Sep 7, 2015

Ok, adressing the figure issue in #347.

@cdeil cdeil changed the title from Add example script to produce true and reco bg cube model to Add example script to produce cube background models Sep 16, 2015

@cdeil cdeil changed the title from Add example script to produce cube background models to Add example script for cube background models Sep 16, 2015

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