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 printout for 3FGL catalog objects #898

Merged
merged 9 commits into from Feb 23, 2017

Conversation

Projects
None yet
2 participants
@vorugantia
Contributor

vorugantia commented Feb 20, 2017

In this PR, I'm simply adding lines to the __str__ method to print more data from SourceCatalogObject3FGL.data neatly.

@cdeil - This PR acts as my first minor contribution to Gammapy. Are there any additions/edits that should be made to the method?

@cdeil cdeil self-assigned this Feb 20, 2017

@cdeil cdeil added the feature label Feb 20, 2017

@cdeil cdeil added this to the 0.6 milestone Feb 20, 2017

@cdeil

This comment has been minimized.

Show comment
Hide comment
@cdeil

cdeil Feb 20, 2017

Member

@vorugantia - Thanks!
It would be great to have more info available!

I tried if for one source, and currently you have this:

>>> from gammapy.catalog import SourceCatalog3FGL
>>> cat = SourceCatalog3FGL()
>>> source = cat['3FGL J0534.5+2201']
>>> print(source)
Source : 3FGL J0534.5+2201 
Assoc  : PSR J0534+2200            
Class  : PSR  

RA (J2000)  : 83.63719940185547
Dec (J2000) : 22.024099349975586
GLON        : 184.5518035888672
GLAT        : -5.775753974914551

Semimajor      : 0.007215708959847689
Semiminor      : 0.006969018839299679
Rotation angle : 89.83000183105469

Energy flux (100 MeV - 100 GeV) : 1.4717778107353752e-09 +- 1.0623095285378081e-11 erg cm^-2 s^-1
Detection significance          : 30.669872283935547
Spectral index                  : 2.045008659362793 +- 0.010912163183093071

So there's a few things that can be improved here:

  • print units, like "deg" for RA / DEC
  • print "section headings", like "Basic information", "Position information", "Spectrum information", ...
  • use string formatters to limit the number of digits shown to something sensible. E.g. you could have something like
ss += '{:<20s} : {:.3f} deg\n'.format('Position Error (68%)', d['Pos_Err_68'])

The way you can implement this is to do

from pprint import pprint
pprint(source.data)

for 3FGL and then to simply go top to bottom with the available fields, adding them to your __str__, splitting it up into sub-methods that you call from __str__ if you find that it grows too long to fit on the screen.

It's simpler to just do that and print all numbers than to discuss which number to show in which order. One thing you could omit for now is the spectral point info (what you get via source.flux_points.table.pprint() or the light curve info (what you get via source.lightcurve.pprint(). We might add those, but then their nice string representation would be implemented in the FluxPoints and LightCurve class and you'd just call ``ss += str(source.flux_points) + '\n'andss += str(source.lightcurve) + '\n' from here.

Once that's done, paste an example output here, and I'll give advice on possibly grouping information in a better way, or printing with less / more digits.

I know this is a bit tedious, but I think it might even be useful to you, to learn what all the information given in the Fermi catalog is. There's a good summary for each field at
http://heasarc.gsfc.nasa.gov/W3Browse/fermi/fermilpsc.html
and when in doubt, consult the paper PDF linked to from
https://fermi.gsfc.nasa.gov/ssc/data/access/lat/4yr_catalog/
or ask me.

For testing, you need to have a quick debug cycle.
How do you do it at the moment?
One thing you could do is make a file test_3fgl_str.py at the top-level of your repo (where the setup.py is located) with

from gammapy.catalog import SourceCatalog3FGL
cat = SourceCatalog3FGL()
source = cat['3FGL J0534.5+2201']
print(source)

and then to have the edit & save & test cycle by running:

python test_3fgl_str.py

You might have to run

python setup.py build_ext --inplace

once to make it work, i.e. that importing the local version from the source folder works.

Member

cdeil commented Feb 20, 2017

@vorugantia - Thanks!
It would be great to have more info available!

I tried if for one source, and currently you have this:

>>> from gammapy.catalog import SourceCatalog3FGL
>>> cat = SourceCatalog3FGL()
>>> source = cat['3FGL J0534.5+2201']
>>> print(source)
Source : 3FGL J0534.5+2201 
Assoc  : PSR J0534+2200            
Class  : PSR  

