44# pylint: disable-msg=C0103
55import numpy as np
66
7- def dedisperse (samples , highest_x = None , max_delay = None , dm = None ):
7+ def dedisperse (samples , highest_x = None , max_delay = 0 , dm = None ):
88 '''
99 This method performs dedispersion on the filterbank data
1010 The maximum_delay specifies between the currently considered pulsar signal and the next pulsar
@@ -19,22 +19,23 @@ def dedisperse(samples, highest_x=None, max_delay=None, dm=None):
1919 pulsar_intensity = find_estimation_intensity (samples , highest_x )
2020 dm = find_dm (samples , pulsar_intensity , max_delay )
2121
22- # Distribute the DM over the amount of samples
23- delays_per_sample = np .round (np .linspace (dm , 0 , samples .shape [1 ])).astype (int )
22+ if dm :
23+ # Distribute the DM over the amount of samples
24+ delays_per_sample = (np .round (np .linspace (dm , 0 , samples .shape [1 ]))).astype (int )
2425
25- # Loop over the frequencies
26- for i , _ in enumerate (delays_per_sample ):
26+ # Loop over the frequencies
27+ for i , _ in enumerate (delays_per_sample ):
2728
28- # Temporary array that is used to later delay the frequency
29- temporary_samples = []
29+ # Temporary array that is used to later delay the frequency
30+ temporary_samples = []
3031
31- # Select frequency/column 'i' of all samples
32- temporary_samples = samples [:, i ]
32+ # Select frequency/column 'i' of all samples
33+ temporary_samples = samples [:, i ]
3334
34- # Write back the frequency/column 'i' to the samples, using numpy's roll function
35- samples [:, i ] = np .roll (temporary_samples , delays_per_sample [i ])
35+ # Write back the frequency/column 'i' to the samples, using numpy's roll function
36+ samples [:, i ] = np .roll (temporary_samples , delays_per_sample [i ])
3637
37- return samples
38+ return samples
3839
3940def find_dm (samples , pulsar_intensity , max_delay ):
4041 '''
0 commit comments