Change copy and add rotate methods#281
Conversation
|
Each region already defines a Polygons would require a workaround, but I think the polygon API should be changed (but not in this release!) so that its "center" can be moved around by changing one parameter instead of all the vertices. IIRC we discussed that at one time. |
|
@larrybradley - Agreed that both Is it really useful to exclude Another cosmetic change I'd suggest is to move these tuples to class-level, out of |
|
@larrybradley - I followed your suggestion in 19edcfc - for now we just have
You proposed it in #57. It wasn't clear to me why it's useful. Is it a performance issue, to have an efficient "shift" of a polygon to a new position, in case there are many vertices and you don't want to make another array? |
|
Added rotate for circle, ellipse, rectangle and polygon. Seems to work fine, based on the test added. Ready for final review. |
|
@cdeil I think the I think it's a good idea to move the params tuple to the class level. I'm not familiar with the |
|
@cdeil For the polygon region, I'm thinking of the use case of aperture photometry. In that case, one has an xypos = PixCoord(10, 20)
reg1 = CirclePixelRegion(xypos, radius=3)
reg2 = PolygonPixelRegion(xypos, vertices=vertices)
aperture_photometry(data, (reg1, reg2))where the polygon xypos2 = PixCoord(30, 40)
# no need to recompute polygon vertices for new position
reg3 = PolygonPixelRegion(xypos2, vertices=vertices) |
This PR is a follow-up to #269 - I did implement the suggestion from #269 (comment) and put
copyin the base class. I'm not sure if that's good - comments welcome!This PR also adds PixCoord and pixel region rotate methods, as I mentioned in #265 .
I'll continue a bit and add copy and rotate for a few more regions here.
@astrofrog @keflavich @registerrier or anyone - please review.