Beispiel #1
0
def read_desdr2(ra,dec,radius=1.5):
    """ Read the reference catalog in a localized region.

    Parameters
    ----------
    ra : ra (deg)
    dec : dec (deg)
    radius : regional radius (deg)

    Returns
    -------
    refcat : reference catalog columns
    """
    
    nside = 32
    pixels = ang2disc(nside, ra, dec, radius, inclusive=True)
    dirname = '/data/des40.b/data/y6a1/gold/1.1/healpix'
    basename = 'y6_gold_1_0_%05d.fits'
    filenames = [os.path.join(dirname,basename%p) for p in pixels]
    #filenames = [f for f in filenames if os.path.exists(f)]
    columns = DESDR2_COLUMNS
    refcat = utils.load_infiles(filenames,columns=columns)
    refcat = refcat[refcat['WAVG_MAG_PSF_R'] < 21]

    mapping = dict(zip(DESDR2_COLUMNS,REFCAT_COLUMNS))
    new_names = [mapping[n] for n in refcat.dtype.names]
    refcat.dtype.names = new_names

    return refcat
Beispiel #2
0
 def _cache(self, name=None):
     pixel_area = hp.nside2pixarea(self.nside, degrees=True)
     vec = ang2vec(self.lon, self.lat)
     #self.pix = query_disc(self.nside,vec,self.extension)
     self.pix = ang2disc(self.nside,
                         self.lon,
                         self.lat,
                         self.extension,
                         inclusive=True)
     self._norm = 1. / (len(self.pix) * pixel_area)
Beispiel #3
0
def get_local_catalog(ra, dec, radius, catalog, **kwargs):
    """ Get local catalog from disk 

    Parameters
    ----------
    ra : right ascension of catalog pixel (deg)
    dec: declination of catalog pixel (deg)
    catalog : catalog name
    
    Returns
    -------
    cat : object catalog
    """
    from ugali.utils.healpix import ang2disc

    mapping = {}
    if 'gaia' in catalog.lower():
        nside = 32
        dirname = '/data/des40.b/data/gaia/dr2/healpix'
        basename = 'GaiaSource_%05d.fits'
        columns = ['SOURCE_ID', 'RA', 'DEC']
        mapping.update({'RA': '_RAJ2000', 'DEC': '_DEJ2000'})
    elif 'atlas' in catalog.lower():
        nside = 32
        dirname = '/data/des40.b/data/atlas-refcat2/healpix'
        basename = 'atlas-refcat2_%05d.fits'
        columns = ['OBJID', 'RA', 'DEC', 'G']
        mapping.update({})
    elif 'ps1' in catalog.lower():
        nside = 32
        dirname = '/data/des40.b/data/ps1/dr1/healpix'
        basename = 'ps1_dr1_%05d.fits'
        columns = ['RA', 'DEC']
    elif 'decals' in catalog.lower():
        nside = 32
        dirname = '/data/des40.b/data/decals/dr8/south_healpix'
        basename = 'decals-dr8-sweep_%05d.fits'
        columns = ['OBJID', 'RA', 'DEC']
    else:
        raise Exception('Unrecognized catalog: %s' % catalog)

    pixels = ang2disc(nside, ra, dec, radius, inclusive=True)
    filenames = [os.path.join(dirname, basename % p) for p in pixels]
    filenames = [f for f in filenames if os.path.exists(f)]
    cat = load_infiles(filenames, columns=columns)

    names = [mapping.get(n, n) for n in cat.dtype.names]
    cat.dtype.names = names
    return cat
Beispiel #4
0
    def calc_surface_intensity(self, factor=10):
        """Calculate the surface intensity for each pixel in the interior
        region of the ROI. Pixels are adaptively subsampled around the
        kernel centroid out to a radius of 'factor * max_pixrad'.

        Parameters:
        -----------
        factor : the radius of the oversample region in units of max_pixrad

        Returns:
        --------
        surface_intensity : the surface intensity at each pixel
        """
        # First we calculate the surface intensity at native resolution
        pixels = self.roi.pixels_interior
        nside_in = self.config['coords']['nside_pixel']
        surface_intensity = self.kernel.pdf(pixels.lon, pixels.lat)

        # Then we recalculate the surface intensity around the kernel
        # centroid at higher resolution
        for i in np.arange(1, 5):
            # Select pixels within the region of interest
            nside_out = 2**i * nside_in
            radius = factor * np.degrees(hp.max_pixrad(nside_out))
            pix = ang2disc(nside_in,
                           self.kernel.lon,
                           self.kernel.lat,
                           radius,
                           inclusive=True)

            # Select pix within the interior region of the ROI
            idx = ugali.utils.healpix.index_pix_in_pixels(pix, pixels)
            pix = pix[(idx >= 0)]
            idx = idx[(idx >= 0)]

            # Reset the surface intensity for the subsampled pixels
            subpix = ugali.utils.healpix.ud_grade_ipix(pix, nside_in,
                                                       nside_out)
            pix_lon, pix_lat = pix2ang(nside_out, subpix)
            surface_intensity[idx] = np.mean(self.kernel.pdf(pix_lon, pix_lat),
                                             axis=1)

        return surface_intensity
Beispiel #5
0
def read_refcat(ra,dec,radius=1.5):
    """ Read the reference catalog in a localized region.

    Parameters
    ----------
    ra : ra (deg)
    dec : dec (deg)
    radius : regional radius (deg)

    Returns
    -------
    refcat : reference catalog columns
    """
    
    nside = 32
    pixels = ang2disc(nside, ra, dec, radius, inclusive=True)
    dirname = '/data/des40.b/data/atlas-refcat2/healpix'
    basename = 'atlas-refcat2_%05d.fits'
    filenames = [os.path.join(dirname,basename%p) for p in pixels]
    columns = REFCAT_COLUMNS
    refcat = utils.load_infiles(filenames,columns=columns)
    return refcat
Beispiel #6
0
    def calc_surface_intensity(self, factor=10):
        """Calculate the surface intensity for each pixel in the interior
        region of the ROI. Pixels are adaptively subsampled around the
        kernel centroid out to a radius of 'factor * max_pixrad'.

        Parameters:
        -----------
        factor : the radius of the oversample region in units of max_pixrad

        Returns:
        --------
        surface_intensity : the surface intensity at each pixel
        """
        # First we calculate the surface intensity at native resolution
        pixels = self.roi.pixels_interior
        nside_in = self.config['coords']['nside_pixel']
        surface_intensity = self.kernel.pdf(pixels.lon,pixels.lat)

        # Then we recalculate the surface intensity around the kernel
        # centroid at higher resolution
        for i in np.arange(1,5):
            # Select pixels within the region of interest
            nside_out = 2**i * nside_in
            radius = factor*np.degrees(hp.max_pixrad(nside_out))
            pix = ang2disc(nside_in,self.kernel.lon,self.kernel.lat,
                           radius,inclusive=True)

            # Select pix within the interior region of the ROI
            idx = ugali.utils.healpix.index_pix_in_pixels(pix,pixels)
            pix = pix[(idx >= 0)]; idx = idx[(idx >= 0)]

            # Reset the surface intensity for the subsampled pixels
            subpix = ugali.utils.healpix.ud_grade_ipix(pix,nside_in,nside_out)
            pix_lon,pix_lat = pix2ang(nside_out,subpix)
            surface_intensity[idx]=np.mean(self.kernel.pdf(pix_lon,pix_lat),axis=1)

        return surface_intensity