예제 #1
0
def subset_time_pdf(mec,
                    tres,
                    state1,
                    state2,
                    tmin=0.00001,
                    tmax=1000,
                    points=512,
                    unit='ms'):
    """
    Calculate ideal pdf of any subset dwell times.

    Parameters
    ----------
    mec : instance of type Mechanism
    tres : float
        Time resolution.
    state1, state2 : ints
    tmin, tmax : floats
        Time range for burst length ditribution.
    points : int
        Number of points per plot.
    unit : str
        'ms'- milliseconds.

    Returns
    -------
    t : ndarray of floats, shape (num of points)
        Time in millisec.
    spdf : ndarray of floats, shape (num of points)
        Subset dwell time pdf.
    """

    open = False
    if open:
        eigs, w = scl.ideal_dwell_time_pdf_components(mec.QAA, qml.phiA(mec))
    else:
        eigs, w = scl.ideal_dwell_time_pdf_components(mec.QII, qml.phiF(mec))

    tmax = tau.max() * 20
    t = np.logspace(math.log10(tmin), math.log10(tmax), points)

    # Ideal pdf.
    fac = 1 / np.sum((w / eigs) * np.exp(-tres * eigs))  # Scale factor
    ipdf = t * pdfs.expPDF(t, 1 / eigs, w / eigs) * fac

    spdf = np.zeros(points)
    for i in range(points):
        spdf[i] = t[i] * scl.ideal_subset_time_pdf(mec.Q, state1, state2,
                                                   t[i]) * fac

    if unit == 'ms':
        t = t * 1000  # x scale in millisec

    return t, ipdf, spdf
예제 #2
0
def subset_time_pdf(mec, tres, state1, state2,
    tmin=0.00001, tmax=1000, points=512, unit='ms'):
    """
    Calculate ideal pdf of any subset dwell times.

    Parameters
    ----------
    mec : instance of type Mechanism
    tres : float
        Time resolution.
    state1, state2 : ints
    tmin, tmax : floats
        Time range for burst length ditribution.
    points : int
        Number of points per plot.
    unit : str
        'ms'- milliseconds.

    Returns
    -------
    t : ndarray of floats, shape (num of points)
        Time in millisec.
    spdf : ndarray of floats, shape (num of points)
        Subset dwell time pdf.
    """

    open = False
    if open:
        eigs, w = scl.ideal_dwell_time_pdf_components(mec.QAA, qml.phiA(mec))
    else:
        eigs, w = scl.ideal_dwell_time_pdf_components(mec.QII, qml.phiF(mec))

    tmax = tau.max() * 20
    t = np.logspace(math.log10(tmin), math.log10(tmax), points)

    # Ideal pdf.
    fac = 1 / np.sum((w / eigs) * np.exp(-tres * eigs)) # Scale factor
    ipdf = t * pdfs.expPDF(t, 1 / eigs, w / eigs) * fac

    spdf = np.zeros(points)
    for i in range(points):
        spdf[i] = t[i] * scl.ideal_subset_time_pdf(mec.Q,
            state1, state2, t[i]) * fac

    if unit == 'ms':
        t = t * 1000 # x scale in millisec

    return t, ipdf, spdf
예제 #3
0
def open_time_pdf(mec, tres, tmin=0.00001, tmax=1000, points=512, unit='ms'):
    """
    Calculate ideal asymptotic and exact open time distributions.

    Parameters
    ----------
    mec : instance of type Mechanism
    tres : float
        Time resolution.
    tmin, tmax : floats
        Time range for burst length ditribution.
    points : int
        Number of points per plot.
    unit : str
        'ms'- milliseconds.

    Returns
    -------
    t : ndarray of floats, shape (num of points)
        Time in millisec.
    ipdf, epdf, apdf : ndarrays of floats, shape (num of points)
        Ideal, exact and asymptotic open time distributions.
    """

    open = True

    # Asymptotic pdf
    roots = scl.asymptotic_roots(tres,
        mec.QAA, mec.QII, mec.QAI, mec.QIA, mec.kA, mec.kI)

    tmax = (-1 / roots.max()) * 20
    t = np.logspace(math.log10(tmin), math.log10(tmax), points)

    # Ideal pdf.
    eigs, w = scl.ideal_dwell_time_pdf_components(mec.QAA, qml.phiA(mec))
    fac = 1 / np.sum((w / eigs) * np.exp(-tres * eigs)) # Scale factor
    ipdf = t * pdfs.expPDF(t, 1 / eigs, w / eigs) * fac

    # Asymptotic pdf
    GAF, GFA = qml.iGs(mec.Q, mec.kA, mec.kI)
    areas = scl.asymptotic_areas(tres, roots,
        mec.QAA, mec.QII, mec.QAI, mec.QIA,
        mec.kA, mec.kI, GAF, GFA)
    apdf = scl.asymptotic_pdf(t, tres, -1 / roots, areas)

    # Exact pdf
    eigvals, gamma00, gamma10, gamma11 = scl.exact_GAMAxx(mec,
        tres, open)
    epdf = np.zeros(points)
    for i in range(points):
        epdf[i] = (t[i] * scl.exact_pdf(t[i], tres,
            roots, areas, eigvals, gamma00, gamma10, gamma11))
            
    if unit == 'ms':
        t = t * 1000 # x scale in millisec

    return t, ipdf, epdf, apdf
