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

Add Fermi PSF dataset and example #191

Merged
merged 7 commits into from Sep 21, 2014
Merged

Add Fermi PSF dataset and example #191

merged 7 commits into from Sep 21, 2014

Conversation

@ellisowen
Copy link
Contributor

@ellisowen ellisowen commented Aug 27, 2014

Adds some Fermi-LAT PSF data.

This will be used in unit tests for the FermiGalacticCenter and FermiVelaRegion psf files. I will add these tests in another PR once this one is OK & merged.

* `PSF_P7REP_SOURCE_V15 <http://www.slac.stanford.edu/exp/glast/groups/canda/archive/p7rep_v15/lat_Performance_files/cPsfEnergy_P7REP_SOURCE_V15.png>`_
* `PSF_P7SOURCEV6 <http://www.slac.stanford.edu/exp/glast/groups/canda/archive/pass7v6/lat_Performance_files/cPsfEnergy_P7SOURCE_V6.png>`_

This comment has been minimized.

@ellisowen

ellisowen Aug 27, 2014
Author Contributor

I couldn't find a way to keep these lines below the 80 character limit and still build OK in the docs. Do you know how I can do this?

This comment has been minimized.

@cdeil

cdeil Aug 28, 2014
Member

That's OK ... it's an exception ... braking the URL would be bad.

* ``P7REP_SOURCE_V15_68`` Total Fermi-LAT PSF 68% containment radius with energy for P7REP_SOURCE_V15
* ``P7REP_SOURCE_V15_95`` Total Fermi-LAT PSF 95% containment radius with energy for P7REP_SOURCE_V15
* ``P7SOURCEV6_68`` Total Fermi-LAT PSF 68% containment radius with energy for P7SOURCEV6
* ``P7SOURCEV6_95`` Total Fermi-LAT PSF 95% containment radius with energy for P7SOURCEV6

This comment has been minimized.

@ellisowen

ellisowen Aug 27, 2014
Author Contributor

Same problem as above - splitting the line to adhere to the the pep8 80 character limit meant this would build OK in the docs...

This comment has been minimized.

@cdeil

cdeil Aug 28, 2014
Member

OK ... leave as is.

