output_fname = "{0}/{1}job{2:05}_output.h5".format(o.output_dir, o.fileNamePrefix, o.job_num) d = DataStorage.open(output_fname, 'w') d['trials'] = [] overalT = 0. stop = False ############################################################################### seed_gen = TrialSeedGenerator(int(o.master_seed)) for trial_idx in range(o.ntrials): seed_gen.set_generators(trial_idx) # Each trial is reproducible d['master_seed'] = int(o.master_seed) d['invalidated'] = 1 const_v = [-o.Ivel, 0.0] ei_net = ConstantVelocityNetwork(o, simulationOpts=None, vel=const_v) d['net_params'] = ei_net.getNetParams() # Common settings will stay try: ei_net.simulate(o.time, printTime=o.printTime) except NESTError as e: print("Simulation interrupted. Message: {0}".format(str(e))) print("Not saving the data. Trying to clean up if possible...") stop = True ei_net.endSimulation() d['trials'].append(ei_net.getAllData()) d.flush() constrT, simT, totalT = ei_net.printTimes() overalT += totalT if stop: break
output_fname = "{0}/{1}job{2:05}_output.h5".format(o.output_dir, o.fileNamePrefix, o.job_num) d = DataStorage.open(output_fname, 'w') d['trials'] = [] overalT = 0. stop = False ############################################################################### seed_gen = TrialSeedGenerator(int(o.master_seed)) for trial_idx in range(o.ntrials): seed_gen.set_generators(trial_idx) # Each trial is reproducible d['master_seed'] = int(o.master_seed) d['invalidated'] = 1 const_v = [0.0, -o.Ivel] ei_net = ConstantVelocityNetwork(o, simulationOpts=None, vel=const_v) d['net_params'] = ei_net.getNetParams() # Common settings will stay try: ei_net.simulate(o.time, printTime=o.printTime) except NESTError as e: print("Simulation interrupted. Message: {0}".format(str(e))) print("Not saving the data. Trying to clean up if possible...") stop = True ei_net.endSimulation() d['trials'].append(ei_net.getAllData()) d.flush() constrT, simT, totalT = ei_net.printTimes() overalT += totalT if stop: break
# Now check if there is data in the trial and append # Additionally, if data was saved but IvelVec missing, add it so that it # fits the data check_ivel_vec(trialOut) if 'IvelVec' not in trialOut: oldNIvel = 0 trialOut['IvelData'] = [] else: oldNIvel = len(trialOut['IvelVec']) try: IvelVecAppend = np.arange(oldNIvel*o.dIvel, o.IvelMax + o.dIvel, o.dIvel) for Ivel in IvelVecAppend: seed_gen.set_generators(trial_idx) # Each trial is reproducible const_v = [0.0, -Ivel] ei_net = ConstantVelocityNetwork(o, simulationOpts=None, vel=const_v) ei_net.simulate(o.time, printTime=o.printTime) ei_net.endSimulation() trialOut['IvelData'].append(ei_net.getMinimalSaveData(ispikes=o.ispikes)) trialOut['IvelVec'] = np.arange( .0, len(trialOut['IvelData']) * o.dIvel, o.dIvel) d.flush() constrT, simT, totalT = ei_net.printTimes() overalT += totalT d.flush() except NESTError as e: print("Simulation interrupted. Message: {0}".format(str(e))) print("Not saving the last trial. Trying to clean up if possible...") break
check_ivel_vec(trialOut) if 'IvelVec' not in trialOut: oldNIvel = 0 trialOut['IvelData'] = [] else: oldNIvel = len(trialOut['IvelVec']) try: IvelVecAppend = np.arange(oldNIvel * o.dIvel, o.IvelMax + o.dIvel, o.dIvel) for Ivel in IvelVecAppend: seed_gen.set_generators(trial_idx) # Each trial is reproducible const_v = [0.0, -Ivel] ei_net = ConstantVelocityNetwork(o, simulationOpts=None, vel=const_v) ei_net.simulate(o.time, printTime=o.printTime) ei_net.endSimulation() trialOut['IvelData'].append( ei_net.getMinimalSaveData(ispikes=o.ispikes)) trialOut['IvelVec'] = np.arange( .0, len(trialOut['IvelData']) * o.dIvel, o.dIvel) d.flush() constrT, simT, totalT = ei_net.printTimes() overalT += totalT d.flush() except NESTError as e: print("Simulation interrupted. Message: {0}".format(str(e)))
borders = zip(zip(startPos_x,startPos_y),zip(endPos_x,endPos_y)) #velocities velocities = [[o.Ivel, 0.0],[0.0, -o.Ivel],[-o.Ivel, 0.0],[0.0, o.Ivel]] overalT = 0. stop = False ############################################################################### seed_gen = TrialSeedGenerator(int(o.master_seed)) for trial_idx in range(o.ntrials): seed_gen.set_generators(trial_idx) # Each trial is reproducible d['master_seed'] = int(o.master_seed) d['invalidated'] = 1 const_v = velocities[trial_idx] startPos = borders[trial_idx][0] ei_net = ConstantVelocityNetwork(o, simulationOpts=None, vel=const_v, startPos=startPos) d['net_params'] = ei_net.getNetParams() # Common settings will stay # create border cell (unconnected) ei_net.create_border_cells(borders, N_per_border=1) try: ei_net.simulate(o.time, printTime=o.printTime) except NESTError as e: print("Simulation interrupted. Message: {0}".format(str(e))) print("Not saving the data. Trying to clean up if possible...") stop = True ei_net.endSimulation() # get simulation data sim_data = ei_net.getAllData() # add connection matrices sim_data['connections'] = ei_net.getConnections()