Coverage for python/lsst/sims/catUtils/mixins/PhoSimSupport.py : 14%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
""" Parameters ---------- ra0, dec0 are the coordinates of the original field center in radians
ra1, dec1 are the coordinates of the new field center in radians
The transform() method of this class operates by first applying a rotation that carries the original field center into the new field center. Points are then transformed into a basis in which the unit vector defining the new field center is the x-axis. A rotation about the x-axis is applied so that a point that was due north of the original field center is still due north of the field center at the new location. Finally, points are transformed back into the original x,y,z bases. """
self._ra0 = ra0 self._dec0 = dec0 self._ra1 = ra1 self._dec1 = dec1
# find the rotation that carries the original field center # to the new field center xyz = cartesianFromSpherical(ra0, dec0) xyz1 = cartesianFromSpherical(ra1, dec1) if np.abs(1.0-np.dot(xyz, xyz1))<1.0e-10: self._transformation = np.identity(3, dtype=float) return
first_rotation = rotationMatrixFromVectors(xyz, xyz1)
# create a basis set in which the unit vector # defining the new field center is the x axis xx = np.dot(first_rotation, xyz) rng = np.random.RandomState(99) mag = np.NaN while np.abs(mag)<1.0e-20 or np.isnan(mag): random_vec = rng.random_sample(3) comp = np.dot(random_vec, xx) yy = random_vec - comp*xx mag = np.sqrt((yy**2).sum()) yy /= mag
zz = np.cross(xx, yy)
to_self_bases = np.array([xx, yy, zz])
out_of_self_bases =to_self_bases.transpose()
# Take a point due north of the original field # center. Apply first_rotation to carry it to # the new field. Transform it to the [xx, yy, zz] # bases and find the rotation about xx that will # make it due north of the new field center. # Finally, transform back to the original bases. d_dec = np.radians(0.1) north = cartesianFromSpherical(ra0,dec0+d_dec)
north = np.dot(first_rotation, north)
#print(np.degrees(sphericalFromCartesian(north)))
north_true = cartesianFromSpherical(ra1, dec1+d_dec)
north = np.dot(to_self_bases, north) north_true = np.dot(to_self_bases, north_true) north = np.array([north[1], north[2]]) north /= np.sqrt((north**2).sum()) north_true = np.array([north_true[1], north_true[2]]) north_true /= np.sqrt((north_true**2).sum())
c = north_true[0]*north[0]+north_true[1]*north[1] s = north[0]*north_true[1]-north[1]*north_true[0] norm = np.sqrt(c*c+s*s) c = c/norm s = s/norm
nprime = np.array([c*north[0]-s*north[1], s*north[0]+c*north[1]])
yz_rotation = np.array([[1.0, 0.0, 0.0], [0.0, c, -s], [0.0, s, c]])
second_rotation = np.dot(out_of_self_bases, np.dot(yz_rotation, to_self_bases))
self._transformation = np.dot(second_rotation, first_rotation)
""" ra, dec are in radians; return the RA, Dec coordinates of the point about the new field center """ xyz = cartesianFromSpherical(ra, dec).transpose() xyz = np.dot(self._transformation, xyz).transpose() ra_out, dec_out = sphericalFromCartesian(xyz) return ra_out, dec_out |