def prepare_spiketrains(self, tuning_prop): if (type(tuning_prop) == type('')): # try: tp = np.loadtxt(tuning_prop) # except: # print 'Pid %d fails to load the file ...' % self.pc_id # tp = self.prepare_tuning_prop(self.params) elif (type(tuning_prop) == type(np.array([]))): tp = tuning_prop else: raise TypeError, 'Only filename or numpy array accepted for tuning_prop, given %s' % (str(type(tuning_prop))) my_units = utils.distribute_n(self.params['n_exc'], self.n_proc, self.pc_id) input_spike_trains = utils.create_spike_trains_for_motion(tp, self.params, contrast=.9, my_units=my_units) # write to paths defined in the params dictionary if self.comm != None: self.comm.barrier() #
print 'n_cells=%d\tn_exc=%d\tn_inh=%d' % (params['n_cells'], params['n_exc'], params['n_inh']) print 'Blur', params['blur_X'], params['blur_V'] scale_input_frequency = False if scale_input_frequency: scaling_factor = utils.scale_input_frequency(params['blur_X']) params['f_max_stim'] *= scaling_factor try: from mpi4py import MPI USE_MPI = True comm = MPI.COMM_WORLD pc_id, n_proc = comm.rank, comm.size print "USE_MPI:", USE_MPI, 'pc_id, n_proc:', pc_id, n_proc except: USE_MPI = False pc_id, n_proc, comm = 0, 1, None print "MPI not used" try: tuning_prop = np.loadtxt(params['tuning_prop_means_fn']) except: print 'File with tuning properties missing: %s\nPlease run: \nmpirun -np [N] python prepare_tuning_prop.py\nOR\npython prepare_tuning_prop.py' % params['tuning_prop_means_fn'] exit(1) my_units = utils.distribute_n(params['n_exc'], n_proc, pc_id) utils.create_spike_trains_for_motion(tuning_prop, params, contrast=.9, my_units=my_units, seed=seed) # write to paths defined in the params dictionary if comm != None: comm.barrier()