Esempio n. 1
0
    def angdist2pixdist(self, img, angdist, pa, location=None):
        """Returns the distance in pixels for a given angular distance in degrees

        pa - position angle in degrees east of north
        location - x and y location of center
        """
        import functions as func

        if location is None:
            x1 = int(img.image_arr.shape[2] / 2.0)
            y1 = int(img.image_arr.shape[3] / 2.0)
        else:
            x1, y1 = location

        pa_pix = self.get_rot(img, location)
        x0 = x1 - 10.0 * N.sin((pa + pa_pix) * N.pi / 180.0)
        y0 = y1 - 10.0 * N.cos((pa + pa_pix) * N.pi / 180.0)
        ra0, dec0 = img.pix2sky([x0, y0])
        x2 = x1 + 10.0 * N.sin((pa + pa_pix) * N.pi / 180.0)
        y2 = y1 + 10.0 * N.cos((pa + pa_pix) * N.pi / 180.0)
        ra2, dec2 = img.pix2sky([x2, y2])

        angdist12 = func.angsep(ra0, dec0, ra2, dec2)  # degrees
        pixdist12 = N.sqrt((x0 - x2)**2 + (y0 - y2)**2)  # pixels
        if angdist12 > 0.0:
            result = angdist * pixdist12 / angdist12
            if N.isnan(result) or result <= 0.0:
                result = N.mean(img.wcs_obj.acdelt[0:2])
        else:
            result = N.mean(img.wcs_obj.acdelt[0:2])
        return result
Esempio n. 2
0
    def angdist2pixdist(self, img, angdist, pa, location=None):
        """Returns the distance in pixels for a given angular distance in degrees

        pa - position angle in degrees east of north
        location - x and y location of center
        """
        import functions as func

        if location is None:
            x1 = int(img.image_arr.shape[2] / 2.0)
            y1 = int(img.image_arr.shape[3] / 2.0)
        else:
            x1, y1 = location

        pa_pix = self.get_rot(img, location)
        x0 = x1 - 10.0 * N.sin( (pa + pa_pix) * N.pi / 180.0 )
        y0 = y1 - 10.0 * N.cos( (pa + pa_pix) * N.pi / 180.0 )
        ra0, dec0 = img.pix2sky([x0, y0])
        x2 = x1 + 10.0 * N.sin( (pa + pa_pix) * N.pi / 180.0 )
        y2 = y1 + 10.0 * N.cos( (pa + pa_pix) * N.pi / 180.0 )
        ra2, dec2 = img.pix2sky([x2, y2])

        angdist12 = func.angsep(ra0, dec0, ra2, dec2) # degrees
        pixdist12 = N.sqrt( (x0 - x2)**2 + (y0 - y2)**2 ) # pixels
        if angdist12 > 0.0:
            result = angdist * pixdist12 / angdist12
            if N.isnan(result) or result <= 0.0:
                result = N.mean(img.wcs_obj.acdelt[0:2])
        else:
            result = N.mean(img.wcs_obj.acdelt[0:2])
        return result
Esempio n. 3
0
    def pixdist2angdist(self, img, pixdist, pa, location=None):
        """Returns the angular distance in degrees for a given distance in pixels

        pa - position angle in degrees CCW from +y axis
        location - x and y location of center
        """
        import functions as func

        if location is None:
            x1 = int(img.image_arr.shape[2] / 2.0)
            y1 = int(img.image_arr.shape[3] / 2.0)
        else:
            x1, y1 = location

        x0 = x1 - pixdist / 2.0 * N.sin(pa * N.pi / 180.0)
        y0 = y1 - pixdist / 2.0 * N.cos(pa * N.pi / 180.0)
        ra0, dec0 = img.pix2sky([x0, y0])
        x2 = x1 + pixdist / 2.0 * N.sin(pa * N.pi / 180.0)
        y2 = y1 + pixdist / 2.0 * N.cos(pa * N.pi / 180.0)
        ra2, dec2 = img.pix2sky([x2, y2])

        angdist12 = func.angsep(ra0, dec0, ra2, dec2)  # degrees
        return angdist12
Esempio n. 4
0
    def pixdist2angdist(self, img, pixdist, pa, location=None):
        """Returns the angular distance in degrees for a given distance in pixels

        pa - position angle in degrees CCW from +y axis
        location - x and y location of center
        """
        import functions as func

        if location is None:
            x1 = int(img.image_arr.shape[2] / 2.0)
            y1 = int(img.image_arr.shape[3] / 2.0)
        else:
            x1, y1 = location

        x0 = x1 - pixdist / 2.0 * N.sin(pa * N.pi / 180.0)
        y0 = y1 - pixdist / 2.0 * N.cos(pa * N.pi / 180.0)
        ra0, dec0 = img.pix2sky([x0, y0])
        x2 = x1 + pixdist / 2.0 * N.sin(pa * N.pi / 180.0)
        y2 = y1 + pixdist / 2.0 * N.cos(pa * N.pi / 180.0)
        ra2, dec2 = img.pix2sky([x2, y2])

        angdist12 = func.angsep(ra0, dec0, ra2, dec2) # degrees
        return angdist12