Exemple #1
0
def make_wcs(shape, galactic=False):
    """
    Create a simple celestial WCS object in either the ICRS or Galactic
    coordinate frame.

    Parameters
    ----------
    shape : 2-tuple of int
        The shape of the 2D array to be used with the output
        `~astropy.wcs.WCS` object.

    galactic : bool, optional
        If `True`, then the output WCS will be in the Galactic
        coordinate frame.  If `False` (default), then the output WCS
        will be in the ICRS coordinate frame.

    Returns
    -------
    wcs : `~astropy.wcs.WCS` object
        The world coordinate system (WCS) transformation.

    See Also
    --------
    make_imagehdu

    Examples
    --------
    >>> from photutils.datasets import make_wcs
    >>> shape = (100, 100)
    >>> wcs = make_wcs(shape)
    >>> print(wcs.wcs.crpix)  # doctest: +FLOAT_CMP
    [50. 50.]
    >>> print(wcs.wcs.crval)  # doctest: +FLOAT_CMP
    [197.8925      -1.36555556]
    """

    wcs = WCS(naxis=2)
    rho = np.pi / 3.
    scale = 0.1 / 3600.

    if astropy_version < '3.1':
        wcs._naxis1 = shape[1]  # nx
        wcs._naxis2 = shape[0]  # ny
    else:
        wcs.pixel_shape = shape

    wcs.wcs.crpix = [shape[1] / 2, shape[0] / 2]  # 1-indexed (x, y)
    wcs.wcs.crval = [197.8925, -1.36555556]
    wcs.wcs.cunit = ['deg', 'deg']
    wcs.wcs.cd = [[-scale * np.cos(rho), scale * np.sin(rho)],
                  [scale * np.sin(rho), scale * np.cos(rho)]]
    if not galactic:
        wcs.wcs.radesys = 'ICRS'
        wcs.wcs.ctype = ['RA---TAN', 'DEC--TAN']
    else:
        wcs.wcs.ctype = ['GLON-CAR', 'GLAT-CAR']

    return wcs
Exemple #2
0
def make_wcs(shape, galactic=False):
    """
    Create a simple celestial WCS object in either the ICRS or Galactic
    coordinate frame.

    Parameters
    ----------
    shape : 2-tuple of int
        The shape of the 2D array to be used with the output
        `~astropy.wcs.WCS` object.

    galactic : bool, optional
        If `True`, then the output WCS will be in the Galactic
        coordinate frame.  If `False` (default), then the output WCS
        will be in the ICRS coordinate frame.

    Returns
    -------
    wcs : `~astropy.wcs.WCS` object
        The world coordinate system (WCS) transformation.

    See Also
    --------
    make_imagehdu

    Examples
    --------
    >>> from photutils.datasets import make_wcs
    >>> shape = (100, 100)
    >>> wcs = make_wcs(shape)
    >>> print(wcs.wcs.crpix)  # doctest: +FLOAT_CMP
    [50. 50.]
    >>> print(wcs.wcs.crval)  # doctest: +FLOAT_CMP
    [197.8925      -1.36555556]
    """

    wcs = WCS(naxis=2)
    rho = np.pi / 3.
    scale = 0.1 / 3600.

    if astropy_version < '3.1':
        wcs._naxis1 = shape[1]     # nx
        wcs._naxis2 = shape[0]     # ny
    else:
        wcs.pixel_shape = shape

    wcs.wcs.crpix = [shape[1] / 2, shape[0] / 2]     # 1-indexed (x, y)
    wcs.wcs.crval = [197.8925, -1.36555556]
    wcs.wcs.cunit = ['deg', 'deg']
    wcs.wcs.cd = [[-scale * np.cos(rho), scale * np.sin(rho)],
                  [scale * np.sin(rho), scale * np.cos(rho)]]
    if not galactic:
        wcs.wcs.radesys = 'ICRS'
        wcs.wcs.ctype = ['RA---TAN', 'DEC--TAN']
    else:
        wcs.wcs.ctype = ['GLON-CAR', 'GLAT-CAR']

    return wcs
