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 acceptance curve smoothing method #510

Merged
merged 5 commits into from Apr 17, 2016

Conversation

Projects
None yet
3 participants
@JouvinLea
Contributor

JouvinLea commented Apr 13, 2016

I added the smoothing for the bkg model

Lea Jouvin
Show outdated Hide outdated gammapy/background/models.py Outdated
Show outdated Hide outdated gammapy/background/models.py Outdated
Show outdated Hide outdated gammapy/background/models.py Outdated
if str(ngroup) in self.models3D.keys():
self.models3D[str(ngroup)].smooth()
else:
log.info("No run in the band {}".format(ngroup))

This comment has been minimized.

@cdeil

cdeil Apr 13, 2016

Member

"band" -> "group"
(we can discuss re-naming in the future, but for now let's be consistent and use "group" everywhere.

@cdeil

cdeil Apr 13, 2016

Member

"band" -> "group"
(we can discuss re-naming in the future, but for now let's be consistent and use "group" everywhere.

if str(ngroup) in self.models2D.keys():
self.models2D[str(ngroup)].smooth()
else:
log.info("No run in the band {}".format(ngroup))

This comment has been minimized.

@cdeil

cdeil Apr 13, 2016

Member

Same here: "band" -> "group"

@cdeil

cdeil Apr 13, 2016

Member

Same here: "band" -> "group"

Show outdated Hide outdated gammapy/background/models.py Outdated
@@ -198,17 +198,17 @@ def filename(self, modeltype, group_id, smooth=False):
else:
return 'background_{}_group_{:03d}_table.fits.gz'.format(modeltype, group_id)
def save_model(self, modeltype, ngroup):
def save_model(self, modeltype, ngroup, smooth=False):

This comment has been minimized.

@cdeil

cdeil Apr 13, 2016

Member

I'm not sure it's a good idea to change the filename depending on smooth / no-smooth.

This class will get feature-richer, there will be different ways to smooth the model.
Probably filename management should be left up to the user in those cases?
(but leave as-is if you like for now)

@cdeil

cdeil Apr 13, 2016

Member

I'm not sure it's a good idea to change the filename depending on smooth / no-smooth.

This class will get feature-richer, there will be different ways to smooth the model.
Probably filename management should be left up to the user in those cases?
(but leave as-is if you like for now)

def smooth(self):
"""Smooth the bkg rate with a gaussian 1D kernel.

This comment has been minimized.

@cdeil

cdeil Apr 13, 2016

Member

Maybe add some more info to the docstring. I don't mean a full description of the algorithm, but something like:

Calling this method modifies the ``bg_rate`` data member, replacing it with a smoothed version.

and

This method uses an adaptive Poisson method to compute the smoothing Kernel width
from the available counts (see code and inline comments for details).
@cdeil

cdeil Apr 13, 2016

Member

Maybe add some more info to the docstring. I don't mean a full description of the algorithm, but something like:

Calling this method modifies the ``bg_rate`` data member, replacing it with a smoothed version.

and

This method uses an adaptive Poisson method to compute the smoothing Kernel width
from the available counts (see code and inline comments for details).

@cdeil cdeil added the feature label Apr 13, 2016

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

@cdeil cdeil self-assigned this Apr 13, 2016

@cdeil

This comment has been minimized.

Show comment
Hide comment
@cdeil

cdeil Apr 13, 2016

Member

@JouvinLea - I've done a review. Nothing major, I hope the suggestion to factor out the 1D smoothing algorithm in a separate function was clear).
Once those comments are addressed, this is ready to merge.

Member

cdeil commented Apr 13, 2016

@JouvinLea - I've done a review. Nothing major, I hope the suggestion to factor out the 1D smoothing algorithm in a separate function was clear).
Once those comments are addressed, this is ready to merge.

@cdeil cdeil changed the title from add smooth to Add acceptance curve smoothing method Apr 13, 2016

Show outdated Hide outdated gammapy/background/models.py Outdated
Show outdated Hide outdated gammapy/background/models.py Outdated
@JouvinLea

This comment has been minimized.

Show comment
Hide comment
@JouvinLea

JouvinLea Apr 17, 2016

Contributor

@cdeil
I think I took all you comments in to account, what do you think now?

Contributor

JouvinLea commented Apr 17, 2016

@cdeil
I think I took all you comments in to account, what do you think now?

@cdeil

This comment has been minimized.

Show comment
Hide comment
@cdeil

cdeil Apr 17, 2016

Member

Merging now.

Thank you!

Member

cdeil commented Apr 17, 2016

Merging now.

Thank you!

@cdeil cdeil merged commit 30816c5 into gammapy:master Apr 17, 2016

0 of 2 checks passed

continuous-integration/appveyor/pr Waiting for AppVeyor build to complete
Details
continuous-integration/travis-ci/pr The Travis CI build is in progress
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment