1 year ago

#372456

test-img

BAO

In astropy.coordinates.SkyCoord, how can I use it with data which compose cartesian "2D" coordinates

I am using the astropy.coordinates.SkyCoord.

the SkyCoord is only allowed 'deg' data, but my data's unit is just 'pix'

So I cannot use 'SkyCoord'.

I try to change the unit of my data from pix to deg, but there is an error.

c_FORS = SkyCoord(x_FORS*u.degree, y_FORS*u.degree, frame='icrs', unit='deg')      
c_dat606 = SkyCoord(x_dat606_left*u.degree, y_dat606_left*u.degree, frame='icrs', unit='deg')

ERROR: 'deg pix' and 'deg' (angle) are not convertible

And next, I try to change the code, put the representation_type='cartesian', but they want me to put 'z'. but my data just two dimension data with unit is just 'pix'.

c_FORS = SkyCoord(x_FORS, y_FORS, representation_type='cartesian')
c_dat606 = SkyCoord(x_dat606_left, y_dat606_left, representation_type='cartesian')

ValueError: x, y, and z are required to instantiate CartesianRepresentation

How can I use the SkyCoord by using my data?


Oh, It's working now.

c_FORS = SkyCoord(list(x_FORS), list(y_FORS), list(np.ones(len(y_FORS))),representation_type='cartesian',unit='m')    
c_dat606 = SkyCoord(list(x_dat606_left), list(y_dat606_left), list(np.ones(len(y_dat606_left))),representation_type='cartesian',unit='m')

above code have my code work. I just make z data which value is all one. after that, I faced ERROR(UnitTypeError: Distance instances require units equivalent to 'm', so cannot set it to ''.), so I put the unit = 'm'

Now it is working.


but,

c_dat606 = SkyCoord(list(x_dat606_left), list(y_dat606_left), list(np.ones(len(y_dat606_left))),representation_type='cartesian',unit='m')
idx, d2d, d3d= c_dat606.match_to_catalog_sky(c_FORS)

above result is strange.. idx is just []..


I found the solution so it will be updated as soon as possible

astropy

0 Answers

Your Answer

Accepted video resources