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 d.close() print("Script total run time: {0} s".format(overalT)) ################################################################################
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 d.close() print("Script total run time: {0} s".format(overalT)) ################################################################################