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 1D spectrum analysis tool based on gammapy.hspec #359

Merged
merged 15 commits into from Sep 30, 2015

Conversation

Projects
None yet
2 participants
@joleroi
Contributor

joleroi commented Sep 23, 2015

This PR introduces the GammapySpectrumObservation and GammapySpectrumAnalysis classes that are the basis for the command line tool gammapy-spectrum-pipe. This tool performs a basic 1D spectral analysis using a ring in the FoV to estimated the background contamination

Missing functionality

  • tests are not possible because data handling is based on ~gammapy.obs.DataStore for which also no tests are implemented
  • Reflected regions
@cdeil

This comment has been minimized.

Show comment
Hide comment
@cdeil

cdeil Sep 23, 2015

Member

I think your code will simplify quite a bit and be more re-usable from other scripts / algorithms if you introduce separate functions (and maybe even a class) to represent one observation and do the processing per observation.

Maybe something like this?

class GammapySpectrumObservation:
    event list data member
    count data member and method to compute it
    effective area data member and method to compute it
    energy resolution data member and method to compute it

and then your analysis class only does the batch observation processing / book-keeping:

class GammaSpectrumAnalysis:
    def process_observations
        for obs in self.observations:
            obs.process()

For the fitting from Sherpa I don't know yet how it works ... I haven't looked at how it's done by hspec.
But at least for computing PHA, ARF, RMFs I'd recommend the approach mentioned above.

Member

cdeil commented Sep 23, 2015

I think your code will simplify quite a bit and be more re-usable from other scripts / algorithms if you introduce separate functions (and maybe even a class) to represent one observation and do the processing per observation.

Maybe something like this?

class GammapySpectrumObservation:
    event list data member
    count data member and method to compute it
    effective area data member and method to compute it
    energy resolution data member and method to compute it

and then your analysis class only does the batch observation processing / book-keeping:

class GammaSpectrumAnalysis:
    def process_observations
        for obs in self.observations:
            obs.process()

For the fitting from Sherpa I don't know yet how it works ... I haven't looked at how it's done by hspec.
But at least for computing PHA, ARF, RMFs I'd recommend the approach mentioned above.

@joleroi

This comment has been minimized.

Show comment
Hide comment
@joleroi

joleroi Sep 24, 2015

Contributor

I absolutely agree, thank you!

Contributor

joleroi commented Sep 24, 2015

I absolutely agree, thank you!

@joleroi

This comment has been minimized.

Show comment
Hide comment
@joleroi

joleroi Sep 28, 2015

Contributor

updated, please have a look

Contributor

joleroi commented Sep 28, 2015

updated, please have a look

Show outdated Hide outdated gammapy/scripts/spectrum_pipe.py Outdated
@cdeil

This comment has been minimized.

Show comment
Hide comment
@cdeil

cdeil Sep 28, 2015

Member

This looks good!

Can you make --help print something useful?
One option would be to replace this old docs page (https://gammapy.readthedocs.org/en/latest/tutorials/gammapy-pfspec/index.html) with an example showing how to use this script, and link to the online URL from the --help text?

Member

cdeil commented Sep 28, 2015

This looks good!

Can you make --help print something useful?
One option would be to replace this old docs page (https://gammapy.readthedocs.org/en/latest/tutorials/gammapy-pfspec/index.html) with an example showing how to use this script, and link to the online URL from the --help text?

@cdeil cdeil added the feature label Sep 29, 2015

@cdeil cdeil added this to the 0.4 milestone Sep 29, 2015

@cdeil cdeil assigned cdeil and joleroi and unassigned cdeil Sep 29, 2015

Show outdated Hide outdated gammapy/scripts/spectrum_pipe.py Outdated
Show outdated Hide outdated gammapy/scripts/spectrum_pipe.py Outdated
@cdeil

This comment has been minimized.

Show comment
Hide comment
@cdeil

cdeil Sep 29, 2015

Member

Please run autopep8 on the new gammapy/scripts/spectrum_pipe.py before committing the file.

Member

cdeil commented Sep 29, 2015

Please run autopep8 on the new gammapy/scripts/spectrum_pipe.py before committing the file.

@joleroi

This comment has been minimized.

Show comment
Hide comment
@joleroi

joleroi Sep 29, 2015

Contributor

Hi I applied most of your comments, I would like to do the rest in the separate PR, like

  • edit --help output and write example page
  • implement ring background
  • Write alpha keyword correctly

Of course I have to fix the build error here :(

Contributor

joleroi commented Sep 29, 2015

Hi I applied most of your comments, I would like to do the rest in the separate PR, like

  • edit --help output and write example page
  • implement ring background
  • Write alpha keyword correctly

Of course I have to fix the build error here :(

@joleroi

This comment has been minimized.

Show comment
Hide comment
@joleroi

joleroi Sep 30, 2015

Contributor

There is one (allowed) test failure. If there are no objections I am going to merge this, and continue in another PR

Contributor

joleroi commented Sep 30, 2015

There is one (allowed) test failure. If there are no objections I am going to merge this, and continue in another PR

@cdeil

This comment has been minimized.

Show comment
Hide comment
@cdeil

cdeil Sep 30, 2015

Member

👍

Can you please change the title of the PR to be a bit more descriptive (e.g. "Add 1D spectrum analysis tool") and add a changelog entry yourself?

Member

cdeil commented Sep 30, 2015

👍

Can you please change the title of the PR to be a bit more descriptive (e.g. "Add 1D spectrum analysis tool") and add a changelog entry yourself?

@cdeil

This comment has been minimized.

Show comment
Hide comment
@cdeil

cdeil Sep 30, 2015

Member

It would also be nice if you edit the issue description at the top to contain a short description of what this PR does ... makes it easy to understand what's what in the future.

Member

cdeil commented Sep 30, 2015

It would also be nice if you edit the issue description at the top to contain a short description of what this PR does ... makes it easy to understand what's what in the future.

@joleroi joleroi changed the title from WIP: Spectrum pipe to Add 1D spectrum analysis tool Sep 30, 2015

@joleroi joleroi changed the title from Add 1D spectrum analysis tool to Add 1D spectrum analysis tool based on gammapy.hspec Sep 30, 2015

joleroi pushed a commit that referenced this pull request Sep 30, 2015

Merge pull request #359 from kingj90/spectrum_pipe
Add 1D spectrum analysis tool based on gammapy.hspec

@joleroi joleroi merged commit 41d6c8e into gammapy:master Sep 30, 2015

1 check passed

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

@joleroi joleroi deleted the joleroi:spectrum_pipe branch Sep 30, 2015

@cdeil

This comment has been minimized.

Show comment
Hide comment
@cdeil

cdeil Sep 30, 2015

Member

🆒

Member

cdeil commented Sep 30, 2015

🆒

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