@@ -304,7 +305,7 @@ def background_image():
@staticmethod
def predicted_image():
"""Predicted counts spectral image including Vela Pulsar.
Based on the Fermi Diffuse model (see class docstring) and
Based on the Fermi Diffuse model (see clP7REP_SOURCE_V15ass docstring) and

This comment has been minimized.

@cdeil

cdeil Aug 28, 2014
Member

Looks like you accidentally pasted something into this line.

@cdeil
Copy link
Member

@cdeil cdeil commented Aug 28, 2014

Please add a tutorial that computes the containment radii using the EnergyDependentTablePSF class and plots the curves R68 and R95 as a function of energy and compares to the tables you have here.

Parameters
----------
performance_file : float

This comment has been minimized.

@cdeil

cdeil Aug 28, 2014
Member

float -> str ?

@ellisowen ellisowen force-pushed the ellisowen:psf_data branch from 47a96a0 to 94a10fe Aug 29, 2014
@ellisowen
Copy link
Contributor Author

@ellisowen ellisowen commented Aug 29, 2014

To do (Ellis):

  • Include FermiVelaRegion PSF in plots.
  • Add some short text to the tutorial.
@ellisowen ellisowen force-pushed the ellisowen:psf_data branch from 00bb7d5 to d47cfb7 Aug 29, 2014
@ellisowen
Copy link
Contributor Author

@ellisowen ellisowen commented Aug 29, 2014

OK, this is now ready for review.

@cdeil
Copy link
Member

@cdeil cdeil commented Aug 31, 2014

This is the result I get:
image

In the tutorial you should mention if the values make sense or not.
The Vela PSF uses P7REP_CLEAN_V15 cuts ... did you not have those available for comparison or why did you read off the P7REP_SOURCE_V15 values.
If the plot for P7REP_SOURCE_V15 is not available online, you should at least mention that P7REP_CLEAN_V15 is very similar to P7REP_SOURCE_V15 (I think, but don't know how close it actually is), so this PSF looks OK.

For the Galactic center PSF it says here that I used P7REP_CLEAN_V15, but the gtmktime and gtpsf commands are not shown there, so I suspect that I used a different IRF instead.
Looks like you or I have to replace the Galactic center dataset at some point with something more reproducible ... for now you could simply write this as a comment that this PSF is not consistent.

data = []

# Loop over energies and determine PSF containment radius
for i in np.arange(emin, emax, step):

This comment has been minimized.

@cdeil

cdeil Aug 31, 2014
Member

This is a bit weird ... emin and emax aren't really energies here.
Please use this utiltity function instead to create an equal-log-spacing grid of energies?

Instead of passing parameters to this function you can simply create the energies array here or make it a global variable.

energy = Quantity(10 ** i, 'MeV')
energy_psf = psf.table_psf_at_energy(energy)

# 68% Containment radius

This comment has been minimized.

@cdeil

cdeil Aug 31, 2014
Member

Remove that comment ... the code says exactly the same thing.


# 68% Containment radius
containment_68 = energy_psf.containment_radius(0.68)
# 95% Containment radius

This comment has been minimized.

@cdeil

cdeil Aug 31, 2014
Member

Remove that comment ... the code says exactly the same thing.

true_table_rep = load_lat_psf_performance('P7REP_SOURCE_V15_68')
true_table = load_lat_psf_performance('P7SOURCEV6_68')

plt.errorbar(gtpsf_table_gc['ENERGY'], gtpsf_table_gc['CONT_68'],

This comment has been minimized.

@cdeil

cdeil Aug 31, 2014
Member

Use plt.plot here ... you're not drawing errorbars.

"""Plots 95 Percent PSF Containment Radius with Energy for Galactic Center
and Vela region.
"""
from gammapy.datasets import FermiGalacticCenter, FermiVelaRegion

This comment has been minimized.

@cdeil

cdeil Aug 31, 2014
Member

The 95% containment radius code repeats the 68% containment radius code.
Put it in a function plot_containment_radii() and call it with a fraction=68 or fraction=95 argument.

performance_file : str
Specify which PSF performance file to return.
* ``P7REP_SOURCE_V15_68`` Total Fermi-LAT PSF 68% containment radius with energy for P7REP_SOURCE_V15

This comment has been minimized.

@cdeil

cdeil Aug 31, 2014
Member

Make this shorter to fit on one line ... e.g.:

* ``P7REP_SOURCE_V15_68``: P7REP_SOURCE_V15, 68% containment
@cdeil
Copy link
Member

@cdeil cdeil commented Aug 31, 2014

This is mostly OK ... some inline comments above.

The main discovery here is that I screwed up the Galactic center reference dataset.

Could you please update exposure.sh (and rename to make.sh) and README and fermi_counts.fits.gz and fermi_exposure.fits.gz and psf.fits files for the Galactic center dataset (and adapt tests as needed.
You can use the Vela ROI make.sh ... the only reason I don't include that in the gammapy repo is that it is 5 MB total, so we still need the smaller Galactic center dataset here.

Great that you found out what's wrong!

@cdeil
Copy link
Member

@cdeil cdeil commented Aug 31, 2014

And would you mind putting the four txt files into a single FITS files with four table extensions?

You can do this once interactively with a few commands in an IPython session or write 10 lines of script to do it and put it in the dev folder like I did here for example.

@coveralls
Copy link

@coveralls coveralls commented Sep 17, 2014

Coverage Status

Coverage increased (+0.43%) when pulling d529946 on ellisowen:psf_data into a0b99ec on gammapy:master.

@ellisowen ellisowen force-pushed the ellisowen:psf_data branch 2 times, most recently from 3a90052 to 27f0521 Sep 17, 2014
@ellisowen
Copy link
Contributor Author

@ellisowen ellisowen commented Sep 17, 2014

OK, this is now ready.

I didn't change the FermiGalacticCenter files in this PR, just updated the descriptions so the correct IRFs are mentioned. I don't think the updating of the datafiles themselves with P7REP_CLEAN_V15 will be something I'll have time to do myself in the next day or two, so perhaps these can just be put as an issue?

@cdeil
Copy link
Member

@cdeil cdeil commented Sep 17, 2014

Can you please rebase this against master?

@ellisowen ellisowen force-pushed the ellisowen:psf_data branch from 27f0521 to 4edc742 Sep 17, 2014
@ellisowen
Copy link
Contributor Author

@ellisowen ellisowen commented Sep 17, 2014

Ok, done!

@cdeil
Copy link
Member

@cdeil cdeil commented Sep 21, 2014

Thanks!

cdeil added a commit that referenced this pull request Sep 21, 2014
Psf data
@cdeil cdeil merged commit 55afe0d into gammapy:master Sep 21, 2014
1 check passed
1 check passed
continuous-integration/travis-ci The Travis CI build passed
Details
@cdeil cdeil changed the title Psf data Add Fermi PSF example Apr 8, 2015
@cdeil cdeil changed the title Add Fermi PSF example Add Fermi PSF dataset and example Apr 8, 2015
@cdeil cdeil added the feature label Apr 8, 2015
@cdeil cdeil added this to the 0.2 milestone Apr 8, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants
You can’t perform that action at this time.