RA (J2000)  : 83.63719940185547
Dec (J2000) : 22.024099349975586
GLON        : 184.5518035888672
GLAT        : -5.775753974914551

Semimajor      : 0.007215708959847689
Semiminor      : 0.006969018839299679
Rotation angle : 89.83000183105469

Energy flux (100 MeV - 100 GeV) : 1.4717778107353752e-09 +- 1.0623095285378081e-11 erg cm^-2 s^-1
Detection significance          : 30.669872283935547
Spectral index                  : 2.045008659362793 +- 0.010912163183093071

So there's a few things that can be improved here:

  • print units, like "deg" for RA / DEC
  • print "section headings", like "Basic information", "Position information", "Spectrum information", ...
  • use string formatters to limit the number of digits shown to something sensible. E.g. you could have something like
ss += '{:<20s} : {:.3f} deg\n'.format('Position Error (68%)', d['Pos_Err_68'])

The way you can implement this is to do

from pprint import pprint
pprint(source.data)

for 3FGL and then to simply go top to bottom with the available fields, adding them to your __str__, splitting it up into sub-methods that you call from __str__ if you find that it grows too long to fit on the screen.

It's simpler to just do that and print all numbers than to discuss which number to show in which order. One thing you could omit for now is the spectral point info (what you get via source.flux_points.table.pprint() or the light curve info (what you get via source.lightcurve.pprint(). We might add those, but then their nice string representation would be implemented in the FluxPoints and LightCurve class and you'd just call ``ss += str(source.flux_points) + '\n'andss += str(source.lightcurve) + '\n' from here.

Once that's done, paste an example output here, and I'll give advice on possibly grouping information in a better way, or printing with less / more digits.

I know this is a bit tedious, but I think it might even be useful to you, to learn what all the information given in the Fermi catalog is. There's a good summary for each field at
http://heasarc.gsfc.nasa.gov/W3Browse/fermi/fermilpsc.html
and when in doubt, consult the paper PDF linked to from
https://fermi.gsfc.nasa.gov/ssc/data/access/lat/4yr_catalog/
or ask me.

For testing, you need to have a quick debug cycle.
How do you do it at the moment?
One thing you could do is make a file test_3fgl_str.py at the top-level of your repo (where the setup.py is located) with

from gammapy.catalog import SourceCatalog3FGL
cat = SourceCatalog3FGL()
source = cat['3FGL J0534.5+2201']
print(source)

and then to have the edit & save & test cycle by running:

python test_3fgl_str.py

You might have to run

python setup.py build_ext --inplace

once to make it work, i.e. that importing the local version from the source folder works.

@vorugantia

This comment has been minimized.

Show comment
Hide comment
@vorugantia

vorugantia Feb 21, 2017

Contributor

@cdeil I'm now testing my code the way you suggested. I liked the way you organized the info for the HGPS catalog so I used the same format. Here is the output:

$ python test_3fgl_str.py

*** Basic info ***

Source                         : 3FGL J0534.5+2201
Catalog row index (zero-based) : 621
Extended name                  :
Associations                   : PSR J0534+2200, Crab, Crab Pulsar, 1AGL J0535+2205, EGR J0534+2159
Other names                    : 0FGL J0534.6+2201, 1FGL J0534.5+2200, 2FGL J0534.5+2201, 1FHL J0534.5+2201
Class                          : PSR

*** Position info ***

RA (J2000)           : 83.637 deg
Dec (J2000)          : 22.024 deg
GLON                 : 184.552 deg
GLAT                 : -5.776 deg
ROI number           : 191

*** Extension info ***

Semimajor (68%)      : 0.0072 deg
Semiminor (68%)      : 0.0070 deg
Position angle (68%) : 89.83 deg
Semimajor (95%)      : 0.0117 deg
Semiminor (95%)      : 0.0113 deg
Position angle (95%) : 89.83 deg

*** Spectral info ***

