Esempio n. 1
0
    def run(self, slicePoints):
        self._readMap()

        nsideMatch = False
        if 'nside' in slicePoints.keys():
            if slicePoints['nside'] == self.starmapNside:
                slicePoints['starLumFunc'] = self.starMap
                nsideMatch = True
        if not nsideMatch:
            # Compute the healpix for each slicepoint on the nside=64 grid
            indx = radec2pix(self.starmapNside, slicePoints['ra'], slicePoints['dec'])
            slicePoints['starLumFunc'] = self.starMap[indx,:]

        slicePoints['starMapBins'] = self.starMapBins
        return slicePoints
Esempio n. 2
0
    def run(self, slicePoints):
        self._readMap()

        nsideMatch = False
        if 'nside' in slicePoints:
            if slicePoints['nside'] == self.starmapNside:
                slicePoints[f'starLumFunc_{self.filtername}'] = self.starMap
                nsideMatch = True
        if not nsideMatch:
            # Compute the healpix for each slicepoint on the nside=64 grid
            indx = radec2pix(self.starmapNside, slicePoints['ra'], slicePoints['dec'])
            slicePoints[f'starLumFunc_{self.filtername}'] = self.starMap[indx,:]

        slicePoints[f'starMapBins_{self.filtername}'] = self.starMapBins
        return slicePoints
Esempio n. 3
0
def EBVhp(nside, ra=None,dec=None, pixels=None, interp=False):
    """
    Read in a healpix dust map and return values for given RA, Dec values

    nside: Healpixel resolution (2^x)
    ra: RA (can take numpy array)
    dec: Dec (can take numpy array)
    pixles: Healpixel IDs
    interp: Should returned values be interpolated (True) or just nearest neighbor(False)
    """

    if (ra is None) & (dec is None) & (pixels is None):
        raise RuntimeError("Need to set ra,dec or pixels.")

    # Load the map
    if not hasattr(EBVhp, 'nside'):
        EBVhp.nside = nside

    if (not hasattr(EBVhp, 'dustmap')) | (EBVhp.nside != nside) :
        EBVhp.nside = nside
        ebvDataDir = getPackageDir('sims_maps')
        filename = 'DustMaps/dust_nside_%i.npz'%EBVhp.nside
        EBVhp.dustMap = np.load(os.path.join(ebvDataDir,filename))['ebvMap']

    # If we are interpolating to arbitrary positions
    if interp:
        result = hp.get_interp_val(EBVhp.dustMap, np.pi/2. - dec , ra )
    else:
        # If we know the pixel indices we want
        if pixels is not None:
            result = EBVhp.dustMap[pixels]
        # Look up
        else:
            pixels = radec2pix(EBVhp.nside,ra,dec)
            result = EBVhp.dustMap[pixels]

    return result