def from_tree_transform(self, node): if node['direction'] == 'native2celestial': return rotations.RotateNative2Celestial(node["phi"], node["theta"], node["psi"]) elif node['direction'] == 'celestial2native': return rotations.RotateCelestial2Native(node["phi"], node["theta"], node["psi"]) else: return rotations.EulerAngleRotation(node["phi"], node["theta"], node["psi"], axes_order=node["direction"])
def project_to_tangent_plane(ra, dec, ra_ref, dec_ref, scale=1.): """Convert ra/dec coordinates into pixel coordinates using a tangent plane projection. Theprojection's reference point has to be specified. Scale is a convenience parameter that defaults to 1.0, in which case the returned pixel coordinates are also in degree. Scale can be set to a pixel scale to return detector coordinates in pixels Parameters ---------- ra : float Right Ascension in decimal degrees dec: float declination in decimal degrees ra_ref : float Right Ascension of reference point in decimal degrees dec_ref: float declination of reference point in decimal degrees scale : float Multiplicative factor that is applied to the returned values. Default is 1.0 Returns ------- x,y : float pixel coordinates in decimal degrees if scale = 1.0 """ # for zenithal projections, i.e. gnomonic, i.e. TAN: if isinstance(ra_ref, u.Quantity): lonpole = 180. * u.deg else: lonpole = 180. # tangent plane projection from phi/theta to x,y tan = astmodels.Sky2Pix_TAN() # compute native coordinate rotation to obtain phi and theta rot_for_tan = astrotations.RotateCelestial2Native(ra_ref, dec_ref, lonpole) phi_theta = rot_for_tan(ra, dec) # pixel coordinates, x and y are in degree-equivalent x, y = tan(phi_theta[0], phi_theta[1]) x = x * scale y = y * scale return x, y
def from_yaml_tree_transform(self, node, tag, ctx): from astropy.modeling import rotations if node["direction"] == "native2celestial": return rotations.RotateNative2Celestial(node["phi"], node["theta"], node["psi"]) elif node["direction"] == "celestial2native": return rotations.RotateCelestial2Native(node["phi"], node["theta"], node["psi"]) else: return rotations.EulerAngleRotation(node["phi"], node["theta"], node["psi"], axes_order=node["direction"])
def aberrator(arr, ra, dec, v): gamma = 1. / np.sqrt(1 - (v / c)**2.) #print gamma, v/c ra = np.deg2rad(ra) dec = np.deg2rad(dec) dangle = np.arccos( np.cos(np.deg2rad(arr[1])) * np.cos(dec) * np.cos(np.deg2rad(arr[0]) - ra) + np.sin(np.deg2rad(arr[1])) * np.sin(dec)) #print np.rad2deg(np.min(dangle)), np.rad2deg(np.max(dangle)) tanphi = np.sin(dangle) / (gamma * (np.cos(dangle) - v / c)) rotor = rot.RotateCelestial2Native(lon=np.rad2deg(ra), lat=np.rad2deg(dec), lon_pole=5. * u.degree) rotorback = rot.RotateNative2Celestial(lon=np.rad2deg(ra), lat=np.rad2deg(dec), lon_pole=5. * u.degree) lon, lat = rotor(arr[0], arr[1]) #print np.rad2deg(dangle) + lat #print np.rad2deg(dangle) #print np.rad2deg(np.arctan(tanphi)) phi = np.rad2deg(np.arctan(tanphi)) phi = phi + (-1. * np.sign(phi) + 1.) * 90. #print phi #print dangle - np.arctan(tanphi) diff = np.rad2deg(dangle) - phi print diff #latab = np.rad2deg(np.arctan(tanphi)) latab = lat - diff #print (np.rad2deg(dangle) - np.rad2deg(np.arctan(tanphi)))#[0], lon[0], lat[0] #print lat - latab #print lat cellon, cellat = rotorback(lon, latab) return np.vstack((cellon, cellat))
decf = (dec[frame1:frame2]) latf = (lat[frame1+offset:frame2+offset]) lstf = lst[frame1+offset:frame2+offset] #Map parameters crpix = np.array([50,50]) crval = np.array([132.2, -42.9]) cdelt = np.array([-0.003, 0.003]) lonpole = 180. ''' Build a wcs for telescope coordinates rotating Celestial Sphere to native sphere using astropy routines and then using wcs module to build it ''' n2c = rotations.RotateCelestial2Native(lon=crval[0], lat=crval[1], lon_pole=lonpole) new_crval = n2c(crval[0],crval[1]) new_coordinates = n2c(raf*15, decf) w = wcs.WCS(naxis=2) w.wcs.crpix = crpix w.wcs.cdelt = cdelt #w.wcs.crval = new_crval w.wcs.crval = crval w.wcs.ctype = ["TLON-TAN", "TLAT-TAN"] coord = np.transpose(np.vstack((raf*15, decf))) #coord = np.transpose(np.array([new_coordinates[0], new_coordinates[1]])) px = w.all_world2pix(coord, 1) px2 = w.wcs.s2p(coord, 1)