Ejemplo n.º 1
0
    def readPixels(self, i, filename):
        """
        Reads data
        """

        d = h5py.File(filename, 'r')

        # --- Feed position indices can change
        self.FeedIndex = GetFeeds(d['level1/spectrometer/feeds'][...],
                                  self.Feeds)

        # We store all the pointing information
        #x0  = d['level1/spectrometer/pixel_pointing/pixel_ra'][self.FeedIndex,:]
        #y0  = d['level1/spectrometer/pixel_pointing/pixel_dec'][self.FeedIndex,:]
        x = d['level1/spectrometer/pixel_pointing/pixel_az'][self.FeedIndex, :]
        y = d['level1/spectrometer/pixel_pointing/pixel_el'][self.FeedIndex, :]
        mjd = d['level1/spectrometer/MJD'][:]
        for j in range(x.shape[0]):
            x[j], y[j] = Coordinates.h2e_full(x[j], y[j], mjd,
                                              Coordinates.comap_longitude,
                                              Coordinates.comap_latitude)

        #pyplot.plot((x0[0]-x[0])*60)
        #pyplot.plot((y0[0]-y[0])*60)
        #pyplot.show()

        scan_edges = d['level2/Statistics/scan_edges'][...]
        pixels = np.zeros((x.shape[0], self.datasizes[i]))
        last = 0
        for iscan, (start, end) in enumerate(scan_edges):
            N = int((end - start) // self.offset_length * self.offset_length)
            end = start + N
            xc = x[:, start:end]
            yc = y[:, start:end]
            yshape = yc.shape
            # convert to Galactic
            if 'GLON' in self.naive.wcs.wcs.ctype[0]:
                rot = hp.rotator.Rotator(coord=['C', 'G'])
                gb, gl = rot((90 - yc.flatten()) * np.pi / 180.,
                             xc.flatten() * np.pi / 180.)
                xc, yc = gl * 180. / np.pi, (np.pi / 2 - gb) * 180. / np.pi

            pixels[:, last:last + N] = np.reshape(
                self.naive.getFlatPixels(xc.flatten(), yc.flatten()), yshape)
            last += N

        self.pixels[self.chunks[i][0]:self.chunks[i][1]] = pixels.flatten()
        d.close()
Ejemplo n.º 2
0
    def readPixels(self, i, filename):
        """
        Reads data
        """

        d = h5py.File(filename, 'r')

        # --- Feed position indices can change
        self.FeedIndex = GetFeeds(d['level1/spectrometer/feeds'][...],
                                  self.Feeds)

        # We store all the pointing information
        x0 = d['level1/spectrometer/pixel_pointing/pixel_ra'][
            self.FeedIndex, :]
        y0 = d['level1/spectrometer/pixel_pointing/pixel_dec'][
            self.FeedIndex, :]
        x = d['level1/spectrometer/pixel_pointing/pixel_az'][self.FeedIndex, :]
        y = d['level1/spectrometer/pixel_pointing/pixel_el'][self.FeedIndex, :]
        mjd = d['level1/spectrometer/MJD'][:]
        for i in range(x.shape[0]):
            x[i], y[i] = Coordinates.h2e_full(x[i], y[i], mjd,
                                              Coordinates.comap_longitude,
                                              Coordinates.comap_latitude)

        scan_edges = d['level2/Statistics/scan_edges'][...]
        pixels = np.zeros((x.shape[0], self.datasizes[i]))
        last = 0
        for iscan, (start, end) in enumerate(scan_edges):
            N = int((end - start) // self.offset_length * self.offset_length)
            end = start + N
            xc = x[:, start:end]
            yc = y[:, start:end]
            pixels[:, last:last + N] = hp.ang2pix(
                self.nside, (np.pi / 2. - yc * np.pi / 180.),
                xc * np.pi / 180.,
                nest=True)
            last += N

        self.pixels[self.chunks[i][0]:self.chunks[i][1]] = pixels.flatten()