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 an implementation of daophot GROUP functionality #369

Merged
merged 36 commits into from
Aug 2, 2016

Conversation

mirca
Copy link
Member

@mirca mirca commented Jun 8, 2016

Hi all,

this PR is part of a work in progress in order to implement a procedure for doing point spread function photometry in crowded fields.

A possible block-diagram of such procedure is shown here:
photometry_system

  1. This PR implements the GROUP block based on Stetson (1987) that basically group stars whenever their centroid-to-centroid distance is less than crit_separation.
  2. The FIND block is already implemented in photutils as daofind.
  3. The NSTAR block is responsible for constructing the joint PSF model for each group recognized by GROUP and for fitting those models to the given data.
  4. The IDENTIFY block must be able to decide which PSF models were well fitted to the data so that they can be removed from the fitting procedure.

cc @eteq @hamogu @bsipocz

def _find_group(star, starlist, crit_separation):
"""
Find those stars in `starlist` which are at a distance of
`crit_separation` from `star`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These should be double back ticks as sphinx tries to linkify the singe ones and will fail with these.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ahh, never mind this wont fail the test but only because it's a private function (thus left out of the docs).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

less than crite_separation ...

__all__ = ['DAOGroup']


class GroupStarsBase(object):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you need to add it to the public classes to __all__ to get rid of the sphinx warnings. (It is the base group for DAOGroup, thus the docs generation for the DAOGroup API tries to make a link to it, but since it's not public cannot find it).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bsipocz Thanks Brigitta, I'll do that =)

@@ -52,6 +52,8 @@ User Documentation

photutils/background.rst
photutils/detection.rst
photutils/grouping.rst
photutils/grouping_files
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you don't need to list the directory here

@bsipocz
Copy link
Member

bsipocz commented Jun 28, 2016

@mirca - matplotlib has a sphinx directive for plotting, and other parts of the documentation are using it. Remind me please if there is a reason for using png files for the plots rather than plotting them on the fly?

@mirca
Copy link
Member Author

mirca commented Jun 29, 2016

@bsipocz I realized that I could just convert an IPython notebook to rst. Would you prefer that I use the plot directive instead?

@bsipocz
Copy link
Member

bsipocz commented Jun 29, 2016

Yes please, it will be more consistent with the rest of the package and also avoid storing image files in the repo (though we will have to do that anyway once we set up pytest-mpl testing).

@mirca mirca changed the title WIP: GROUP function Add an implementation of daophot GROUP functionality Jul 2, 2016
@mirca
Copy link
Member Author

mirca commented Jul 2, 2016

Failures seems to be unrelated.

@mirca
Copy link
Member Author

mirca commented Jul 7, 2016

There was an issue with the id column. It turns out that the data in the id column have to be 1, 2, ..., n rather than 0, 1, ..., n, in order to be compatible with this and this. So, should I verify if the id column is valid? I'm thinking of the case that the user will use her/his own find algorithm and it generates an id column which begins with 0...

cc @hamogu @eteq @bsipocz

@hamogu
Copy link
Member

hamogu commented Jul 7, 2016

Classic problem in python: While array indices start at 0, when people talk to each other you would say "group 1, group 2, ...".
I think testing it and giving a good error message is a good idea. It's easy and its a mistake that other people will make.

@bsipocz
Copy link
Member

bsipocz commented Jul 9, 2016

@mirca - This needs rebasing.

@mirca
Copy link
Member Author

mirca commented Jul 19, 2016

@eteq @bsipocz @hamogu @larrybradley Please, consider merging this if you are happy :)

@bsipocz
Copy link
Member

bsipocz commented Jul 19, 2016

@mirca - As I remember @eteq said on our last telecon that he wants to review this.

@bsipocz
Copy link
Member

bsipocz commented Jul 26, 2016

@mirca - It seems that you've pushed the last commit to the wrong branch ;)

@mirca
Copy link
Member Author

mirca commented Jul 26, 2016

@bsipocz I actually forgot to commit the changes in the main file, haha, thanks! xD



@six.add_metaclass(abc.ABCMeta)
class GroupStarsBase(object):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This class and the group_stars method needs to have a docstring that lays out explicitly what the interface is (i.e., what must starlist be, and what must the method return). That way a user can implement their own grouping method if they don't like one of the options here.

Copy link
Member

@eteq eteq Aug 2, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, and it should be very clear whether or not __call__ needs to be implemented. I see below that DAOGroup uses __call__ instead of group_stars.

My suggestion would be for this class (GroupStarsBase) to implement just this:

def __call__(self, starlist):
    return self.group_stars(starlist)

And then have the subclasses only implement group_stars. That way the "function"-like capability that @hamogu suggested is preserved, but subclasses have to use the group_stars method name, which is much more readable.

EDIT: (I see this is already what's in DAOGroup, but I'm just suggesting the __call__ method be moved to GroupStarsBase)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@eteq I think I addressed your points. Did I get them right?

@eteq
Copy link
Member

eteq commented Aug 2, 2016

@mirca - OK, I reviewed this and it looks great. I left a few comments above, only one of which is really significant (about making the interface in GroupStarsBase clear, and possibly a minor adjustment to where __call__ is implemented). Once you've addressed those (which should be pretty easy), this is godo to merge!

@mirca
Copy link
Member Author

mirca commented Aug 2, 2016

@bsipocz Do you think long URL is a fair enough reason to break pep8? ;)

@bsipocz
Copy link
Member

bsipocz commented Aug 2, 2016

Do you think long URL is a fair enough reason to break pep8? ;)

Sure, there are plenty of examples for that ;)
(Also the line length is one of the PEP8 that none of the packages are enforcing)

@bsipocz bsipocz merged commit 857b38d into astropy:master Aug 2, 2016
@mirca mirca deleted the group-routine branch May 5, 2017 00:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants