Dataset_Management.py
def _get_labels(self, time_window, Cnp, Duration, Dnp):
        "Returns classes and bboxes inside the signal window"
        dset_p = self.File['Cnp_' + str(Cnp+1) + '/Duration_' + str(Duration+1) + '/Dnp_' + str(Dnp+1) + '/parameters']
        pulses_inside_window = np.where((torch.from_numpy(dset_p[0,:]) > time_window[0].cpu()) & \
                                        (torch.from_numpy(dset_p[0,:]) < time_window[-1].cpu()))[0]
        pulses_inside_window = pulses_inside_window.tolist()
        
        start_times = dset_p[0,pulses_inside_window]
        #pulse_widths = dset_p[1,pulses_inside_window]
        #pulse_categories = dset_p[2,pulses_inside_window]
        pulse_widths = dset_p[2,pulses_inside_window]
        pulse_amplitudes = dset_p[3,pulses_inside_window]
        
        number_of_pulses = len(pulses_inside_window)
        if number_of_pulses == 0:
            average_width = 0.0
            average_amplitude = 0.0
        else:
            average_width = np.average(pulse_widths)
            average_amplitude = np.average(pulse_amplitudes)

        starts = (torch.from_numpy(start_times) - time_window[0].cpu()) / self.window
        widths = torch.from_numpy(pulse_widths) / self.window
        amplitudes = torch.from_numpy(pulse_amplitudes)
        
        starts = starts.tolist()
        widths = widths.tolist()
        amplitudes = amplitudes.tolist()
        #categories = pulse_categories.tolist()
        categories = np.zeros(len(pulses_inside_window)).tolist()
        
        starts = (starts + [1.0]*(self.max_num_of_pulses_in_a_wind - len(starts)))
        widths = (widths + [1.0]*(self.max_num_of_pulses_in_a_wind - len(widths)))
        amplitudes = (amplitudes + [1.0]*(self.max_num_of_pulses_in_a_wind - len(amplitudes)))
        categories = (categories + [1.0]*(self.max_num_of_pulses_in_a_wind - len(categories)))
        
        starts = torch.FloatTensor(starts)
        widths = torch.FloatTensor(widths)
        amplitudes = torch.FloatTensor(amplitudes)
        categories = torch.FloatTensor(categories)
        return starts, widths, amplitudes, categories, number_of_pulses, average_width, average_amplitude
Returns classes and bboxes inside the signal window
Returns classes and bboxes inside the signal window
Returns classes and bboxes inside the signal window
def _get_labels(self, time_window, Cnp, Duration, Dnp):
        dset_p = self.File['Cnp_' + str(Cnp+1) + '/Duration_' + str(Duration+1) + '/Dnp_' + str(Dnp+1) + '/parameters']
        pulses_inside_window = np.where((torch.from_numpy(dset_p[0,:]) > time_window[0].cpu()) & \
                                        (torch.from_numpy(dset_p[0,:]) < time_window[-1].cpu()))[0]
        pulses_inside_window = pulses_inside_window.tolist()
        start_times = dset_p[0,pulses_inside_window]
        pulse_widths = dset_p[2,pulses_inside_window]
        pulse_amplitudes = dset_p[3,pulses_inside_window]
        number_of_pulses = len(pulses_inside_window)
        if number_of_pulses == 0:
            average_width = 0.0
            average_amplitude = 0.0
        else:
            average_width = np.average(pulse_widths)
            average_amplitude = np.average(pulse_amplitudes)
        starts = (torch.from_numpy(start_times) - time_window[0].cpu()) / self.window
        widths = torch.from_numpy(pulse_widths) / self.window
        amplitudes = torch.from_numpy(pulse_amplitudes)
        starts = starts.tolist()
        widths = widths.tolist()
        amplitudes = amplitudes.tolist()
        categories = np.zeros(len(pulses_inside_window)).tolist()
        starts = (starts + [1.0]*(self.max_num_of_pulses_in_a_wind - len(starts)))
        widths = (widths + [1.0]*(self.max_num_of_pulses_in_a_wind - len(widths)))
        amplitudes = (amplitudes + [1.0]*(self.max_num_of_pulses_in_a_wind - len(amplitudes)))
        categories = (categories + [1.0]*(self.max_num_of_pulses_in_a_wind - len(categories)))
        starts = torch.FloatTensor(starts)
        widths = torch.FloatTensor(widths)
        amplitudes = torch.FloatTensor(amplitudes)
        categories = torch.FloatTensor(categories)
        return starts, widths, amplitudes, categories, number_of_pulses, average_width, average_amplitude
def _get_labels ( self , time_window , Cnp , Duration , Dnp ) : dset_p = self . File [ 'Cnp_' + str ( Cnp + 1 ) + '/Duration_' + str ( Duration + 1 ) + '/Dnp_' + str ( Dnp + 1 ) + '/parameters' ] pulses_inside_window = np . where ( ( torch . from_numpy ( dset_p [ 0 , : ] ) > time_window [ 0 ] . cpu ( ) ) & ( torch . from_numpy ( dset_p [ 0 , : ] ) < time_window [ - 1 ] . cpu ( ) ) ) [ 0 ] pulses_inside_window = pulses_inside_window . tolist ( ) start_times = dset_p [ 0 , pulses_inside_window ] pulse_widths = dset_p [ 2 , pulses_inside_window ] pulse_amplitudes = dset_p [ 3 , pulses_inside_window ] number_of_pulses = len ( pulses_inside_window ) if number_of_pulses == 0 : average_width = 0.0 average_amplitude = 0.0 else : average_width = np . average ( pulse_widths ) average_amplitude = np . average ( pulse_amplitudes ) starts = ( torch . from_numpy ( start_times ) - time_window [ 0 ] . cpu ( ) ) / self . window widths = torch . from_numpy ( pulse_widths ) / self . window amplitudes = torch . from_numpy ( pulse_amplitudes ) starts = starts . tolist ( ) widths = widths . tolist ( ) amplitudes = amplitudes . tolist ( ) categories = np . zeros ( len ( pulses_inside_window ) ) . tolist ( ) starts = ( starts + [ 1.0 ] * ( self . max_num_of_pulses_in_a_wind - len ( starts ) ) ) widths = ( widths + [ 1.0 ] * ( self . max_num_of_pulses_in_a_wind - len ( widths ) ) ) amplitudes = ( amplitudes + [ 1.0 ] * ( self . max_num_of_pulses_in_a_wind - len ( amplitudes ) ) ) categories = ( categories + [ 1.0 ] * ( self . max_num_of_pulses_in_a_wind - len ( categories ) ) ) starts = torch . FloatTensor ( starts ) widths = torch . FloatTensor ( widths ) amplitudes = torch . FloatTensor ( amplitudes ) categories = torch . FloatTensor ( categories ) return starts , widths , amplitudes , categories , number_of_pulses , average_width , average_amplitude
Returns classes and bboxes inside the signal window
Returns classes and bboxes inside the signal window
"Returns classes and bboxes inside the signal window" #pulse_widths = dset_p[1,pulses_inside_window] #pulse_categories = dset_p[2,pulses_inside_window] #categories = pulse_categories.tolist()
self
time_window
Cnp
Duration
Dnp