def skyToPix(self, ra_deg, dec_deg): sin = np.sin cos = np.cos #Parse inputs and allocate space for outputs ra_deg, dec_deg = self.parseInputs(ra_deg, dec_deg) long_deg = ra_deg * 0 lat_deg = long_deg * 0 #Get longitude and latitude relative to defined origin. for i in range(len(ra_deg)): vec = rotate.vecFromRaDec(ra_deg[i], dec_deg[i]) aVec = np.dot( self.Rmatrix, vec) long_deg[i], lat_deg[i] = rotate.raDecFromVec(aVec) long_deg = np.fmod(long_deg + 180, 360.) long_rad = np.radians(long_deg) - np.pi #[-pi,pi] lat_rad = np.radians(lat_deg) #long_rad = np.fmod(long_rad+ np.pi, 2*np.pi) gamma = 1 + cos(lat_rad)* cos(long_rad/2.) gamma = np.sqrt(2/gamma) x = -2*gamma*cos(lat_rad)*sin(long_rad/2) y = gamma*sin(lat_rad) return x, y
def skyToPix(self, ra_deg, dec_deg): sin = np.sin cos = np.cos #Parse inputs and allocate space for outputs ra_deg, dec_deg = self.parseInputs(ra_deg, dec_deg) long_deg = ra_deg * 0 lat_deg = long_deg * 0 #Get longitude and latitude relative to defined origin. for i in range(len(ra_deg)): vec = rotate.vecFromRaDec(ra_deg[i], dec_deg[i]) aVec = np.dot(self.Rmatrix, vec) long_deg[i], lat_deg[i] = rotate.raDecFromVec(aVec) long_deg = np.fmod(long_deg + 180, 360.) long_rad = np.radians(long_deg) - np.pi #[-pi,pi] lat_rad = np.radians(lat_deg) #long_rad = np.fmod(long_rad+ np.pi, 2*np.pi) gamma = 1 + cos(lat_rad) * cos(long_rad / 2.) gamma = np.sqrt(2 / gamma) x = -2 * gamma * cos(lat_rad) * sin(long_rad / 2) y = gamma * sin(lat_rad) return x, y
def getRaDecs(self, mods): """Internal function converting cartesian coords to ra dec""" raDecOut = np.empty( (len(mods), 5)) raDecOut[:,0:3] = mods[:,0:3] for i, row in enumerate(mods): raDecOut[i, 3:5] = r.raDecFromVec(row[3:6]) return raDecOut
def pixToSky(self, x, y): x, y = self.parseInputs(x, y) R = self.Rmatrix invR = np.matrix(R.transpose()) ra_deg = np.empty((len(x), )) dec_deg = np.empty((len(x), )) for i in range(len(x)): phi_rad = np.arctan2(y, x) r = np.hypot(x, y) theta_rad = np.arctan(r) aVec = np.zeros((3, )) aVec[0] = np.cos(theta_rad) aVec[1] = np.sin(theta_rad) * np.cos(phi_rad) aVec[2] = np.sin(theta_rad) * np.sin(phi_rad) vec = np.dot(invR, aVec) vec = np.array(vec)[0] #Convert to 1d array ra_deg[i], dec_deg[i] = rotate.raDecFromVec(vec) return ra_deg, dec_deg
def pixToSky(self, x, y): x, y = self.parseInputs(x, y) R = self.Rmatrix invR = np.matrix(R.transpose()) ra_deg = np.empty( (len(x),)) dec_deg = np.empty( (len(x),)) for i in range(len(x)): phi_rad = np.arctan2(y,x) r = np.hypot(x,y) theta_rad = np.arctan(r) aVec = np.zeros((3,)) aVec[0] = np.cos(theta_rad) aVec[1] = np.sin(theta_rad)*np.cos(phi_rad) aVec[2] = np.sin(theta_rad)*np.sin(phi_rad) vec = np.dot(invR, aVec) vec = np.array(vec)[0] #Convert to 1d array ra_deg[i], dec_deg[i] = rotate.raDecFromVec(vec) return ra_deg, dec_deg