Exemple #3
0
def make_wcs(shape):
    """
    Create a simple celestial WCS object.

    Parameters
    ----------
    shape : 2-tuple of int
        The shape of the 2D array to be used with the output
        `~astropy.wcs.WCS` object.

    Returns
    -------
    wcs : `~astropy.wcs.WCS` object
        The world coordinate system (WCS) transformation.

    See Also
    --------
    make_imagehdu

    Examples
    --------
    >>> from photutils.datasets import make_wcs
    >>> shape = (100, 100)
    >>> wcs = make_wcs(shape)
    >>> print(wcs.wcs.crpix)
    [ 50.  50.]
    >>> print(wcs.wcs.crval)
    [ 197.8925       -1.36555556]
    """

    wcs = WCS(naxis=2)
    rho = np.pi / 3.
    scale = 0.1 / 3600.
    wcs._naxis1 = shape[1]  # nx
    wcs._naxis2 = shape[0]  # ny
    wcs.wcs.crpix = [shape[1] / 2, shape[0] / 2]  # 1-indexed (x, y)
    wcs.wcs.crval = [197.8925, -1.36555556]
    wcs.wcs.cunit = ['deg', 'deg']
    wcs.wcs.radesys = 'ICRS'
    wcs.wcs.cd = [[-scale * np.cos(rho), scale * np.sin(rho)],
                  [scale * np.sin(rho), scale * np.cos(rho)]]
    wcs.wcs.ctype = ['RA---TAN', 'DEC--TAN']

    return wcs
Exemple #4
0
def create_wcs(ra, dec, cenchan):
    """Creates a fake WCS header to generate a MWA primary beam response

    Arguments:
        ra {float} -- Observation pointing direction in degrees
        dec {float} -- Observation pointing direction in degrees
        cenchan {float} -- Central channel

    Returns:
        {astropy.wcs.WCS} -- WCS information describing the observation
    """
    pixscale = 0.6 / float(cenchan)
    # print("pixscale: ", pixscale)
    # print("cenchan: ", cenchan)
    w = WCS(naxis=2)
    w.wcs.crpix = [4000, 4000]
    w.wcs.cdelt = np.array([-pixscale, pixscale])
    w.wcs.crval = [ra, dec]
    w.wcs.ctype = ["RA---SIN", "DEC--SIN"]
    w.wcs.cunit = ["deg", "deg"]
    w._naxis1 = 8000
    w._naxis2 = 8000

    return w
Exemple #5
0
wcs = WCS(naxis=2)
wcs.wcs.cdelt = [dra, ddec]
wcs.wcs.crval = [0, 0]
wcs.wcs.ctype = ['RA---CAR', 'DEC--CAR']
wcs.wcs.crpix = [1 + 180 / dra, 1 + 90 / np.fabs(ddec)]
dl, dw_q, dw_u = nmt.synfast_spherical(
    -1,
    [cltt + nltt, clte + nlte, 0 * cltt, clee + nlee, 0 * clee, clbb + nlbb],
    [0, 2],
    wcs=wcs)
sl, sw_q, sw_u = nmt.synfast_spherical(-1, [
    cltt / (l + 1.)**1.5, 0 * clte, 0 * cltt, clee /
    (l + 1.)**1.5, 0 * clee, 0.5 * clee / (l + 1.)**1.5
], [0, 2],
                                       wcs=wcs)
wcs._naxis2, wcs._naxis1 = dl.shape

mask = getmaskapoana_car(wcs, 20., 0.4, dec0=90.)
write_flat_map("mps_car_small.fits", np.array([dl, dw_q, dw_u]), wcs,
               ["T", "Q", "U"])
write_flat_map("tmp_car_small.fits", np.array([sl, sw_q, sw_u]), wcs,
               ["T", "Q", "U"])
write_flat_map("msk_car_small.fits", mask, wcs, "mask")

plt.figure()
plt.imshow(dl * mask, interpolation='nearest', origin='lower')
plt.figure()
plt.imshow(dw_q * mask, interpolation='nearest', origin='lower')
plt.figure()
plt.imshow(dw_u * mask, interpolation='nearest', origin='lower')
plt.figure()