Repository navigation
Add cube background model class - #299
Conversation
|
#292 (comment) |
99431d4 to
da60ebd
Compare
|
#292 (comment) |
|
#292 (comment) |
|
#292 (comment) |
|
#292 (comment) |
|
#292 (comment) |
|
Ok, we discussed this issue already here: and I already simplified the methods. They are still long because I add 2 checks for a valid entry from the user. The method itself to find the bin is 4 lines on each case (X, Y and E). I'm not sure I can simplify it more. (We could drop the checks, if you think they don't belong there.) In the case of the det bin (X, Y), I don't like using the In the case of the energy, I'm not sure what PR #290 does, but one can rewrite it once it is finished, if it makes sense. As I said, finding the bin is only 4 lines: actually it's 2 lines, plus extra 2 lines to find the edges (which I find nice/handy to have). |
|
#292 (comment) You say it is no good practice to add print statements to the library code. I think sometimes it can be useful to have some printouts, especially if the code takes long to run (which is not the case), but also to get some important information. An example would be: I removed in any case all |
|
About the plots: #292 (comment) #292 (comment) #292 (comment) |
|
#292 (comment) |
|
@mapazarr – I'm short on time this week, so I'll just do a final review tomorrow during the hangout. Please update the task list and ask if you have any specific questions before you can finish this up. Concerning the |
|
Ok, I'm pretty much done with this PR. I think I have still one or 2 minor TODO's for you to review/comment on, on top of the questions I posted acouple of days ago above, and of course the final code review. The link to the docs is here: |
|
This example doesn't work for me: The problem are the Merging the headers like this works for me, so that's what I'd suggest as a workaround: header = wcs_header.update(imhdu.header)The reason this error doesn't show up for you locally and on travis-ci is probably that you're not using the very latest Astropy master. |
There was a problem hiding this comment.
I'd like the top-level gammapy.background page to remain short, just giving an overview of the available functionality and maybe one or two quick code examples / plots.
So please move this whole section to a sub page.
An example how to do this is here: https://gammapy.readthedocs.org/en/latest/image/plotting.html , i.e. plotting is a subpage of the image docs.
There was a problem hiding this comment.
PS: the docs you put online on Google drive don't work (I get 404 page not found errors when I click on gammapy.background).
Contrary to what I said before: please don't put docs online any more! I'll simply check out your branch, built the docs locally and make inline comments on what I think should be fixed, using screenshots where needed. This works nicely.
There was a problem hiding this comment.
Sorry if this has been discussed already, I don't remember: Why call Quantity here? self.detx_bins is already a quantity, so this is useless, no?
There was a problem hiding this comment.
As it is, it is the simplest way.
See this: #299 (comment)
There was a problem hiding this comment.
I can add an explanation in the code as a comment if you like.
There was a problem hiding this comment.
So you basically want to reshape the array here?
Then please call reshape or maybe numpy.expand_dims to make the code clearer.
(I hope it works with Quantity objects).
Also, in this case the temp variables aren't really needed, you can just assign to the table columns below and it'll still nicely fit on one line, no?
There was a problem hiding this comment.
Thinking about this some more, I think this is a tick more readable:
bin_centers = 0.5 * (bin_edges[:-1] + bin_edges[-1:])and is more similar to the expression for log bin centers (geometric mean):
bin_centers = np.sqrt(bin_edges[:-1] * bin_edges[1:])
So please use that.
It's also faster! 🚤 🐎
:-)
There was a problem hiding this comment.
Done. It is how I had done it before, only I had temp vars for bin_edges[:-1] and bin_edges[1:] for readability purposes...
|
Left some more minor inline comments. |
|
Ok I implemented the last comments. I also fixed some problems in SpectralCube nad the tutorials, that where preventing the sphinx job in travis-ci to work. Can we merge this PR already? Some of the minor comments are turning around on issues discussed a few times already, and undoing some of the proposed changes. |
|
Merging this now. I looked through the coverage report and generally coverage is good. |
|
🎆 |
|
Docs build on readthedocs worked: https://gammapy.readthedocs.org/en/latest/background/models.html |
|
Hi Christoph. Indeed the existence of Please see the text at the examples section of: https://heasarc.gsfc.nasa.gov/docs/heasarc/ofwg/docs/general/ogip_93_001/ogip_93_001.html 'the number of spaces between individual unit sub-strings is left a matter for personal preference' @mimayer doesn't use any spaces, i.e. According to the FITS standards both are valid. This could be another issue for astropy. |
|
Thanks for the merging! :-) |
|
I didn't get any coveralls report. |
|
You have to manually go to https://coveralls.io/github/gammapy/gammapy (I always do it via the link here) and find the right build. |
|
BTW, I think the test file from |
…roundModel class).
…roundModel class).
This PR is a continuation of PR #292.
Task list:
~gammapy-extraread_imageandwrite_imagewith aWCSobject and a HDU table for the energy bin edges; testsdo_one_plotanddo_many_plotsfunctionsexamples/plot_background_model.py; add examples of many plots (mosaic of images, stack of spectra)Further methods like histograming of event lists or interpolation and smoothing of the model will come on a later PR.
Sorry for the mess, I renamed the branch, which automatically closes the pull request. I thought the PR would be transparent to the rename.