Exemplo n.º 1
0
    def _extract(self):
        ra = self.data[0]
        dec = self.data[1]
        radius = self.data[2]

        self._geom = hs.Circle(
            ra=ra,
            dec=dec,
            radius=radius,
            value=self.value,
        )
Exemplo n.º 2
0
    def _render_catalog(self, maskmap, maskcat, indices):
        """
        Render part of a maskcat into a mask map.

        Parameters
        ----------
        maskmap : `healsparse.HealSparseMap`
           The map must be of `healsparse.WIDE_MASK` type
        maskcat : `np.ndarray`
           Catalog of region information
        indices : `np.ndarray`
           Array of indices from maskcat to render
        """
        box = np.isnan(maskcat['radius'][indices])
        circ = ~box

        ra = maskcat['ra'][indices[circ]]
        dec = maskcat['dec'][indices[circ]]
        radius = maskcat['radius'][indices[circ]]

        shapes = []
        for i in range(ra.size):
            shapes.append(
                healsparse.Circle(ra=ra[i],
                                  dec=dec[i],
                                  radius=radius[i],
                                  value=[self.config.default_bit]))

        ra = maskcat['ra'][indices[box]]
        dec = maskcat['dec'][indices[box]]
        width = maskcat['width'][indices[box]] / np.cos(
            np.deg2rad(maskcat['dec'][indices[box]]))
        height = maskcat['height'][indices[box]]

        for i in range(ra.size):
            shapes.append(
                healsparse.Polygon(ra=[
                    ra[i] - width[i] / 2., ra[i] - width[i] / 2.,
                    ra[i] + width[i] / 2., ra[i] + width[i] / 2.
                ],
                                   dec=[
                                       dec[i] - height[i] / 2.,
                                       dec[i] + height[i] / 2.,
                                       dec[i] + height[i] / 2.,
                                       dec[i] - height[i] / 2.
                                   ],
                                   value=[self.config.default_bit]))

        healsparse.realize_geom(shapes, maskmap)
Exemplo n.º 3
0
 def test_draw_hspmap(self):
     """ Test drawing a HealSparse map """
     nside_sparse = 4096
     nside_coverage = 64
     hspmap = hsp.HealSparseMap.make_empty(nside_coverage,
                                           nside_sparse,
                                           dtype=np.int64,
                                           sentinel=0)
     circ = hsp.Circle(ra=0, dec=0, radius=2.0, value=10)
     hsp.geom.realize_geom([circ], hspmap)
     m = cartosky.Skymap(projection='cyl')
     llcrnrlon, urcrnrlon = 3.0, -3.0
     llcrnrlat, urcrnrlat = -3, 3.0
     m.ax.set_extent([llcrnrlon, urcrnrlon, llcrnrlat, urcrnrlat])
     m.draw_hspmap(hspmap)
     plt.title('HEALPix Zoom (nside=%i)' % nside_sparse)
Exemplo n.º 4
0
    def _get_maskcircle_from_row(self, table_row):
        """
        Get a mask circle from a table row

        Parameters
        ----------
        table_row : `np.ndarray`
           Row of a mask table with RAs and Decs

        Returns
        -------
        maskcircle : `healsparse.Circle`
        """
        maskcircle = healsparse.Circle(ra=table_row['ra'],
                                       dec=table_row['dec'],
                                       radius=table_row['radius'] / 3600.,
                                       value=1)
        return maskcircle
Exemplo n.º 5
0
def load_circles(*, data, values, bands=None, expand=1.0):
    """
    load a set of circle objects from the input data

    Parameters
    ----------
    data: array with fields
        Must have ra, dec, radius, badpix fields
    expand: number, optional
        Factor by which to expand star masks, default 1
    """

    has_bands = 'band' in data.dtype.names
    if bands is not None and not has_bands:
        raise ValueError('bands= sent but no bands present in input data')

    values = _extract_values(values, data.size)

    circles = []
    for i in range(data.size):

        idata = data[i]

        if bands is not None:
            band = idata['band'].strip()
            if band not in bands:
                continue

        radius = idata['radius'] / 3600.0
        radius *= expand

        circle = hs.Circle(
            ra=idata['ra'],
            dec=idata['dec'],
            radius=radius,
            value=values[i],
        )
        circles.append(circle)

    return circles