def get_paths(self, ctr_ra, ctr_dec, info): paths = [] keys = list(info.keys()) keys.sort() for key in keys: path = [wcs.add_offset_radec(ctr_ra, ctr_dec, dra, ddec) for dra, ddec in info[key]["polygon"]] paths.append((key, path)) return paths
def add_offset_xy(self, x, y, delta_deg_x, delta_deg_y): # calculate ra/dec of x,y pixel ra_deg, dec_deg = self.pixtoradec(x, y) # add offsets ra2_deg, dec2_deg = wcs.add_offset_radec(ra_deg, dec_deg, delta_deg_x, delta_deg_y) # then back to new pixel coords x2, y2 = self.radectopix(ra2_deg, dec2_deg) return (x2, y2)
def calc_dither5(self, n): idx = n - 1 l = ((0.0, 0.0), (1.0, -2.0), (2.0, 1.0), (-1.0, 2.0), (-2.0, -1.0)) mra, mdec = l[idx] dra = float(self.w.dith1.get_text()) / 3600.0 ddec = float(self.w.dith2.get_text()) / 3600.0 ## ctr_ra, ctr_dec = wcs.add_offset_radec( ## self.ctr_ra_deg, self.ctr_dec_deg, mra * dra, mdec * ddec) ctr_ra, ctr_dec = wcs.add_offset_radec( self.ctr_ra_deg, self.ctr_dec_deg, mra * dra + self.ra_off_deg, mdec * ddec + self.dec_off_deg ) return (ctr_ra, ctr_dec)
def __init__(self, ra_ll_deg, dec_ll_deg, xs, ys, image, **params): """ Shape for drawing ccd window Parameters ---------- ra_ll_deg : float lower left coordinate in ra (deg) dec_ll_deg : float lower left y coord in dec (deg) xs : float x size in degrees ys : float y size in degrees image : `~ginga.AstroImage` image to plot Window on """ points_wcs = ((ra_ll_deg, dec_ll_deg), wcs.add_offset_radec(ra_ll_deg, dec_ll_deg, xs, 0.0), wcs.add_offset_radec(ra_ll_deg, dec_ll_deg, xs, ys), wcs.add_offset_radec(ra_ll_deg, dec_ll_deg, 0.0, ys)) self.points = [image.radectopix(ra, dec) for (ra, dec) in points_wcs] super(CCDWin, self).__init__(self.points, **params) self.name = params.pop('name', 'window')
def calc_ditherN(self, n): n = n - 1 rdith = float(self.w.dith1.get_text()) / 3600.0 tdith = float(self.w.dith2.get_text()) ndith = float(self.dither_steps) sin_res = numpy.sin(numpy.radians(n * 360.0 / ndith + tdith)) cos_res = numpy.cos(numpy.radians(n * 360.0 / ndith + tdith)) self.logger.debug("sin=%f cos=%f" % (sin_res, cos_res)) ## ctr_ra, ctr_dec = wcs.add_offset_radec( ## self.ctr_ra_deg, self.ctr_dec_deg, cos_res * rdith, sin_res * rdith) ctr_ra, ctr_dec = wcs.add_offset_radec( self.ctr_ra_deg, self.ctr_dec_deg, cos_res * rdith + self.ra_off_deg, sin_res * rdith + self.dec_off_deg ) return (ctr_ra, ctr_dec)
def calc_radius_xy(self, x, y, radius_deg): """Calculate a radius (in pixels) from the point (x, y) to a circle defined by radius in degrees. """ # calculate ra/dec of x,y pixel ra_deg, dec_deg = self.pixtoradec(x, y) # Calculate position 1 degree from the given one # NOTE: this needs to add in DEC, not RA ra2_deg, dec2_deg = wcs.add_offset_radec(ra_deg, dec_deg, 0.0, 1.0) # Calculate the length of this segment--it is pixels/deg x2, y2 = self.radectopix(ra2_deg, dec2_deg) px_per_deg_e = math.sqrt(math.fabs(x2 - x)**2 + math.fabs(y2 - y)**2) # calculate radius based on desired radius_deg radius_px = px_per_deg_e * radius_deg return radius_px
def calc_radius_xy(self, x, y, radius_deg): """Calculate a radius (in pixels) from the point (x, y) to a circle defined by radius in degrees. """ # calculate ra/dec of x,y pixel ra_deg, dec_deg = self.pixtoradec(x, y) # Calculate position 1 degree from the given one # NOTE: this needs to add in DEC, not RA ra2_deg, dec2_deg = wcs.add_offset_radec(ra_deg, dec_deg, 0.0, 1.0) # Calculate the length of this segment--it is pixels/deg x2, y2 = self.radectopix(ra2_deg, dec2_deg) px_per_deg_e = math.sqrt(math.fabs(x2 - x) ** 2 + math.fabs(y2 - y) ** 2) # calculate radius based on desired radius_deg radius_px = px_per_deg_e * radius_deg return radius_px
def offset_pt(self, pt, xoff, yoff): x, y = pt return wcs.add_offset_radec(x, y, xoff, yoff)
def offset_pt(self, pts, offset): x, y = np.transpose(pts) xoff, yoff = np.transpose(offset) res_arr = wcs.add_offset_radec(x, y, xoff, yoff) return np.transpose(res_arr)
def calc_dither1(self, n): ctr_ra, ctr_dec = wcs.add_offset_radec(self.ctr_ra_deg, self.ctr_dec_deg, self.ra_off_deg, self.dec_off_deg) return (ctr_ra, ctr_dec)