[AstroPy] Object within region

Eric Jensen ejensen1 at swarthmore.edu
Sun Jun 12 09:56:46 EDT 2022


Hi Miguel,

> One of my questions is why the "contains" method requires a wcs. If my only inputs are skycoords in icrs, why is needed to perform wcs transformations? This is a concept that I don't fully understand.


I think this is answered elsewhere in the docs, here: https://astropy-regions.readthedocs.io/en/stable/getting_started.html.  There it says: “Sky regions are regions that are defined using celestial coordinates. Note that these are not defined as regions on the celestial sphere, but rather are meant to represent shapes on an image, but simply defined using celestial coordinates as opposed to pixel coordinates.” 

Given this definition (that regions - even sky regions - always exist in the context of some image), then the WCS is needed to be able to convert between sky and pixel coords for the associated image.  

For your case, where maybe you only care about regions on the celestial sphere, it seems like you should be able to make this work using the WCS from the sample image they use in the docs.  (Caveat: I’ve never used this, so there could be some subtleties I’m missing here.)

If you can provide some sample code, and what results you get vs. what you expect to get, we can go from there.  

Eric


> On Jun 12, 2022, at 7:18 AM, Miguel Gutiérrez Páez <mgutierrez at gmail.com> wrote:
> 
> 
> Hi all,
> 
> I'm trying to figure out how to determine if a particular object falls within a certain sky region.
> First, please note I'm a complete noob with astropy, so I guess I'm probably missing some concept.
> 
> I've read examples about regions and sky regions: https://astropy-regions.readthedocs.io/en/stable/contains.html
> 
> I've been trying some examples by myself but I get some wrong results. That is, the script reports an object falls within the region, but after checking with stellarium for example, clearly is not.
> 
> One of my questions is why the "contains" method requires a wcs. If my only inputs are skycoords in icrs, why is needed to perform wcs transformations? This is a concept that I don't fully understand.
> The wcs I'm passing to the contains method, is the one described in the link above, the mentioned example.
> 
> As stated, I'm pretty sure I'm failing due to some missing concepts. Glad to hear from your for any clarification.
> 
> Thanks in advance.
> 
> Regards
> 
> PS: if you with I can paste some lines of my code
> _______________________________________________
> AstroPy mailing list
> AstroPy at python.org
> https://mail.python.org/mailman/listinfo/astropy
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.python.org/pipermail/astropy/attachments/20220612/64974fde/attachment.html>


More information about the AstroPy mailing list