def smoothing(m, fwhm, nest=True):
    if fwhm <= 0:
        return m
    nside = hpf.npix2nside(len(m))
    if nest:
        return hps.smoothing(m[hpf.ring2nest(nside, np.arange(hpf.nside2npix(nside)))], fwhm=fwhm)[hpf.nest2ring(nside, np.arange(hpf.nside2npix(nside)))]
    else:
        return hps.smoothing(m, fwhm=fwhm)
Exemplo n.º 2
0
    def add_pix(self, order, ipix, nest=True):
        """
        add a given HEALPix pixel number to the current object
        """
        self._counter += 1
        # force consistency to prevent too large interval array
        if self._counter == 1000:
            self._ensure_consistency()
            self._counter = 0
        from healpy import pixelfunc

        if order > MOC.HPY_MAX_NORDER:
            raise Exception('norder can not be greater than MOC max norder')

        if not nest:
            ipix = pixelfunc.ring2nest(ipix)

        p1 = ipix
        p2 = ipix + 1
        shift = 2 * (MOC.HPY_MAX_NORDER - order)

        self._interval_set.add((p1 << shift, p2 << shift))
                             (len(subublindex) * nt / tavg,
                              12 * nside_standard**2))))

        average_size = nside_standard / nside
        Bfile = '/home/omniscope/data/GSM_data/Bmatrix_nside%i_to_nside%i.bin' % (
            nside_standard, nside)
        if os.path.isfile(Bfile):
            B = np.fromfile(Bfile, dtype='float32').reshape(
                (12 * nside**2, 12 * nside_standard**2))
        else:
            B = np.zeros((12 * nside**2, 12 * nside_standard**2),
                         dtype='float32')
            for ringpix in range(12 * nside_standard**2):
                B[hpf.nest2ring(
                    nside,
                    hpf.ring2nest(nside_standard, ringpix) / average_size**2),
                  ringpix] = average_size**-2
            B.tofile(
                '/home/omniscope/data/GSM_data/Bmatrix_nside%i_to_nside%i.bin'
                % (nside_standard, nside))
        if nside <= 4 and nside != nside_standard:
            equatorial_GSM = B.dot(equatorial_GSM_standard)

        ##plt.imshow(B.transpose().dot(B))
        ##plt.colorbar()
        ##plt.show()
        ##print "Computing BtBi...",
        ##sys.stdout.flush()
        ##rcondB = 1e-3
        ##BtBi = la.pinv(B.transpose().dot(B) , rcond=rcondB)#+ 10.**sigmap*np.identity(len(B[0])), rcond=rcondB)
        ##print "Done."
Exemplo n.º 4
0
        ###################################plot actual errors and such, see if the gridding is too coarse

        #A = np.fromfile('/home/omniscope/simulate_visibilities/data/Amatrix_%iubl_nside%i_%iby%i_redundantinfo_X5_q3x.bin'%(nUBL, nside, nt*nUBL, 12*nside**2),dtype='complex64').reshape((nUBL, nt, 12*nside**2))[subublindex,::tavg].reshape((len(subublindex) * nt/tavg, 12*nside**2))/nside**2

        #ublindex = [u for u in range(len(ubls_standard)) if la.norm(ubls_standard[u]) < (nside * 299.792458 / freq)]
        A_standard = np.fromfile('/home/omniscope/data/GSM_data/Amatrix_%iubl_nside%i_%iby%i_redundantinfo_X5_q3x.bin'%(nUBL, nside_standard, nt_standard*nUBL, 12*nside_standard**2),dtype='complex64').reshape((nUBL, nt_standard, 12*nside_standard**2))[subublindex, ::(tavg*nt_standard/nt)].reshape((len(subublindex)*nt/tavg, 12*nside_standard**2))
        A_standard = np.concatenate((A_standard, np.fromfile('/home/omniscope/data/GSM_data/Amatrix_%iubl_nside%i_%iby%i_redundantinfo_X5_q3y.bin'%(nUBL, nside_standard, nt_standard*nUBL, 12*nside_standard**2),dtype='complex64').reshape((nUBL, nt_standard, 12*nside_standard**2))[subublindex, ::(tavg*nt_standard/nt)].reshape((len(subublindex)*nt/tavg, 12*nside_standard**2))))

        average_size = nside_standard/nside
        Bfile = '/home/omniscope/data/GSM_data/Bmatrix_nside%i_to_nside%i.bin'%(nside_standard,nside)
        if os.path.isfile(Bfile):
            B = np.fromfile(Bfile, dtype='float32').reshape((12*nside**2,12*nside_standard**2))
        else:
            B = np.zeros((12*nside**2,12*nside_standard**2), dtype='float32')
            for ringpix in range(12*nside_standard**2):
                B[hpf.nest2ring(nside, hpf.ring2nest(nside_standard, ringpix)/average_size**2), ringpix] = average_size**-2
            B.tofile('/home/omniscope/data/GSM_data/Bmatrix_nside%i_to_nside%i.bin'%(nside_standard,nside))
        if nside <= 4 and nside != nside_standard:
            equatorial_GSM = B.dot(equatorial_GSM_standard)

        ##plt.imshow(B.transpose().dot(B))
        ##plt.colorbar()
        ##plt.show()
        ##print "Computing BtBi...",
        ##sys.stdout.flush()
        ##rcondB = 1e-3
        ##BtBi = la.pinv(B.transpose().dot(B) , rcond=rcondB)#+ 10.**sigmap*np.identity(len(B[0])), rcond=rcondB)
        ##print "Done."
        ##sys.stdout.flush()
        ##BtBi.astype('float32').tofile('/home/omniscope/data/GSM_data/BtBi_nside%i_to_nside%i.bin'%(nside_standard,nside))
        #plt.imshow(np.abs(B.transpose().dot(B)))