astropy / photutils

Astropy package for source detection and photometry. Maintainer: @larrybradley
https://photutils.readthedocs.io
BSD 3-Clause "New" or "Revised" License
240 stars 134 forks source link

Making custom apertures by combining existing Apertures #888

Open ysBach opened 5 years ago

ysBach commented 5 years ago

It's rather a question...

I wanted to make a pillbox-shaped aperture, as in TRIPPY (e.g., here), because all the stars in my images are trailed (due to the non-sidereal tracking mode).

I thought it will be easy enough because what I have to do is just combining two circles with a rectangle (overlapping regions will not matter much if I use mask properly) using photutils. But currently I am stuck at the very first step... I can't just sum or combine the apertures as I sometimes do for astropy models. I think there should be simple workaround, but couldn't figure out so far.

Do you have any idea?

larrybradley commented 5 years ago

@ysBach Here's an example notebook where I define a pillbox mask and use it to perform photometry. Hopefully this will help you get started!

https://gist.github.com/larrybradley/37ea328514abd891ef834eead47e8e81

Combining various shapes is available in the regions package (https://github.com/astropy/regions), but the methods needed for photometry aren't defined for compound shapes yet.

ysBach commented 5 years ago

@larrybradley Sorry for this late reply! So far, I have been trying to make an Aperture object named PillBoxAperture (with annulus, skyaperture, skyannulus), and used it for the data reduction of my observational data (get light curve of asteroid and determine the rotational period, and got results much better than expected)

The one I used is in the gist here: result: image (annulus masks are just added although there is no physical meaning for that)

It is compatible with photutils v0.7, but I haven't put any effort on the backward compatibility with photutils v0.6 or lower.

As I am not very clever about coding (honestly, I didn't know how to use @property and @staticmethod about a week ago..), I am not sure whether it is the best way of doing it.

Do you think it is worth pull request? Or, I will just keep it with my personal data reduction package and use it for my own purpose :)