예제 #1
0
    def create_raw_spike_signal(self, start, stop):
    #signal=load:spikes()
        if self.sd['params']['to_file']:
            
            
            
            n_vp=my_nest.GetKernelStatus(['total_num_virtual_procs'])[0]
            data_path=my_nest.GetKernelStatus(['data_path'])[0]
            files=os.listdir(data_path)
            file_names=[data_path+s for s in files 
             if s.split('-')[0]==self.sd['model']]
                        
            s, t = my_nest.get_spikes_from_file(file_names)
            
        else:  
            
            s,t=my_nest.get_spikes_from_memory(self.sd['id'])
            
            e = my_nest.GetStatus(self.sd['id'])[0]['events'] # get events
            s = e['senders'] # get senders
            t = e['times'] # get spike times
        
            
            if comm.is_mpi_used():
                s,t=my_nest.collect_spikes_mpi(s,t)
                

        if stop:
            s, t = s[t < stop], t[t < stop] # Cut out data
            s, t = s[t >= start], t[t >= start] # Cut out data
        signal = zip(s, t)
        return signal
예제 #2
0
    def create_raw_spike_signal(self, start, stop):
        #signal=load:spikes()
        if self.sd['params']['to_file']:

            n_vp = my_nest.GetKernelStatus(['total_num_virtual_procs'])[0]
            data_path = my_nest.GetKernelStatus(['data_path'])[0]
            files = os.listdir(data_path)
            file_names = [
                data_path + s for s in files
                if s.split('-')[0] == self.sd['model']
            ]

            s, t = my_nest.get_spikes_from_file(file_names)

        else:

            s, t = my_nest.get_spikes_from_memory(self.sd['id'])

            e = my_nest.GetStatus(self.sd['id'])[0]['events']  # get events
            s = e['senders']  # get senders
            t = e['times']  # get spike times

            if comm.is_mpi_used():
                s, t = my_nest.collect_spikes_mpi(s, t)

        if stop:
            s, t = s[t < stop], t[t < stop]  # Cut out data
            s, t = s[t >= start], t[t >= start]  # Cut out data
        signal = zip(s, t)
        return signal
예제 #3
0
 def save_fig(self, *args):
     if comm.is_mpi_used():
         with Barrier():
             if comm.rank() == 0:
                 self._save_fig(*args)
     else:
         self._save_fig(*args)
예제 #4
0
 def save_fig(self, *args):
     if comm.is_mpi_used():
         with Barrier():
             if comm.rank()==0:
                 self._save_fig(*args)
     else:
         self._save_fig(*args)
예제 #5
0
def get_spikes_from_memory(sd_id):
    e = GetStatus(sd_id)[0]['events']  # get events
    s = e['senders']  # get senders
    t = e['times']  # get spike times

    if comm.is_mpi_used():
        s, t = collect_spikes_mpi(s, t)
    return s, t
예제 #6
0
def get_spikes_from_memory(sd_id):
    e = GetStatus(sd_id)[0]['events'] # get events
    s = e['senders'] # get senders
    t = e['times'] # get spike times

    if comm.is_mpi_used():
        s,t=collect_spikes_mpi(s,t)    
    return s,t
예제 #7
0
def mkdir(*args, **kwargs):
    '''
     
    Arguments:
        data        - data to be pickled
        fileName    - full path or just file name
    '''
     
    if comm.is_mpi_used() and not kwargs.get('all_mpi', False):
        _mkdir_mpi(*args)
    else:
        _mkdir(*args)
예제 #8
0
def mkdir(*args, **kwargs):
    '''
     
    Arguments:
        data        - data to be pickled
        fileName    - full path or just file name
    '''

    if comm.is_mpi_used() and not kwargs.get('all_mpi', False):
        _mkdir_mpi(*args)
    else:
        _mkdir(*args)
예제 #9
0
def text_load(fileName, **kwargs):
    '''
    
    Arguments:
        fileName    - full path or just file name
    '''

    if comm.is_mpi_used() and not kwargs.get('all_mpi', False):
        data = _text_load_mpi(fileName)
    else:
        data = _text_load(fileName)

    return data
예제 #10
0
def text_save(text, fileName, **kwargs ):
    '''
    
    Arguments:
        data        - data to be pickled
        fileName    - full path or just file name
    '''
        
    mkdir('/'.join(fileName.split('/')[0:-1])) 

    if comm.is_mpi_used() and not kwargs.get('all_mpi', False):
        _text_save_mpi(text, fileName)
    else:
        _text_save(text, fileName)
예제 #11
0
def text_save(text, fileName, **kwargs):
    '''
    
    Arguments:
        data        - data to be pickled
        fileName    - full path or just file name
    '''

    mkdir('/'.join(fileName.split('/')[0:-1]))

    if comm.is_mpi_used() and not kwargs.get('all_mpi', False):
        _text_save_mpi(text, fileName)
    else:
        _text_save(text, fileName)
예제 #12
0
def text_load(fileName, **kwargs):
    '''
    
    Arguments:
        fileName    - full path or just file name
    '''

    if comm.is_mpi_used()and not kwargs.get('all_mpi', False):
        data=_text_load_mpi(fileName)
    else:  
        data=_text_load(fileName)


    return data
