def main(args): from ZigZag.ListRuns import ExpandTrackRuns trackConfs = ParamUtils.LoadTrackerParams(args.trackconfs) trackRuns = ExpandTrackRuns(trackConfs.keys(), args.trackRuns) trackrunConfs = dict([(runName, trackConfs[runName]) for runName in trackRuns]) MultiTrack(args.multiSim, trackrunConfs, path=args.directory)
def main(args): from ZigZag.ListRuns import ExpandTrackRuns dirName = os.path.join(args.directory, args.simName) simFile = os.path.join(dirName, "simParams.conf") simParams = ParamUtils.ReadSimulationParams(simFile) trackConfs = ParamUtils.LoadTrackerParams(args.trackconfs) trackRuns = ExpandTrackRuns(trackConfs.keys(), args.trackRuns) trackrunConfs = dict([(runName, trackConfs[runName]) for runName in trackRuns]) SingleTracking(simFile, args.simName, simParams, trackrunConfs, path=args.directory)
def SingleTracking(simFile, simName, simParams, trackConfs, path='.'): #simParams['trackers'] = trackConfs.keys() simDir = os.path.join(path, simName, '') storedConfFile = os.path.join(simDir, simParams['trackerparams']) if not os.path.exists(storedConfFile): # Initialize an empty config file ParamUtils.SaveConfigFile(storedConfFile, {}) # Now load that one file storedTrackConfs = ParamUtils.LoadTrackerParams([storedConfFile]) for trackRun in trackConfs: tracker = trackConfs[trackRun]['algorithm'] # This is where the tracking is performed! # Trackers.trackerList is a dictionary of Tracker objects Trackers.trackerList[tracker](trackRun, simParams.copy(), trackConfs[trackRun].copy(), returnResults=False, path=simDir) # We want this simulation to know which trackers they used, # so we will update the file after each successful tracking operation. # Note that we still want an ordered, unique list, henced the use of # set() and .sort() simParams['trackers'].append(trackRun) tempHold = list(set(simParams['trackers'])) tempHold.sort() simParams['trackers'] = tempHold # TODO: We could use some sort of 'with' clause here to restore # the original file if something goes wrong here. ParamUtils.SaveSimulationParams(simFile, simParams) # Add these tracker configurations to the sim's global # tracker configuration file for record-keeping storedTrackConfs[trackRun] = trackConfs[trackRun].copy() ParamUtils.SaveConfigFile(storedConfFile, storedTrackConfs)
def RenameRuns(simName, old, new, trackRuns, dirName='.'): """ For *trackRuns* in *simName*, replace the *old* portion with *new*. This over-writes existing trackruns and does a bit of house-keeping in situations where the old run is incomplete while the existing new run has extra files. Also takes care of the simulation param file and the stored tracker configuration file, if it exists. """ simDir = os.path.join(dirName, simName) simFile = os.path.join(simDir, "simParams.conf") storedConfFile = os.path.join(simDir, simParams['trackerparams']) simParams = ParamUtils.ReadSimulationParams(simFile) if not os.path.exists(storedConfFile): # Initialize an empty config file ParamUtils.SaveConfigFile(storedConfFile, {}) # Now load that one file trackerConfs = ParamUtils.LoadTrackerParams([storedConfFile]) for oldRun in trackRuns: newRun = oldRun.replace(old, new) RenameRun(simName, simParams, trackerConfs, oldRun, newRun, dirName=dirName) # TODO: We could use some sort of 'with' clause here to restore # the original file if something goes wrong here. ParamUtils.SaveSimulationParams(simFile, simParams) ParamUtils.SaveConfigFile(storedConfFile, trackerConfs)