def get_rotated_pixels(shape_source, wcs_source, shape_target, wcs_target, inverse=False): """ Given a source geometry (shape_source,wcs_source) return the pixel positions in the target geometry (shape_target,wcs_target) if the source geometry were rotated such that its center lies on the center of the target geometry. WARNING: Only currently tested for a rotation along declination from one CAR geometry to another CAR geometry. """ from enlib import coordinates # what are the center coordinates of each geometris center_source = enmap.pix2sky(shape_source, wcs_source, (shape_source[0] / 2., shape_source[1] / 2.)) center_target = enmap.pix2sky(shape_target, wcs_target, (shape_target[0] / 2., shape_target[1] / 2.)) decs, ras = center_source dect, rat = center_target # what are the angle coordinates of each pixel in the target geometry pos_target = enmap.posmap(shape_target, wcs_target) lra = pos_target[1, :, :].ravel() ldec = pos_target[0, :, :].ravel() del pos_target # recenter the angle coordinates of the target from the target center to the source center if inverse: newcoord = coordinates.decenter((lra, ldec), (rat, dect, ras, decs)) else: newcoord = coordinates.recenter((lra, ldec), (rat, dect, ras, decs)) del lra del ldec # reshape these new coordinates into enmap-friendly form new_pos = np.empty((2, shape_target[0], shape_target[1])) new_pos[0, :, :] = newcoord[1, :].reshape(shape_target) new_pos[1, :, :] = newcoord[0, :].reshape(shape_target) del newcoord # translate these new coordinates to pixel positions in the target geometry based on the source's wcs pix_new = enmap.sky2pix(shape_source, wcs_source, new_pos) return pix_new
def cel2foc(cpos, site, mjd, bore): baz, bel = bore hpos = coordinates.transform("cel","hor",cpos,time=mjd,site=site) fpos = coordinates.recenter(hpos, [baz,bel,0,0]) return fpos
def cel2foc(cpos, site, mjd, bore): baz, bel = bore hpos = coordinates.transform("cel", "hor", cpos, time=mjd, site=site) fpos = coordinates.recenter(hpos, [baz, bel, 0, 0]) return fpos
def foc2cel(fpos, site, mjd, bore): baz, bel = bore hpos = coordinates.recenter(fpos, [0,0,baz,bel]) cpos = coordinates.transform("hor","cel",hpos,time=mjd,site=site) return cpos
def foc2cel(fpos, site, mjd, bore): baz, bel = bore hpos = coordinates.recenter(fpos, [0, 0, baz, bel]) cpos = coordinates.transform("hor", "cel", hpos, time=mjd, site=site) return cpos