@@ -11,7 +11,7 @@ def dedisperse(samples, dm=None):
1111
1212 if dm is None :
1313 print ("Finding possible DM's" )
14- dm = estimate_dm (samples )
14+ dm = find_initial_line (samples )
1515
1616 # Distribute the DM over the amount of samples
1717 delays_per_sample = np .round (np .linspace (dm , 0 , samples .shape [1 ])).astype (int )
@@ -94,29 +94,52 @@ def find_initial_line(samples):
9494 '''
9595
9696 avg_intensity = find_avg_intensity (samples , 10 )
97- max_delay = 8
97+ max_delay = 10
9898
99- for s , sample in enumerate (samples [:, 1 ]):
99+ for s , sample in enumerate (samples [:, 0 ]):
100100 if (sample > avg_intensity ):
101- previous_sample_index = s
102- print ("Attempting to find line on freq," , 1 , "sample" , s )
103- find_line (samples , previous_sample_index , max_delay , avg_intensity )
101+ start_sample_index = s
102+ print ("Attempting to find line on freq," , 0 , "sample" , s )
103+ line_coordinates = find_line (samples , start_sample_index , max_delay , avg_intensity )
104+ if (line_coordinates is not None ):
105+ dm = line_coordinates [1 ] - line_coordinates [0 ]
106+ print (dm )
107+ return dm
104108
105109
106- print ( "NO INITIAL SIGNAL FOUND" )
110+
107111 return None
108112
109113
110- def find_line (samples , previous_sample_index , max_delay , avg_intensity ):
114+ def find_line (samples , start_sample_index , max_delay , avg_intensity ):
115+
116+ previous_sample_index = start_sample_index
117+ break_freq_loop = True
118+ break_samples_loop = False
119+
111120 for f , frequency in enumerate (samples [1 ]):
112- for i , intensity in enumerate (samples [:, f ][previous_sample_index :previous_sample_index + max_delay ]):
121+ for i , intensity in enumerate (samples [:, f ][previous_sample_index :previous_sample_index + max_delay ]):
122+ if (f == 0 ):
123+ break_freq_loop = False
124+ break
125+ #print(previous_sample_index, previous_sample_index+max_delay)
113126 if (intensity > avg_intensity ):
114- print ("Continuing to find line on freq," , f , "sample" , i , intensity )
115- previous_sample_index = i
127+ print ("Continuing to find line on freq," , f , "sample" , previous_sample_index + i , intensity )
128+ previous_sample_index = previous_sample_index + i
129+ break_freq_loop = False
130+ break_samples_loop = True
116131 break
117- else :
118- continue
119-
132+
133+ if break_freq_loop :
134+ break
135+
136+ if break_freq_loop :
137+ print ("Failed to find line" )
138+ return None
139+
140+ print ("All freqs are looped" )
141+ return start_sample_index , previous_sample_index
142+
120143
121144
122145def find_avg_intensity (samples , top = 10 ):
0 commit comments