Example #1
0
def writeRKProbTraj(fh, trajs, probabilities, config):
    """writes time, distance, kappa and the total probability in an opened file handle"""
    if config:
        startclip = config.get("Photon Flooding", "startclip")
        endclip = config.get("Photon Flooding", "endclip")
    else:
        startclip = 0
        endclip = 0

    keys = trajs.keys()
    keys.sort()
    for key in keys:
        fh.write("# starting traj %s\n" % key)

        classprob = getTrajClassProbability(trajs[key], probabilities)
        nrtrajs = getClassTrajCount(trajs[key]["species"], trajs)
        trajlen = trajs[key]["length"] - startclip - endclip
        probprefact = classprob / nrtrajs / trajlen

        if not trajs[key].has_key("photons"):
            trajs[key]["photons"] = numpy.ones(len(trajs[key]["t"]))
        trajs[key]["photons"] = trajs[key]["photons"] * probprefact
        arr = numpy.array((trajs[key]["t"], trajs[key]["R"], trajs[key]["k2"], trajs[key]["photons"]))
        if endclip == 0:
            numpy.savetxt(fh, arr.T[startclip:, :])
        else:
            numpy.savetxt(fh, arr.T[startclip:-endclip, :])

        print key, "written with traj %s probability with length %d, clipping %d and %d frames at beginning and end." % (probprefact, trajs[key]["length"], startclip, endclip)
Example #2
0
def writeRKProbTraj(fh, trajs, probabilities, config):
    """writes time, distance, kappa and the total probability in an opened file handle"""
    if config:
        startclip = config.get("Photon Flooding", "startclip")
        endclip = config.get("Photon Flooding", "endclip")
    else:
        startclip = 0
        endclip = 0

    keys = trajs.keys()
    keys.sort()
    for key in keys:
        fh.write("# starting traj %s\n" % key)

        classprob = getTrajClassProbability(trajs[key], probabilities)
        nrtrajs = getClassTrajCount(trajs[key]["species"], trajs)
        trajlen = trajs[key]["length"] - startclip - endclip
        probprefact = classprob / nrtrajs / trajlen

        if not trajs[key].has_key("photons"):
            trajs[key]["photons"] = numpy.ones(len(trajs[key]["t"]))
        trajs[key]["photons"] = trajs[key]["photons"] * probprefact
        arr = numpy.array((trajs[key]["t"], trajs[key]["R"], trajs[key]["k2"],
                           trajs[key]["photons"]))
        if endclip == 0:
            numpy.savetxt(fh, arr.T[startclip:, :])
        else:
            numpy.savetxt(fh, arr.T[startclip:-endclip, :])

        print key, "written with traj %s probability with length %d, clipping %d and %d frames at beginning and end." % (
            probprefact, trajs[key]["length"], startclip, endclip)
Example #3
0
def normalizeTrajProbForSpecies(trajs, probs):
    for trajkey in trajs:
        traj = trajs[trajkey]
        if not traj.has_key("l"):
            continue
        print "Correcting trajectory", trajkey, "for class probability in 4th column."
        prb = getTrajClassProbability(traj, probs)
        traj["l"] *= prb
Example #4
0
def normalizeTrajProbForSpecies(trajs, probs):
    for trajkey in trajs:
        traj = trajs[trajkey]
        if not traj.has_key("l"):
            continue
        print "Correcting trajectory", trajkey, "for class probability in 4th column."
        prb = getTrajClassProbability(traj, probs)
        traj["l"] *= prb