コード例 #1
0
ファイル: FoldedData.py プロジェクト: ewanbarr/sigpyproc
    def updateParams(self,dm=None,period=None):
        """Install a new folding period and/or DM in the data cube.
        
        :param dm: the new DM to dedisperse to
        :type dm: float

        :param period: the new period to fold with
        :type period: float
        """
          
        if dm is None: 
            dm = self.dm
        if period is None: 
            period = self.period
          
        dmdelays = self._getDMdelays(dm)
        pdelays = self._getPdelays(period)
        for ii in range(self.nints):
            for jj in range(self.nbands):
                if dmdelays is not None:
                    self[ii][jj] = rollArray(self[ii][jj],dmdelays[jj],0)
                if pdelays is not None:
                    self[ii][jj] = rollArray(self[ii][jj],pdelays[ii],0)
        self.dm = dm
        self.period = period
コード例 #2
0
    def updateParams(self, dm=None, period=None):
        """Install a new folding period and/or DM in the data cube.
        
        :param dm: the new DM to dedisperse to
        :type dm: float

        :param period: the new period to fold with
        :type period: float
        """

        if dm is None:
            dm = self.dm
        if period is None:
            period = self.period

        dmdelays = self._getDMdelays(dm)
        pdelays = self._getPdelays(period)
        for ii in range(self.nints):
            for jj in range(self.nbands):
                if dmdelays is not None:
                    self[ii][jj] = rollArray(self[ii][jj], dmdelays[jj], 0)
                if pdelays is not None:
                    self[ii][jj] = rollArray(self[ii][jj], pdelays[ii], 0)
        self.dm = dm
        self.period = period
コード例 #3
0
    def dedisperse(self, dm, only_valid_samples=False):
        """Dedisperse the block.

        Parameters
        ----------
        dm : float
            dm to dedisperse to
        only_valid_samples : bool, optional
            return a FilterbankBlock with only time samples that
            contain the full bandwidth, by default False

        Returns
        -------
        :class:`~sigpyproc.Filterbank.FilterbankBlock`
            a dedispersed version of the block

        Raises
        ------
        ValueError
            If there are not enough time samples to dedisperse.

        Notes
        -----
        Frequency dependent delays are applied as rotations to each
        channel in the block.
        """
        delays = self.header.getDMdelays(dm)
        if only_valid_samples:
            if self.shape[1] < delays[-1]:
                raise ValueError(
                    f"Insufficient time samples to dedisperse to {dm} (requires "
                    f"at least {delays[-1]} samples, given {self.shape[1]})."
                )
            new_ar = FilterbankBlock(
                np.zeros(
                    (self.header.nchans, self.shape[1] - delays[-1]), dtype=self.dtype
                ),
                self.header,
            )
            end_samples = delays + new_ar.shape[1]

            slices = [
                np.arange(delay, end_sample)
                for delay, end_sample in zip(delays, end_samples)
            ]
            for idx, timeSlice in enumerate(slices):
                new_ar[idx, :] = self[idx, timeSlice]
        else:
            new_ar = self.copy()
            for ii in range(self.shape[0]):
                new_ar[ii] = rollArray(self[ii], delays[ii] % self.shape[1], 0)

        new_ar.dm = dm
        return new_ar
コード例 #4
0
    def dedisperse(self,dm):
        """Dedisperse the block.

        :param dm: dm to dedisperse to
        :type dm: float

        :return: a dedispersed version of the block
        :rtype: :class:`~sigpyproc.Filterbank.FilterbankBlock`
        
        .. note::
        
                Frequency dependent delays are applied as rotations to each
                channel in the block.
        """
        new_ar = self.copy()
        delays = self.header.getDMdelays(dm)
        for ii in range(self.shape[0]):
            new_ar[ii] = rollArray(self[ii],delays[ii]%self.shape[1],0)
        new_ar.dm = dm
        return new_ar
コード例 #5
0
    def dedisperse(self,dm):
        """Dedisperse the block.

        :param dm: dm to dedisperse to
        :type dm: float

        :return: a dedispersed version of the block
        :rtype: :class:`~sigpyproc.Filterbank.FilterbankBlock`
        
        .. note::
        
                Frequency dependent delays are applied as rotations to each
                channel in the block.
        """
        new_ar = self.copy()
        delays = self.header.getDMdelays(dm)
        for ii in range(self.shape[0]):
            new_ar[ii] = rollArray(self[ii],delays[ii]%self.shape[1],0)
        new_ar.dm = dm
        return new_ar
コード例 #6
0
ファイル: FoldedData.py プロジェクト: ewanbarr/sigpyproc
 def centre(self):
     """Try and roll the data cube to center the pulse."""
     p = self.getProfile()
     pos = p._getPosition(p._getWidth())
     self = rollArray(self,(pos-self.nbins/2),2)
コード例 #7
0
 def centre(self):
     """Try and roll the data cube to center the pulse."""
     p = self.getProfile()
     pos = p._getPosition(p._getWidth())
     self = rollArray(self, (pos - self.nbins / 2), 2)