Пример #1
0
    def _map_pixel_coordinates(self, coord0, d0, incl0, pa0):
        shape = (self.ref_header["NAXIS2"], self.ref_header["NAXIS1"])
        yindices, xindices = np.mgrid[0 : shape[0], 0 : shape[1]]
        self.y_indices_flat = yindices.flatten()
        self.x_indices_flat = xindices.flatten()
        self.ra, self.dec = self.ref_wcs.all_pix2world(self.x_indices_flat, self.y_indices_flat, 0)
        coords = SkyCoord(self.ra, self.dec, "icrs", unit="deg")
        pixel_R, pixel_PA, sky_radius = galaxy_coords(coords, coord0, pa0, incl0, d0)
        self.pixel_R = pixel_R.kpc
        self.image_sky_r = sky_radius  # arcsec units
        self.image_pa = pixel_PA.deg

        # Measure position on the sky
        # TODO put into galaxy_coords?
        delta_ra = coords.ra - coord0.ra
        P = Angle(
            np.arctan2(
                np.sin(delta_ra.rad),
                np.cos(coord0.dec.rad) * np.tan(coords.dec.rad) - np.sin(coord0.dec.rad) * np.cos(delta_ra.rad),
            ),
            unit=u.rad,
        )
        # Reset wrap-around range
        s = np.where(P < 0.0)[0]
        P[s] = Angle(2.0 * np.pi, unit=u.rad) + P[s]
        P -= pa0
        s = np.where(P.deg < 0.0)[0]
        P[s] += Angle(2.0 * np.pi, unit=u.rad)
        self.image_sky_pa = P.deg
Пример #2
0
    def _map_pixel_coordinates(self, coord0, d0, incl0, pa0):
        shape = (self.ref_header['NAXIS2'], self.ref_header['NAXIS2'])
        yindices, xindices = np.mgrid[0:shape[0], 0:shape[1]]
        y_indices_flat = yindices.flatten()
        x_indices_flat = xindices.flatten()
        ra, dec = self.ref_wcs.all_pix2world(x_indices_flat, y_indices_flat, 0)
        coords = SkyCoord(ra, dec, "icrs", unit="deg")
        pixel_R, pixel_PA, sky_radius = galaxy_coords(coords,
                                                      coord0,
                                                      pa0,
                                                      incl0,
                                                      d0)
        self.image_r = pixel_R.kpc.reshape(*shape)
        self.image_sky_r = sky_radius.reshape(*shape)  # arcsec units
        self.image_pa = pixel_PA.deg.reshape(*shape)

        # Make an image of position angle on sky
        self.image_sky_pa = -1. * np.ones(shape, dtype=np.float)
        delta_ra = coords.ra - coord0.ra
        P = Angle(np.arctan2(np.sin(delta_ra.rad),
                             np.cos(coord0.dec.rad) * np.tan(coords.dec.rad)
                             - np.sin(coord0.dec.rad) * np.cos(delta_ra.rad)),
                  unit=u.rad)
        # Reset wrap-around range
        s = np.where(P < 0.)[0]
        P[s] = Angle(2. * np.pi, unit=u.rad) + P[s]
        P -= pa0
        s = np.where(P.deg < 0.)[0]
        P[s] += Angle(2. * np.pi, unit=u.rad)
        self.image_sky_pa = P.deg.reshape(*shape)

        fits.writeto("_sky_pa_image.fits", self.image_sky_pa, clobber=True)