예제 #4
0
def shut_time_pdf(mec, tres, tmin=0.00001, tmax=1000, points=512, unit='ms'):
    """
    Calculate ideal asymptotic and exact shut time distributions.

    Parameters
    ----------
    mec : instance of type Mechanism
    tres : float
        Time resolution.
    tmin, tmax : floats
        Time range for burst length ditribution.
    points : int
        Number of points per plot.
    unit : str
        'ms'- milliseconds.

    Returns
    -------
    t : ndarray of floats, shape (num of points)
        Time in millisec.
    ipdf, epdf, apdf : ndarrays of floats, shape (num of points)
        Ideal, exact and asymptotic shut time distributions.
    """

    open = False

    # Asymptotic pdf
    roots = scl.asymptotic_roots(tres, mec.QII, mec.QAA, mec.QIA, mec.QAI,
                                 mec.kI, mec.kA)

    tmax = (-1 / roots.max()) * 20
    t = np.logspace(math.log10(tmin), math.log10(tmax), points)

    # Ideal pdf.
    eigs, w = scl.ideal_dwell_time_pdf_components(mec.QII, qml.phiF(mec))
    fac = 1 / np.sum((w / eigs) * np.exp(-tres * eigs))  # Scale factor
    ipdf = t * pdfs.expPDF(t, 1 / eigs, w / eigs) * fac

    # Asymptotic pdf
    GAF, GFA = qml.iGs(mec.Q, mec.kA, mec.kI)
    areas = scl.asymptotic_areas(tres, roots, mec.QII, mec.QAA, mec.QIA,
                                 mec.QAI, mec.kI, mec.kA, GFA, GAF)
    apdf = scl.asymptotic_pdf(t, tres, -1 / roots, areas)

    # Exact pdf
    eigvals, gamma00, gamma10, gamma11 = scl.exact_GAMAxx(mec, tres, open)
    epdf = np.zeros(points)
    for i in range(points):
        epdf[i] = (t[i] * scl.exact_pdf(t[i], tres, roots, areas, eigvals,
                                        gamma00, gamma10, gamma11))

    if unit == 'ms':
        t = t * 1000  # x scale in millisec

    return t, ipdf, epdf, apdf
예제 #5
0
def adjacent_open_time_pdf(mec,
                           tres,
                           u1,
                           u2,
                           tmin=0.00001,
                           tmax=1000,
                           points=512,
                           unit='ms'):
    """
    Calculate pdf's of ideal all open time and open time adjacent to specified shut
    time range.

    Parameters
    ----------
    mec : instance of type Mechanism
    tres : float
        Time resolution.
    tmin, tmax : floats
        Time range for burst length ditribution.
    points : int
        Number of points per plot.
    unit : str
        'ms'- milliseconds.

    Returns
    -------
    t : ndarray of floats, shape (num of points)
        Time in millisec.
    ipdf, ajpdf : ndarrays of floats, shape (num of points)
        Ideal all and adjacent open time distributions.
    """

    # Ideal pdf.
    eigs, w = scl.ideal_dwell_time_pdf_components(mec.QAA, qml.phiA(mec))
    tmax = (1 / eigs.max()) * 100
    t = np.logspace(math.log10(tmin), math.log10(tmax), points)

    fac = 1 / np.sum((w / eigs) * np.exp(-tres * eigs))  # Scale factor
    ipdf = t * pdfs.expPDF(t, 1 / eigs, w / eigs) * fac

    # Ajacent open time pdf
    eigs, w = scl.adjacent_open_to_shut_range_pdf_components(
        u1, u2, mec.QAA, mec.QAI, mec.QII, mec.QIA,
        qml.phiA(mec).reshape((1, mec.kA)))
    #    fac = 1 / np.sum((w / eigs) * np.exp(-tres * eigs)) # Scale factor
    ajpdf = t * pdfs.expPDF(t, 1 / eigs, w / eigs) * fac

    if unit == 'ms':
        t = t * 1000  # x scale in millisec

    return t, ipdf, ajpdf
예제 #6
0
def adjacent_open_time_pdf(mec, tres, u1, u2, 
    tmin=0.00001, tmax=1000, points=512, unit='ms'):
    """
    Calculate pdf's of ideal all open time and open time adjacent to specified shut
    time range.

    Parameters
    ----------
    mec : instance of type Mechanism
    tres : float
        Time resolution.
    tmin, tmax : floats
        Time range for burst length ditribution.
    points : int
        Number of points per plot.
    unit : str
        'ms'- milliseconds.

    Returns
    -------
    t : ndarray of floats, shape (num of points)
        Time in millisec.
    ipdf, ajpdf : ndarrays of floats, shape (num of points)
        Ideal all and adjacent open time distributions.
    """

    # Ideal pdf.
    eigs, w = scl.ideal_dwell_time_pdf_components(mec.QAA, qml.phiA(mec))
    tmax = (1 / eigs.max()) * 100
    t = np.logspace(math.log10(tmin), math.log10(tmax), points)
    
    fac = 1 / np.sum((w / eigs) * np.exp(-tres * eigs)) # Scale factor
    ipdf = t * pdfs.expPDF(t, 1 / eigs, w / eigs) * fac

    # Ajacent open time pdf
    eigs, w = scl.adjacent_open_to_shut_range_pdf_components(u1, u2, 
        mec.QAA, mec.QAI, mec.QII, mec.QIA, qml.phiA(mec).reshape((1,mec.kA)))
