FRBs / sigpyproc3

Python3 version of Ewan Barr's sigpyproc library
https://sigpyproc3.readthedocs.io
MIT License
14 stars 11 forks source link

Implement the kwarg "only_valid_samples" to FilterbankBlock.dedisperse() #2

Closed David-McKenna closed 4 years ago

David-McKenna commented 4 years ago

This significantly cuts down on the memory requirements and processing time for high DM dedispersion calls.

As an example, here is a case where rawdata1 is a FilterbankBlock with dimensions (3904, 406444), dedispersing at a DM of 56.751 (Crab Pulsar) with this methodology results in 2 orders of magnitude of time saved compared to the original implementation:

In [12]: %timeit test1 = rawdata1.dedisperse(56.751)[:, :3912]
1min 10s +- 343 ms per loop (mean +- std. dev. of 7 runs, 1 loop each)

In [13]: %timeit test2 = rawdata1.dedisperse(56.751, True)
510 ms +- 7.53 ms per loop (mean +- std. dev. of 7 runs, 1 loop each)

With the same result:

In [18]: test2.shape, test1.shape
Out[18]: ((3904, 3912), (3904, 3912))

In [20]: np.sum(np.logical_not(test1 == test2))
Out[20]: FilterbankBlock(0)