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
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
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)
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)
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
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
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)
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
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)
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)
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
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)
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)
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
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
def Connect_speed(*args, **kwargs): if comm.is_mpi_used(): _Connect_speed_mpi(*args, **kwargs) else: _Connect_speed(*args, **kwargs)
def Simulate(*args, **kwargs): if comm.is_mpi_used(): _Simulate_mpi(*args, **kwargs) else: _Simulate(*args, **kwargs)
def Connect_DC(*args, **kwargs): if comm.is_mpi_used(): _Connect_DC_mpi(*args, **kwargs) else: _Connect_DC(*args, **kwargs)
def Create(*args, **kwargs): if comm.is_mpi_used(): return _Create_mpi(*args, **kwargs) else: return nest.Create(*args, **kwargs)
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)
def delete_data(path, **kwargs): if comm.is_mpi_used(): return _delete_data_mpi(path, **kwargs) else: return _delete_data(path, **kwargs)
def garbage_collect(self): if comm.is_mpi_used(): self._garbage_collect_mpi() else: self._garbage_collect()