2 years ago

#61868

test-img

Jimbles

changing astropy SkyCoord object into float

I am working with the astropy function pixel_to_SkyCoords which takes 2 1D arrays of coordinates, a wcs transform system (.fits HDU), and returns an object of the SkyCoord class that contains the equivalent sky coordinates. Since I have many pixel coordinates, I am iterating through a for loop:

transform_file = ap.io.fits.open('/home/jryan/astrometry_tests/75mm_field_new-image_3rd.fits')
transform = ap.wcs.WCS(transform_file[0].header, naxis=2)

sky_pts = []
for star in range(num_objects):
    sky_coords = ap.wcs.utils.pixel_to_skycoord(x[star],y[star], transform) 
    sky_pts.append(sky_coords)

The problem is that when the sky_coords variable is appended to sky_pts, it is not appending the values of the coordinates, but rather the SkyCoord object. I want the values themselves so I can put them into a Dataframe. How can I convert this object to a float to do this?

Thanks!

python

astropy

astronomy

0 Answers

Your Answer

Accepted video resources