Energy flux            : 1.47e-09 +- 1.06e-11 erg cm^-2 s^-1 (100 MeV - 100 GeV)
Detection significance : 30.670 Sigma (100 MeV - 300 GeV)
Spectral index         : 2.045 +- 0.011
Pivot energy           : 636 MeV
Flux Density           : 5.541301861811121e-10 +- 2.6707379797291653e-12 phot cm^-2 MeV^-1 s^-1 (100 MeV - 100 GeV)
Integral flux          : 1.57e-07 +- 1.08e-09 phot cm^-2 s^-1 (1 - 100 GeV)
Significance curvature : 15.8
Spectrum type          : PLExpCutoff
Cutoff energy          : 8143 +- 442 MeV
Power law index        : 2.226

*** Other info (omitted) ***

Flux<energy range>
Unc_Flux<energy range>
nuFnu<energy range>
Sqrt_TS<energy range>
Variability_Index
Flux_Peak
Unc_Flux_Prak
Time_Peak
Peak_Interval
Flux_History
Unc_Flux_History
TEVCAT_FLAG
Flags

Here is what I'm uncertain about, if you would like to check them:

  • Some item labels may need to be changed, e.g. "Flux density" - the 3FGL PDF paper says this is just differential flux at the pivot energy, so should I change the label to that?

  • I don't think I'm missing any units but you can check. As for the energy ranges in parentheses, would you like them before or after the values? (Currently they come after the values)

  • Do I need less/more digits anywhere? (I just realized I forgot to shorten "Flux density")

  • Do I need to change the order of the values anywhere?

  • Some items under spectral info may need to be omitted, but I'm not sure.

  • I grouped together all the "ASSOC" names and other names, is that okay?

  • See the "Other info" category for things I omitted. Should any of those be included?

Contributor

vorugantia commented Feb 21, 2017

@cdeil I'm now testing my code the way you suggested. I liked the way you organized the info for the HGPS catalog so I used the same format. Here is the output:

$ python test_3fgl_str.py

*** Basic info ***

Source                         : 3FGL J0534.5+2201
Catalog row index (zero-based) : 621
Extended name                  :
Associations                   : PSR J0534+2200, Crab, Crab Pulsar, 1AGL J0535+2205, EGR J0534+2159
Other names                    : 0FGL J0534.6+2201, 1FGL J0534.5+2200, 2FGL J0534.5+2201, 1FHL J0534.5+2201
Class                          : PSR

*** Position info ***

RA (J2000)           : 83.637 deg
Dec (J2000)          : 22.024 deg
GLON                 : 184.552 deg
GLAT                 : -5.776 deg
ROI number           : 191

*** Extension info ***

Semimajor (68%)      : 0.0072 deg
Semiminor (68%)      : 0.0070 deg
Position angle (68%) : 89.83 deg
Semimajor (95%)      : 0.0117 deg
Semiminor (95%)      : 0.0113 deg
Position angle (95%) : 89.83 deg

*** Spectral info ***

Energy flux            : 1.47e-09 +- 1.06e-11 erg cm^-2 s^-1 (100 MeV - 100 GeV)
Detection significance : 30.670 Sigma (100 MeV - 300 GeV)
Spectral index         : 2.045 +- 0.011
Pivot energy           : 636 MeV
Flux Density           : 5.541301861811121e-10 +- 2.6707379797291653e-12 phot cm^-2 MeV^-1 s^-1 (100 MeV - 100 GeV)
Integral flux          : 1.57e-07 +- 1.08e-09 phot cm^-2 s^-1 (1 - 100 GeV)
Significance curvature : 15.8
Spectrum type          : PLExpCutoff
Cutoff energy          : 8143 +- 442 MeV
Power law index        : 2.226

*** Other info (omitted) ***

Flux<energy range>
Unc_Flux<energy range>
nuFnu<energy range>
Sqrt_TS<energy range>
Variability_Index
Flux_Peak
Unc_Flux_Prak
Time_Peak
Peak_Interval
Flux_History
Unc_Flux_History
TEVCAT_FLAG
Flags

Here is what I'm uncertain about, if you would like to check them:

  • Some item labels may need to be changed, e.g. "Flux density" - the 3FGL PDF paper says this is just differential flux at the pivot energy, so should I change the label to that?

  • I don't think I'm missing any units but you can check. As for the energy ranges in parentheses, would you like them before or after the values? (Currently they come after the values)

  • Do I need less/more digits anywhere? (I just realized I forgot to shorten "Flux density")

  • Do I need to change the order of the values anywhere?

  • Some items under spectral info may need to be omitted, but I'm not sure.

  • I grouped together all the "ASSOC" names and other names, is that okay?

  • See the "Other info" category for things I omitted. Should any of those be included?