#    fac = 1 / np.sum((w / eigs) * np.exp(-tres * eigs)) # Scale factor
    ajpdf = t * pdfs.expPDF(t, 1 / eigs, w / eigs) * fac
           
    if unit == 'ms':
        t = t * 1000 # x scale in millisec

    return t, ipdf, ajpdf
예제 #7
0
    def test_openshut(self):

        # # # Initial HJC vectors.
        expQFF = qml.expQt(self.mec.QFF, self.tres)
        expQAA = qml.expQt(self.mec.QAA, self.tres)
        GAF, GFA = qml.iGs(self.mec.Q, self.mec.kA, self.mec.kF)
        eGAF = qml.eGs(GAF, GFA, self.mec.kA, self.mec.kF, expQFF)
        eGFA = qml.eGs(GFA, GAF, self.mec.kF, self.mec.kA, expQAA)
        phiA = qml.phiHJC(eGAF, eGFA, self.mec.kA)
        phiF = qml.phiHJC(eGFA, eGAF, self.mec.kF)

        self.assertAlmostEqual(phiA[0], 0.153966, 6)
        self.assertAlmostEqual(phiA[1], 0.846034, 6)
        self.assertAlmostEqual(phiF[0], 0.530369, 6)
        self.assertAlmostEqual(phiF[1], 0.386116, 6)
        self.assertAlmostEqual(phiF[2], 0.0835153, 6)

        # Ideal shut time pdf
        eigs, w = scl.ideal_dwell_time_pdf_components(self.mec.QFF,
                                                      qml.phiF(self.mec))
        self.assertAlmostEqual(eigs[0], 0.263895, 6)
        self.assertAlmostEqual(eigs[1], 2062.93, 2)
        self.assertAlmostEqual(eigs[2], 19011.8, 1)
        self.assertAlmostEqual(w[0], 0.0691263, 6)
        self.assertAlmostEqual(w[1], 17.2607, 4)
        self.assertAlmostEqual(w[2], 13872.7, 1)

        # Asymptotic shut time pdf
        roots = scl.asymptotic_roots(self.tres, self.mec.QFF, self.mec.QAA,
                                     self.mec.QFA, self.mec.QAF, self.mec.kF,
                                     self.mec.kA)
        areas = scl.asymptotic_areas(self.tres, roots, self.mec.QFF,
                                     self.mec.QAA, self.mec.QFA, self.mec.QAF,
                                     self.mec.kF, self.mec.kA, GFA, GAF)
        mean = scl.exact_mean_time(self.tres, self.mec.QFF, self.mec.QAA,
                                   self.mec.QFA, self.mec.kF, self.mec.kA, GFA,
                                   GAF)
        self.assertAlmostEqual(-roots[0], 17090.2, 1)
        self.assertAlmostEqual(-roots[1], 2058.08, 2)
        self.assertAlmostEqual(-roots[2], 0.243565, 6)
        self.assertAlmostEqual(areas[0] * 100, 28.5815, 4)
        self.assertAlmostEqual(areas[1] * 100, 1.67311, 5)
        self.assertAlmostEqual(areas[2] * 100, 68.3542, 4)

        # Exact pdf
        eigvals, gamma00, gamma10, gamma11 = scl.exact_GAMAxx(
            self.mec, self.tres, False)
        self.assertAlmostEqual(gamma00[0], 0.940819, 6)
        self.assertAlmostEqual(gamma00[1], 117.816, 3)
        self.assertAlmostEqual(gamma00[2], 24.8962, 4)
        self.assertAlmostEqual(gamma00[3], 1.28843, 5)
        self.assertAlmostEqual(gamma00[4], 5370.18, 2)
        self.assertAlmostEqual(gamma10[0], 4.57792, 5)
        self.assertAlmostEqual(gamma10[1], 100.211, 3)
        self.assertAlmostEqual(gamma10[2], -5.49855, 4)
        self.assertAlmostEqual(gamma10[3], 0.671548, 6)
        self.assertAlmostEqual(gamma10[4], -99.9617, 4)
        self.assertAlmostEqual(gamma11[0], 0.885141, 6)
        self.assertAlmostEqual(gamma11[1], 43634.99, 1)
        self.assertAlmostEqual(gamma11[2], 718.068, 3)
        self.assertAlmostEqual(gamma11[3], -39.7437, 3)
        self.assertAlmostEqual(gamma11[4], -1.9832288e+06, 0)