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

Implement .fake() methods on datasets #2298

Merged
merged 4 commits into from Jul 22, 2019
Merged

Conversation

@JouvinLea
Copy link

@JouvinLea JouvinLea commented Jul 18, 2019

extend the feature fake that was existing for SpectrumDataset to simulate ON counts from Npred.
Add the method for SpectrumDatasetOnOFF simulated also the OFF and for MapDataset

@JouvinLea JouvinLea requested a review from registerrier Jul 18, 2019
Copy link
Contributor

@registerrier registerrier left a comment

Thanks @JouvinLea. Some inline comments

@@ -180,6 +179,20 @@ def likelihood(self):

return stat

def fake(self, random_state="random-seed"):
"""Simulate fake data for the counts from a Poisson Law of mean value = N predicted counts in each energy pixel.
Erase the counts data and replace them by the simulated one.
Copy link
Contributor

@registerrier registerrier Jul 18, 2019

simulated ones

@@ -180,6 +179,20 @@ def likelihood(self):

return stat

def fake(self, random_state="random-seed"):
"""Simulate fake data for the counts from a Poisson Law of mean value = N predicted counts in each energy pixel.
Copy link
Contributor

@registerrier registerrier Jul 18, 2019

Simulate fake counts for the current model and reduced irfs.
Not useful to mention predicted counts if one does not know how they are predicted.

@@ -135,23 +135,18 @@ def residuals(self):
return self._as_counts_spectrum(residuals)

def fake(self, random_state="random-seed"):
"""Simulate a fake `~gammapy.spectrum.CountsSpectrum`.
"""Simulate fake data for the counts from a Poisson Law of mean value = N predicted counts in each energy bin.
Copy link
Contributor

@registerrier registerrier Jul 18, 2019

Same comments here.

@@ -343,6 +338,23 @@ def likelihood_per_bin(self):
)
return np.nan_to_num(on_stat_)

def fake(self, random_state="random-seed"):
"""Simulate fake data for the counts from a Poisson Law of mean value = N predicted counts in each energy bin.
Copy link
Contributor

@registerrier registerrier Jul 18, 2019

Same comments. Simplify

def fake(self, random_state="random-seed"):
"""Simulate fake data for the counts from a Poisson Law of mean value = N predicted counts in each energy bin.
Simulate fake data for the background from a Poisson Law of mean value = N background counts in each energy bin.
Erase the counts and background data and replace them by the simulated one.
Copy link
Contributor

@registerrier registerrier Jul 18, 2019

Erase countsand offdata. Requires to set background attribute.

gammapy/spectrum/dataset.py Show resolved Hide resolved
gammapy/spectrum/dataset.py Show resolved Hide resolved
@cdeil cdeil added the feature label Jul 18, 2019
@cdeil cdeil added this to the 0.13 milestone Jul 18, 2019
@cdeil cdeil changed the title Fake Dataset Add fake method to Dataset Jul 19, 2019
@JouvinLea
Copy link
Author

@JouvinLea JouvinLea commented Jul 19, 2019

@registerrier
Apparently it doesn't like that we define the method fake for the SpetrumDatasetOnOFF with an argument background_model that override the method fake of the parents class SpetrumDataset.

@adonath
Copy link
Member

@adonath adonath commented Jul 19, 2019

@JouvinLea Let's ignore codacy for now...

@JouvinLea
Copy link
Author

@JouvinLea JouvinLea commented Jul 19, 2019

Cool!!

@JouvinLea
Copy link
Author

@JouvinLea JouvinLea commented Jul 22, 2019

@registerrier ok to merge ?

@adonath
Copy link
Member

@adonath adonath commented Jul 22, 2019

@JouvinLea I just noticed there is a merge conflict in gammapy/spectrum/tests/test_dataset.py, can you resolve it or should I?

@JouvinLea
Copy link
Author

@JouvinLea JouvinLea commented Jul 22, 2019

@adonath it should be fixed now. All my PR are touching the same files so those merge conflict will happen after each merging...
I also notices that the members backscale was changed to acceptance in the SpectrumDatasetOnOFf class but the docs is not updated. do you want me to change it in this PR?

@adonath
Copy link
Member

@adonath adonath commented Jul 22, 2019

Thanks @JouvinLea! No don't change in this PR, I'll clean this up later if needed...

@adonath
Copy link
Member

@adonath adonath commented Jul 22, 2019

Thanks @JouvinLea! I''ll merge this PR now and do a little clean up in a second PR...

@adonath adonath merged commit 36c9496 into gammapy:master Jul 22, 2019
8 of 9 checks passed
@adonath adonath changed the title Add fake method to Dataset Implement .fake() methods on datasets Jul 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

4 participants