@cdeil

This comment has been minimized.

Show comment
Hide comment
@cdeil

cdeil Feb 21, 2017

Member

@vorugantia - Just some quick comments, I'll have a closer look tomorrow.

  • there's a merge conflict here. Can you please resolve it?
  • what you have under "other info", yes, I would suggest to print that as well. For now you could just do "key: value", at least for the scalar values. (spectral points and lightcurve we might do separately or at the end)
  • this is a point source catalog. so rename "extension info" here to "position error info" or just put this in the position info section. the ellipse parameter given are position error ellipse parameters, not source extension
  • for the fluxes and flux density, I do think it would be more readable if the energy point / range is given at the front, like Diff. flux (@ 1 TeV) = or something like that.
  • Personally I don't like the "phot", you can just remove it.
  • Give the spectrum type more towards the start of the spectrum section?
Member

cdeil commented Feb 21, 2017

@vorugantia - Just some quick comments, I'll have a closer look tomorrow.

  • there's a merge conflict here. Can you please resolve it?
  • what you have under "other info", yes, I would suggest to print that as well. For now you could just do "key: value", at least for the scalar values. (spectral points and lightcurve we might do separately or at the end)
  • this is a point source catalog. so rename "extension info" here to "position error info" or just put this in the position info section. the ellipse parameter given are position error ellipse parameters, not source extension
  • for the fluxes and flux density, I do think it would be more readable if the energy point / range is given at the front, like Diff. flux (@ 1 TeV) = or something like that.
  • Personally I don't like the "phot", you can just remove it.
  • Give the spectrum type more towards the start of the spectrum section?
@vorugantia

This comment has been minimized.

Show comment
Hide comment
@vorugantia

vorugantia Feb 22, 2017

Contributor

@cdeil - All of your most recent comments have been taken care of, except printing the Flux_History and Unc_Flux_History. Before making another table, I wanted to make sure the first table looks fine to you (see output below).

New output:

$ python test_3fgl_str.py

*** Basic info ***

Source                         : 3FGL J0534.5+2201
Catalog row index (zero-based) : 621
Extended name                  :
Associations                   : PSR J0534+2200, Crab, Crab Pulsar, 1AGL J0535+2205, EGR J0534+2159
Other names                    : 0FGL J0534.6+2201, 1FGL J0534.5+2200, 2FGL J0534.5+2201, 1FHL J0534.5+2201
Class                          : PSR
TeVCat flag                    : Small TeV source
Other flags                    : N/A

*** Position info ***

RA (J2000)           : 83.637 deg
Dec (J2000)          : 22.024 deg
GLON                 : 184.552 deg
GLAT                 : -5.776 deg

ROI number           : 191
Semimajor (68%)      : 0.0072 deg
Semiminor (68%)      : 0.0070 deg
Position angle (68%) : 89.83 deg
Semimajor (95%)      : 0.0117 deg
Semiminor (95%)      : 0.0113 deg
Position angle (95%) : 89.83 deg

*** Spectral info ***

Energy flux (100 MeV - 100 GeV)               : 1.47e-09 +- 1.06e-11 erg cm^-2 s^-1
Detection significance (100 MeV - 300 GeV)    : 30.670 Sigma
Spectrum type                                 : PLExpCutoff
Cutoff energy                                 : 8143 +- 442 MeV
Power law index                               : 2.226
Spectral index                                : 2.045 +- 0.011
Pivot energy                                  : 636 MeV
Flux Density (100 MeV - 100 GeV)              : 5.54e-10 +- 2.67e-12 cm^-2 MeV^-1 s^-1
Integral flux (1 - 100 GeV)                   : 1.57e-07 +- 1.08e-09 cm^-2 s^-1
Significance curvature                        : 15.8


Table:

