コード例 #1
0
ファイル: frames.py プロジェクト: ipashchenko/frb_old
    def de_disperse(self, dm, replace=False):
        """
        De-disperse frame using specified value of DM.

        :param dm:
            Dispersion measure to use in de-dispersion [cm^3 / pc].
        :param replace: (optional)
            Replace instance's frame values with de-dispersed ones? (default:
            ``False``)

        """
        # MHz ** 2 * cm ** 3 * s / pc
        k = 1. / (2.410331 * 10 ** (-4))

        # Calculate shift of time caused by de-dispersion for all channels
        dt_all = k * dm * (1. / self.nu ** 2. - 1. / self.nu_0 ** 2.)
        # Find what number of time bins corresponds to this shifts
        nt_all = vint(vround(dt_all / self.dt))
        # Roll each axis (freq. channel) to each own number of time steps.
        values = list()
        for i in range(self.n_nu):
            values.append(np.roll(self.values[i], -nt_all[i]))
        values = np.vstack(values)
        #values = roll2d(self.values, -nt_all, axis=1)

        if replace:
            self.values = values[:, :]
        return values
コード例 #2
0
ファイル: frames.py プロジェクト: ipashchenko/frb_old
    def _de_disperse_freq_average(self, dm):
        """
        De-disperse frame using specified value of DM and average in frequency.

        :param dm:
            Dispersion measure to use in de-dispersion [cm^3 / pc].

        :notes:
            This method avoids creating ``(n_nu, n_t)`` arrays and must be
            faster for data with big sizes. But it returns already frequency
            averaged de-dispersed dyn. spectra.

        """
        # MHz ** 2 * cm ** 3 * s / pc
        k = 1. / (2.410331 * 10 ** (-4))

        # Calculate shift of time caused by de-dispersion for all channels
        dt_all = k * dm * (1. / self.nu ** 2. - 1. / self.nu_0 ** 2.)
        # Find what number of time bins corresponds to this shifts
        nt_all = vint(vround(dt_all / self.dt))
        # Container for summing de-dispersed frequency channels
        values = np.zeros(self.n_t)
        # Roll each axis (freq. channel) to each own number of time steps.
        for i in range(self.n_nu):
            values += np.roll(self.values[i], -nt_all[i])

        return values / self.n_nu
コード例 #3
0
ファイル: frames.py プロジェクト: ipashchenko/frb_old
    def grid_dedisperse(self, dm_grid, savefig=None, threads=1):
        """
        Method that de-disperse ``Frame`` instance with range values of
        dispersion measures and average them in frequency to obtain image in
        (t, DM)-plane.

        :param dm_grid:
            Array-like of value of DM on which to de-disperse [cm^3/pc].
        :param savefig: (optional)
            File to save picture.
        :param threads: (optional)
            Number of threads used for parallelization with ``multiprocessing``
            module. If > 1 then it isn't used. (default: 1)

        """
        pool = None
        if threads > 1:
            pool = multiprocessing.Pool(threads, maxtasksperchild=1000)

        if pool:
            m = pool.map
        else:
            m = map

        # Accumulator of de-dispersed frequency averaged frames
        frames = list(m(self._de_disperse_freq_average, dm_grid.tolist()))
        frames = np.array(frames)

        if pool:
            # Close pool
            pool.close()
            pool.join()

        # Plot results
        if savefig is not None:
            plt.imshow(frames, interpolation='none', aspect='auto')
            plt.xlabel('De-dispersed by DM freq.averaged dyn.spectr')
            plt.ylabel('DM correction')
            plt.yticks(np.linspace(0, len(dm_grid) - 10, 5, dtype=int),
                       vint(dm_grid[np.linspace(0, len(dm_grid) - 10, 5,
                                                dtype=int)]))
            plt.colorbar()
            plt.savefig(savefig, bbox_inches='tight')
            plt.show()
            plt.close()

        return frames
コード例 #4
0
 def removeChild(self, index):
     self._ps.RemoveChild(vint(index), vshort(0))
コード例 #5
0
 def insertChildAt(self, child, index):
     self._ps.InsertChildAt(child._ps, vint(index), vshort(0))
コード例 #6
0
 def getChild(self, index):
     return SiebelPropertySet(self._ps.GetChild(vint(index), vshort(0)),
                              self._sa)
コード例 #7
0
 def executeQuery2(self, mode, ignore):
     self._bc.ExecuteQuery2(vint(mode), vint(ignore), vshort(0))
コード例 #8
0
 def executeQuery(self, mode):
     self._bc.ExecuteQuery(vint(mode), vshort(0))
コード例 #9
0
 def associate(self, mode):
     self._bc.Associate(vint(mode), vshort(0))
コード例 #10
0
 def newRecord(self, mode):
     self._bc.NewRecord(vint(mode), vshort(0))