예제 #13
0
def pickle_save(data, fileName, file_extension='.pkl', **kwargs):
    '''
    
    Arguments:
        data        - data to be pickled
        fileName    - full path or just file name
    '''

    fileName = get_full_file_name(fileName, file_extension)
    mkdir('/'.join(fileName.split('/')[0:-1]))

    if comm.is_mpi_used() and not kwargs.get('all_mpi', False):
        _pickle_save_mpi(data, fileName)
    else:
        _pickle_save(data, fileName)
예제 #14
0
def pickle_save(data, fileName, file_extension='.pkl', **kwargs):
    '''
    
    Arguments:
        data        - data to be pickled
        fileName    - full path or just file name
    '''

    fileName=get_full_file_name(fileName, file_extension)  
    mkdir('/'.join(fileName.split('/')[0:-1])) 
    
    if comm.is_mpi_used() and not kwargs.get('all_mpi', False):
        _pickle_save_mpi(data, fileName)
    else:
        _pickle_save(data, fileName)
예제 #15
0
def pickle_load(fileName, file_extension='.pkl', **kwargs):
    '''
    
    Arguments:
        fileName    - full path or just file name
    '''
    #     if 4<len(fileName) and fileName[-4:]!=file_extension:
    #         fileName=fileName+file_extension
    #     fileName=os.path.expanduser(fileName)

    fileName = get_full_file_name(fileName, file_extension)
    f = open(fileName, 'rb')  # make sure file are read in binary mod

    if comm.is_mpi_used() and not kwargs.get('all_mpi', False):
        data = _pickle_load_mpi(f)
    else:
        data = pickle.load(f)

    f.close()
    return data
예제 #16
0
def pickle_load(fileName, file_extension='.pkl', **kwargs):
    '''
    
    Arguments:
        fileName    - full path or just file name
    '''
#     if 4<len(fileName) and fileName[-4:]!=file_extension:
#         fileName=fileName+file_extension
#     fileName=os.path.expanduser(fileName)

    fileName=get_full_file_name(fileName, file_extension)      
    f=open(fileName, 'rb') # make sure file are read in binary mod
    
    if comm.is_mpi_used()and not kwargs.get('all_mpi', False):
        data=_pickle_load_mpi(f)
    else:  
        data=pickle.load(f)

    f.close()
    return data
예제 #17
0
def Connect_speed(*args, **kwargs):
    if comm.is_mpi_used():
        _Connect_speed_mpi(*args, **kwargs)
    else:
        _Connect_speed(*args, **kwargs)
예제 #18
0
def Simulate(*args, **kwargs):
    if comm.is_mpi_used():
        _Simulate_mpi(*args, **kwargs)
    else:
        _Simulate(*args, **kwargs)
예제 #19
0
def Connect_DC(*args, **kwargs):
    if comm.is_mpi_used():
        _Connect_DC_mpi(*args, **kwargs)
    else:
        _Connect_DC(*args, **kwargs)
예제 #20
0
def Create(*args, **kwargs):
    if comm.is_mpi_used():
        return _Create_mpi(*args, **kwargs)
    else:
        return nest.Create(*args, **kwargs)
예제 #21
0
def get_spikes_from_file(file_names):
    if comm.is_mpi_used():
        return _get_spikes_from_file_mpi(file_names)
    else:
        return _get_spikes_from_file(file_names)
예제 #22
0
def Simulate(*args, **kwargs):
    if comm.is_mpi_used():
        _Simulate_mpi(*args, **kwargs)    
    else:
        _Simulate(*args, **kwargs)  
예제 #23
0
def delete_data(path, **kwargs):
    if comm.is_mpi_used():
        return _delete_data_mpi(path, **kwargs)
    else:
        return _delete_data(path, **kwargs)
예제 #24
0
def get_spikes_from_file(file_names):
    if comm.is_mpi_used():
        return _get_spikes_from_file_mpi(file_names)
    else:
        return _get_spikes_from_file(file_names)
예제 #25
0
def Connect_speed(*args, **kwargs):
    if comm.is_mpi_used():
        _Connect_speed_mpi(*args, **kwargs)
    else:
        _Connect_speed(*args, **kwargs)
예제 #26
0
def delete_data(path, **kwargs):
    if comm.is_mpi_used():
        return _delete_data_mpi(path, **kwargs)
    else:
        return _delete_data(path, **kwargs)
예제 #27
0
def Create(*args, **kwargs):
    if comm.is_mpi_used():
        return _Create_mpi(*args, **kwargs)    
    else:
        return nest.Create(*args, **kwargs)  
예제 #28
0
 def garbage_collect(self):
     if comm.is_mpi_used():
         self._garbage_collect_mpi()
     else:
         self._garbage_collect()
예제 #29
0
def Connect_DC(*args, **kwargs):
    if comm.is_mpi_used():
        _Connect_DC_mpi(*args, **kwargs)
    else:
        _Connect_DC(*args, **kwargs)
예제 #30
0
 def garbage_collect(self):
     if comm.is_mpi_used():
         self._garbage_collect_mpi()
     else:
         self._garbage_collect()