Energy range    Integral flux                       Energy distribution       Sqrt Test Statistic
0.3-1 GeV       5.45e-07 +- 3.09e-09 cm^-2 s^-1     3.69e-10 erg cm^-2 s^-1   1.77e+02
1-3 GeV         1.26e-07 +- 1.76e-09 cm^-2 s^-1     2.94e-10 erg cm^-2 s^-1   94.1
3-10 GeV        2.55e-08 +- 1.55e-09 cm^-2 s^-1     1.61e-10 erg cm^-2 s^-1   6.57
100-300 MeV     1.65e-06 +- 1.45e-08 cm^-2 s^-1     3.93e-10 erg cm^-2 s^-1   1.4e+02
10-100 GeV      2.26e-09 +- 2.33e-10 cm^-2 s^-1     2.1e-11 erg cm^-2 s^-1    2.65


*** Lightcurve info ***

Variability index                        : 621.931
Significance peak (100 MeV - 100 GeV)    : 84.423
Integral flux peak (100 MeV - 100 GeV)   : 4.09e-06 +- 9.27e-08 cm^-2 s^-1
Time peak                                : 3.25e+08 s
Peak interval                            : 2.63e+06 s

*** Other info (omitted for now) ***

Flux_History/Unc_Flux_History - should I make a similar table to the one I made above?
Contributor

vorugantia commented Feb 22, 2017

@cdeil - All of your most recent comments have been taken care of, except printing the Flux_History and Unc_Flux_History. Before making another table, I wanted to make sure the first table looks fine to you (see output below).

New output:

$ python test_3fgl_str.py

*** Basic info ***

Source                         : 3FGL J0534.5+2201
Catalog row index (zero-based) : 621
Extended name                  :
Associations                   : PSR J0534+2200, Crab, Crab Pulsar, 1AGL J0535+2205, EGR J0534+2159
Other names                    : 0FGL J0534.6+2201, 1FGL J0534.5+2200, 2FGL J0534.5+2201, 1FHL J0534.5+2201
Class                          : PSR
TeVCat flag                    : Small TeV source
Other flags                    : N/A

*** Position info ***

RA (J2000)           : 83.637 deg
Dec (J2000)          : 22.024 deg
GLON                 : 184.552 deg
GLAT                 : -5.776 deg

ROI number           : 191
Semimajor (68%)      : 0.0072 deg
Semiminor (68%)      : 0.0070 deg
Position angle (68%) : 89.83 deg
Semimajor (95%)      : 0.0117 deg
Semiminor (95%)      : 0.0113 deg
Position angle (95%) : 89.83 deg

*** Spectral info ***

Energy flux (100 MeV - 100 GeV)               : 1.47e-09 +- 1.06e-11 erg cm^-2 s^-1
Detection significance (100 MeV - 300 GeV)    : 30.670 Sigma
Spectrum type                                 : PLExpCutoff
Cutoff energy                                 : 8143 +- 442 MeV
Power law index                               : 2.226
Spectral index                                : 2.045 +- 0.011
Pivot energy                                  : 636 MeV
Flux Density (100 MeV - 100 GeV)              : 5.54e-10 +- 2.67e-12 cm^-2 MeV^-1 s^-1
Integral flux (1 - 100 GeV)                   : 1.57e-07 +- 1.08e-09 cm^-2 s^-1
Significance curvature                        : 15.8


Table:

Energy range    Integral flux                       Energy distribution       Sqrt Test Statistic
0.3-1 GeV       5.45e-07 +- 3.09e-09 cm^-2 s^-1     3.69e-10 erg cm^-2 s^-1   1.77e+02
1-3 GeV         1.26e-07 +- 1.76e-09 cm^-2 s^-1     2.94e-10 erg cm^-2 s^-1   94.1
3-10 GeV        2.55e-08 +- 1.55e-09 cm^-2 s^-1     1.61e-10 erg cm^-2 s^-1   6.57
100-300 MeV     1.65e-06 +- 1.45e-08 cm^-2 s^-1     3.93e-10 erg cm^-2 s^-1   1.4e+02
10-100 GeV      2.26e-09 +- 2.33e-10 cm^-2 s^-1     2.1e-11 erg cm^-2 s^-1    2.65


*** Lightcurve info ***

Variability index                        : 621.931
Significance peak (100 MeV - 100 GeV)    : 84.423
Integral flux peak (100 MeV - 100 GeV)   : 4.09e-06 +- 9.27e-08 cm^-2 s^-1
Time peak                                : 3.25e+08 s
Peak interval                            : 2.63e+06 s

