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
Observation table subset selection #295
Conversation
I have seen the travis-ci error because of warnings in the sphinx-doc. I'll look into it tomorrow. |
Ok. I fixed the warnings. The travis-ci build looks fine. |
|
||
def test_filter_observations(): | ||
# create random observation table | ||
observatory_name='HESS' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please put observatory_name='HESS'
and n_obs=10
as default keyword arguments for make_test_observation_table
.
So that if the user doesn't look up and give any parameters, they still get a nice small table to play with.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
The main additions in this PR are the We can discuss in the hangout tonight, but here's my first thoughts / suggestions:
What's most unclear to me is how to best implement the min / max selection that's currently in
Some other possibilities we could discuss a bit, but I think are probably too complex to hash out and implement in a short amount of time (this should take a few days at most, not weeks):
So bottom line ... I think those last two fancy selection methods would be nice, but we don't have the time and they are probably too complex for the task, and should implement the simple solution I described before. |
Ok I see your point with the complexity of the method. I still think that having a generic way of making cuts on any variable is nice, without the need of implementing a new method each time. In addition, if something changes in the way of treating variables, one has to update only one function, not many (with the risk of forgetting updating some). I think it still would be possible to use the code, making it a bit simpler, by splitting some cases. The complexity of the code is introduced by:
To fix 1. one could do the same as for 3.: use a separate keyword To fix 2. we can either drop the case of the zenith angle (and the user should use altitude) or transform it at an earlier stage. Another complexity in the case of time variables is the need to support 2 different formats:
You already mentioned a couple of weeks ago that we should support both. If using a separate case for time variables, this complexity would become clearer, since it would not be nested with the zenith angle special case. And yet another complexity in the case of time variables: when making a box selection in time, you need to check 2 variables, not only 1:
The observation (start and end) should be within the selected time interval. One could drop this use case, and the user will have to decide if he wants to apply the cut to either So I propose to split the code a bit more, but keeping the generality for allowing cuts in any variable. The splitting would be according to the variable type, rather than the variable name. To finalise, the code works properly, as demonstrated by the many test cases implemented in the test file. One can show them as examples for the user. |
BTW, for the inline command |
For the |
5312132
to
c069d22
Compare
Ok, I did a major revision of the whole filtering process. I tried to simplify it as much as I could, and document it well. Now there are 4 different kinds of selections:
I also started to implement the inline find-obs tool. It is not 100% functional but it works. You can test it with the following commands:
Please have a look at the docs, especially at:
@cdeil I still need to work on this, but please take some time to review the general structure of the code, to see if you like it, and best plan how to move on. Please note, that I find the generic variable filtering method very useful for the construction of the observation groups for the binning of the observations for producing the cube bg models. |
Wow, you've been busy. 😄 It'll take me a few hours to review this, play with this and think if this is the best API / implementation or if it can be improved somehow. I guess you'll continue with this on Monday and I can take my time? If you do want to continue with this, my suggestion would be that you work on the
One concern I have is that we want very similar selection methods for event lists and for the sky regions, for source catalogs, so the code for that should be shared somehow. Not sure what the solution for this is yet. |
|
||
It works with `fits` files as input/output. | ||
|
||
Examples: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make this a sub-section, so that it gets a URL one can link to from emails or other parts of the Sphinx docs.
Examples
-------------
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please implement this suggestion (make Examples
a RST sub-section so that it can be linked to)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
Add changelog entry. Once I've reviewed this for a bit, we should merge it in master and then ask others from HESS to try it out and give feedback in a new issue. This is the first thing most end-user will run, so it's worth the effort to make it as good as possible and add some bells and whistles and lots of docs examples. |
@mapazarr – I'll cut the Gammapy 0.3 release tomorrow evening (CEST).
As long as travis-ci passes so that the CI build isn't broken, I'm fine with merging this. |
@cdeil Sorry, I didn't have much time over the WE. I'm willing to merge it if I can first work for ~1h to make the findruns work with input fits files (and show a PRELIMINARY warning). Then I'd start working on it on a new branch/PR, in order to implement tests for findruns, the comments from this PR and polish the code a bit more. So, can I still make a preliminary working version of findruns? or do you have to freeze the stable version already? |
Can we have a quick Skype chat about this decision? |
f04b42d
to
78f37af
Compare
…filter_observations method in ObservationTable.
78f37af
to
b037fda
Compare
@cdeil OK, I added the mods, and the travis-ci passed. Can you merge it? |
@mapazarr – I'll do one last review ... I promise I won't make suggestions that take long to implement. |
@@ -94,6 +94,7 @@ Pull requests | |||
- Consistent random number handling and improve sample_sphere [#283] (Manuel Paz Arribas) | |||
- Add Feldman Cousins algorithm [#311] (Dirk Lennarz) | |||
- Simplified attribute docstrings [#301] (Manuel Paz Arribas) | |||
- Filter observation tables [#295] (Manuel Paz Arribas) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rename changelog entry and PR title to "Observation table subset selection"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
TODO: describe me | ||
selection : `~dict` | ||
Dictionary with a few keywords for applying selection cuts. | ||
TODO: add doc with allowed selection cuts!!! and link here!!! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible to address this TODO quickly?
(if no, maybe making a new issue for yourself with a task list to keep track of such things would be helpful?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
I left a bunch of comments that I think can be addressed quickly. One comment that might be a bit controversial is that I'd prefer you use Note that both Sunpy has a TimeRange and astroplan is introducing one (currently names TimeWindow, will be named @mapazarr – If you don't want to do this change to |
(`docs <http://ndawe.github.io/goodruns/>`__, `code <https://github.com/ndawe/goodruns>`__) | ||
is a nice example for a run selection tool. | ||
|
||
Examples: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove colon :
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
Ok, I changed the functions to accept |
…tional, add tests, improve docs. Plus a bunch of small changes/fixes in related code.
Merging this now, but a few things remain for a future PR: see issue #315. |
Observation table subset selection
Added methods for filtering observation tables to the
ObservationTable
class. The method allows forbox
orcircle
selections on any variable inside the observation table. In addition,zenith
is interpreted as (90 deg - altitude). Inverse selection is also possible. The doc is uploaded here:https://googledrive.com/host/0BzXHZQx0oCLBfmcyUDdxMU9sLVduMXM1QXk5RTNYU3dXYmthVG9OZ18wWE1uR3lYaEsxRU0/html_doc/docs/_build/html
This PR addresses issue #293.
TODO: