コード例 #1
0
    def sky_signal(self,data,avg_tod):
        """
        1) Read in a sky map
        2) Sample at observed pixels
        3) Return time ordered data
        """

        feeds = np.arange(self.i_nFeeds,dtype=int)

        ra     = data['spectrometer/pixel_pointing/pixel_ra'][...]
        dec    = data['spectrometer/pixel_pointing/pixel_dec'][...]

        for ifeed in tqdm(feeds.flatten()):
            gl, gb = Coordinates.e2g(ra[ifeed], dec[ifeed]) 
            pixels = ang2pixWCS(self.signal_map_wcs, gl, gb,self.signal_map.shape)
            avg_tod[ifeed] += self.signal_map_flat[None,None,pixels]
コード例 #2
0
    def MakeMap(self, tod, ra, dec, mjd, el):
        #takes a 1D tod array and makes a simple map

        #produce arrays for mapping
        npix = self.naxis[0] * self.naxis[1]

        pixbins = np.arange(0, npix + 1).astype(int)

        nHorns, nSBs, nChans, nSamples = tod.shape
        rms = Filtering.calcRMS(tod)

        maps = np.zeros((nHorns, nSBs, nChans, self.naxis[0], self.naxis[1]))
        for i in range(nHorns):

            good = (np.isnan(ra[i, :]) == False) & (np.isnan(tod[i, 0, 0])
                                                    == False)
            pa = Coordinates.pa(ra[i, good], dec[i, good], mjd[good], self.lon,
                                self.lat)
            x, y = Coordinates.Rotate(ra[i, good], dec[i, good], self.x0,
                                      self.y0, -pa)

            nbins = 10
            xbins = np.linspace(np.min(x), np.max(x), nbins + 1)
            xmids = (xbins[1:] + xbins[:-1]) / 2.
            xbw, _ = np.histogram(x, xbins)
            ybw, _ = np.histogram(y, xbins)

            todAvg = np.nanmean(np.nanmean(tod[i, ...], axis=0), axis=0)
            fitx0, fity0 = self.initialPeak(todAvg[good], x, y)
            r = np.sqrt((x - fitx0)**2 + (y - fity0)**2)
            close = (r < 6. / 60.)

            pix = ang2pixWCS(self.wcs, x, y).astype('int')
            mask = np.where((pix != -1))[0]

            h, b = np.histogram(pix,
                                pixbins,
                                weights=(pix != -1).astype(float))
            self.hits = np.reshape(h, (self.naxis[0], self.naxis[1]))

            for j in range(nSBs):
                for k in range(1):  #nChans):
                    todmap = tod[i, j, k, good]

                    if self.filtertod:
                        txbw, _ = np.histogram(x, xbins, weights=todmap)
                        tybw, _ = np.histogram(y, xbins, weights=todmap)
                        fb = txbw / xbw
                        gd = np.isfinite(fb)
                        pmdl = np.poly1d(np.polyfit(xmids[gd], fb[gd], 1))
                        todmap -= pmdl(x)
                        fb = tybw / ybw
                        gd = np.isfinite(fb)
                        pmdl = np.poly1d(np.polyfit(xmids[gd], fb[gd], 1))
                        todmap -= pmdl(y)

                    w, b = np.histogram(pix[mask],
                                        pixbins,
                                        weights=todmap[mask])
                    #                    w, b = np.histogram(pix[:], pixbins, weights=tod[i,j,k,:])
                    m = np.reshape(w, (self.naxis[0], self.naxis[1]))
                    maps[i, j, k, ...] = m / self.hits

        return maps