*** Other info (omitted for now) ***

Flux_History/Unc_Flux_History - should I make a similar table to the one I made above?
@cdeil

Wow, this is looking great!

I've left a few small comments inline.

My suggestion would be to not put the lightcurve table in this PR, but remove that part
(maybe leave a TODO comment) and wrap this up.
In the lightcurve section, the energy band is always the same, no?
I.e. 100 MeV - 100 GeV was used to derive all of these numbers.
Then I would suggest you just put this at the top once:

Lightcurve measured in the energy band: 100 MeV - 100 GeV

About the spectral point table, I'm not sure. I should have mentioned it before:
My thinking was that to print that info, we call source.flux_points and then use the Astropy table formatting functionality to print the table.
So now you have re-implemented a mini table formatter here specifically for this application.
Actually, I would also suggest you leave this as-is for now, and pretty-printing for FluxPoint and LightCurve should just be separate, future pull requests.
What you can do for now is rename "Energy distribution" to "Energy flux", and print the sqrt(TS) with formatter .1f, i.e. 1234.5 instead of something like 12e3 like you have now, which I find hard to read and compare to the other values for some reason (for fluxes it's OK)

Show outdated Hide outdated gammapy/catalog/fermi.py Outdated
Show outdated Hide outdated gammapy/catalog/fermi.py Outdated
Show outdated Hide outdated gammapy/catalog/fermi.py Outdated
Show outdated Hide outdated gammapy/catalog/fermi.py Outdated
@vorugantia

This comment has been minimized.

Show comment
Hide comment
@vorugantia

vorugantia Feb 22, 2017

Contributor

@cdeil - All comments were addressed in the latest commit. The output looks exactly the same as above (exept the ROI number). Unless you would like to reorder any other information, I think we're ready to merge the PR.

If you would like me to implement source.flux_points and source.lightcurve tables, as mentioned above, I can find time and do so in a new PR.

Contributor

vorugantia commented Feb 22, 2017

@cdeil - All comments were addressed in the latest commit. The output looks exactly the same as above (exept the ROI number). Unless you would like to reorder any other information, I think we're ready to merge the PR.

If you would like me to implement source.flux_points and source.lightcurve tables, as mentioned above, I can find time and do so in a new PR.

@cdeil

This comment has been minimized.

Show comment
Hide comment
@cdeil

cdeil Feb 23, 2017

Member

@vorugantia - You have to adapt this one test:
https://travis-ci.org/gammapy/gammapy/jobs/204367627#L1783
Then this can go in.

I suggest a minimal edit to make the test pass.
There could be fancy things like many asserts or a text dump and assert on that reference text dump, but let's not go there now.

@vorugantia - Do you know how to run the tests locally?

Either of those should work:

python -m pytest gammapy/catalog/tests/test_fermi.py -v
python setup.py test -V gammapy/catalog/tests/test_fermi.py

If you would like me to implement source.flux_points and source.lightcurve tables, as mentioned above, I can find time and do so in a new PR.

We're running the Gammapy workshops this week and next week, and there will be quite a few pull request for new contributors. So my suggestion would be that you leave Gammapy be for a week, and if you have time, add something to gamma-sky.net.
E.g. just this text dump, or an HTML view of the same information, loading the data from JSON.
Or make PNG images for gamma-sky.net for all the Fermi catalog sources (see https://github.com/gammapy/gammapy/blob/master/examples/example_fermi_catalogs.py)

I know it's a lot tedious work to write the "view", but it'll be really useful, and you'll learn more Python scripting. In both cases (more JSON or text, or PNG image) I don't think it's trivial to get it done, but I think by now you have the Python / Gammapy chops that you could do it.

Member

cdeil commented Feb 23, 2017

@vorugantia - You have to adapt this one test:
https://travis-ci.org/gammapy/gammapy/jobs/204367627#L1783
Then this can go in.

I suggest a minimal edit to make the test pass.
There could be fancy things like many asserts or a text dump and assert on that reference text dump, but let's not go there now.

@vorugantia - Do you know how to run the tests locally?

Either of those should work:

python -m pytest gammapy/catalog/tests/test_fermi.py -v
python setup.py test -V gammapy/catalog/tests/test_fermi.py

If you would like me to implement source.flux_points and source.lightcurve tables, as mentioned above, I can find time and do so in a new PR.

We're running the Gammapy workshops this week and next week, and there will be quite a few pull request for new contributors. So my suggestion would be that you leave Gammapy be for a week, and if you have time, add something to gamma-sky.net.
E.g. just this text dump, or an HTML view of the same information, loading the data from JSON.
Or make PNG images for gamma-sky.net for all the Fermi catalog sources (see https://github.com/gammapy/gammapy/blob/master/examples/example_fermi_catalogs.py)

I know it's a lot tedious work to write the "view", but it'll be really useful, and you'll learn more Python scripting. In both cases (more JSON or text, or PNG image) I don't think it's trivial to get it done, but I think by now you have the Python / Gammapy chops that you could do it.

@cdeil

This comment has been minimized.

Show comment
Hide comment
@cdeil

cdeil Feb 23, 2017

Member

One more thing: if you want to be clean and a git professional, you would now squash all of those "update" commits into one commit with a good commit message (like the one you have for the first commit already), before this gets merged and then is forever the record of the Gammapy version history:
https://github.com/gammapy/gammapy/pull/898/commits

Member

cdeil commented Feb 23, 2017

One more thing: if you want to be clean and a git professional, you would now squash all of those "update" commits into one commit with a good commit message (like the one you have for the first commit already), before this gets merged and then is forever the record of the Gammapy version history:
https://github.com/gammapy/gammapy/pull/898/commits

@cdeil cdeil merged commit 5cbd300 into gammapy:master Feb 23, 2017

1 of 2 checks passed

continuous-integration/travis-ci/pr The Travis CI build could not complete due to an error
Details
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
@cdeil

This comment has been minimized.

Show comment
Hide comment
@cdeil

cdeil Feb 23, 2017

Member

🎊 First Gammapy pull request 🎊

I'll try it out now locally for some of my favourite sources ...

⭐️ 🌟

Member

cdeil commented Feb 23, 2017

🎊 First Gammapy pull request 🎊

I'll try it out now locally for some of my favourite sources ...

⭐️ 🌟

@cdeil

This comment has been minimized.

Show comment
Hide comment
@cdeil

cdeil Feb 23, 2017

Member

@vorugantia - I used this to check locally:

from gammapy.catalog import SourceCatalog3FGL
for source in SourceCatalog3FGL():
    print(source.name)
    print(source)

Seems to work fine for all sources.

And I did some code more minor changes in af674e0 .

Member

cdeil commented Feb 23, 2017

@vorugantia - I used this to check locally:

from gammapy.catalog import SourceCatalog3FGL
for source in SourceCatalog3FGL():
    print(source.name)
    print(source)

Seems to work fine for all sources.

And I did some code more minor changes in af674e0 .

@cdeil

This comment has been minimized.

Show comment
Hide comment
@cdeil

cdeil Feb 23, 2017

Member

Just for reference: this is what it looks like at the moment:

*** Basic info ***

Source                         : 3FGL J2359.5-2052 
Catalog row index (zero-based) : 3033
Extended name                  :                   
Associations                   : TXS 2356-210
Other names                    : 
Class                          : bll  
TeVCat flag                    : No TeV association
Other flags                    : None

*** Position info ***

RA (J2000)           : 359.881 deg
Dec (J2000)          : -20.883 deg
GLON                 : 57.947 deg
GLAT                 : -76.612 deg

Semimajor (68%)      : 0.0529 deg
Semiminor (68%)      : 0.0449 deg
Position angle (68%) : -22.46 deg
Semimajor (95%)      : 0.0858 deg
Semiminor (95%)      : 0.0728 deg
Position angle (95%) : -22.46 deg
ROI number           : 751

*** Spectral info ***

Spectrum type                                 : PowerLaw        
Detection significance (100 MeV - 300 GeV)    : 6.936
Significance curvature                        : 0.1
Pivot energy                                  : 2371 MeV
Power law index                               : 2.018
Spectral index                                : 2.018 +- 0.159
Flux Density at pivot energy                  : 6.06e-14 +- 1.19e-14 cm^-2 MeV^-1 s^-1
Integral flux (1 - 100 GeV)                   : 3.37e-10 +- 6.64e-11 cm^-2 s^-1
Energy flux (100 MeV - 100 GeV)               : 3.75e-12 +- 7.5e-13 erg cm^-2 s^-1

*** Spectral points ***

Energy range    Integral flux                       Energy flux               Sqrt Test Statistic 
0.3-1 GeV       5.63e-10 +- 3.52e-10 cm^-2 s^-1     3.86e-13 erg cm^-2 s^-1   1.8                 
10-100 GeV      5.46e-11 +- 2.5e-11 cm^-2 s^-1      9.65e-13 erg cm^-2 s^-1   5.4                 
100-300 MeV     4.57e-09 +- 2.26e-09 cm^-2 s^-1     1.1e-12 erg cm^-2 s^-1    2.1                 
3-10 GeV        5.92e-11 +- 3.06e-11 cm^-2 s^-1     4.05e-13 erg cm^-2 s^-1   3.4                 
1-3 GeV         1.99e-10 +- 7.73e-11 cm^-2 s^-1     4.78e-13 erg cm^-2 s^-1   3.6                 


*** Lightcurve info ***

Lightcurve measured in the energy band: 100 MeV - 100 GeV

Variability index                        : 36.292

No peak measured for this source.
Member

cdeil commented Feb 23, 2017

Just for reference: this is what it looks like at the moment:

*** Basic info ***

Source                         : 3FGL J2359.5-2052 
Catalog row index (zero-based) : 3033
Extended name                  :                   
Associations                   : TXS 2356-210
Other names                    : 
Class                          : bll  
TeVCat flag                    : No TeV association
Other flags                    : None

*** Position info ***

RA (J2000)           : 359.881 deg
Dec (J2000)          : -20.883 deg
GLON                 : 57.947 deg
GLAT                 : -76.612 deg

Semimajor (68%)      : 0.0529 deg
Semiminor (68%)      : 0.0449 deg
Position angle (68%) : -22.46 deg
Semimajor (95%)      : 0.0858 deg
Semiminor (95%)      : 0.0728 deg
Position angle (95%) : -22.46 deg
ROI number           : 751

*** Spectral info ***

Spectrum type                                 : PowerLaw        
Detection significance (100 MeV - 300 GeV)    : 6.936
Significance curvature                        : 0.1
Pivot energy                                  : 2371 MeV
Power law index                               : 2.018
Spectral index                                : 2.018 +- 0.159
Flux Density at pivot energy                  : 6.06e-14 +- 1.19e-14 cm^-2 MeV^-1 s^-1
Integral flux (1 - 100 GeV)                   : 3.37e-10 +- 6.64e-11 cm^-2 s^-1
Energy flux (100 MeV - 100 GeV)               : 3.75e-12 +- 7.5e-13 erg cm^-2 s^-1

*** Spectral points ***

Energy range    Integral flux                       Energy flux               Sqrt Test Statistic 
0.3-1 GeV       5.63e-10 +- 3.52e-10 cm^-2 s^-1     3.86e-13 erg cm^-2 s^-1   1.8                 
10-100 GeV      5.46e-11 +- 2.5e-11 cm^-2 s^-1      9.65e-13 erg cm^-2 s^-1   5.4                 
100-300 MeV     4.57e-09 +- 2.26e-09 cm^-2 s^-1     1.1e-12 erg cm^-2 s^-1    2.1                 
3-10 GeV        5.92e-11 +- 3.06e-11 cm^-2 s^-1     4.05e-13 erg cm^-2 s^-1   3.4                 
1-3 GeV         1.99e-10 +- 7.73e-11 cm^-2 s^-1     4.78e-13 erg cm^-2 s^-1   3.6                 


*** Lightcurve info ***

Lightcurve measured in the energy band: 100 MeV - 100 GeV

Variability index                        : 36.292

No peak measured for this source.

@vorugantia vorugantia deleted the vorugantia:SourceCatalogObject3FGL branch Feb 24, 2017

@cdeil cdeil changed the title from extend __str__ in SourceCatalogObject3FGL to Add printout for 3FGL catalog objects Apr 28, 2017

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