简体   繁体   中英

Is there a way to scan each pixel of a photo to look for coordinates with python? ( find RA and Dec coordinates through pixels )

I was wondering if there was a way to use python to look through an image to find coordinates. Basically I just need to find the pixel values ( x,y ) for a target star by matching it to its correct right ascension and declination values. However, I have zero idea how to do this, so I thought I'd ask. I'd really appreciate any help or guidance. Thank you!

If we have the image centre in degrees such as (RA, Dec) and the pixel scale with units (deg/px) then we can calculate the pixel co-ordinates as follows:

img = <2D image array>

t_ra = <target star RA in degrees>
t_dec = <target star Dec in degrees>
c_ra = <image centre RA>
c_dec = <image centre Dec>
ps = <pixel scale in deg/px>

H, W = img.shape
x = int((t_ra - c_ra) / ps + W / 2)
y = int((t_dec - c_dec) / ps + H / 2)

# To extract a small square patch from the image
patch_size = 50
img_patch = img[x - patch_size:x + patch_size, y - patch_size:y + patch_size]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM