Exemplo n.º 1
0
def plotSeries2(series, method='Arser', period=False, figsize=(12,9)):
    fig, axs = subplots(1,4, figsize=figsize)
    if series.index.dtype ==  numpy.dtype('int64'): 
        series = pandas.Series(array(series), index=getTimePoints(series))
    #series = rollingMeanScale(series, 24, plotAxis=axs[0,1])
    arser = Arser(list(series.index), series)
    if period:
        stats = arser.evaluate(T_start =period, T_end=period)
        period, phase = stats['period'][0], stats['phase'][0]
    else:
        if method=='Arser':
            stats = arser.evaluate()
            period, phase = stats['period'][0], stats['phase'][0]
            if int(period)==24:
                stats = arser.evaluateNew()
                period, phase = stats['period'], stats['phase']
        else:
            stats = arser.evaluateNew()
            period, phase = stats['period'], stats['phase']
    
    plotLucData(series, ax=axs[0])
    series = rollingMeanScale(series, period, plotAxis=axs[1])
    normedDays = amplitudeAdjust(series, phase, period, plotAxis=axs[2])
    #axs[1,0].set_ylabel('Normalized Luminescence')
    signal = getCharacteristicSignal(normedDays, phase, 
                                     period, plotAxis=axs[3])
    for ax in axs[:3]: ax.set_xlabel('Hours in LL')
    axs[3].set_xlabel('Hours Past Peak Expression')
    for ax in axs[1:]: ax.set_yticks([])
    axs[0].set_xbound(5,105)
    axs[1].set_xbound(5,105)
    axs[2].set_xbound(5,105)
    fig.subplots_adjust(wspace=.05, top=.9, bottom=.2)
    return signal, normedDays, period, phase
Exemplo n.º 2
0
def getNormedDays(series, period=False, method='Arser', cheap=False):
    if series.index.dtype ==  numpy.dtype('int64'): 
        series = pandas.Series(array(series), index=getTimePoints(series))
    #series = rollingMeanScale(series, 24, plotAxis=axs[0,1])
    arser = Arser(list(series.index), series)
    if period:
        stats = arser.evaluate(T_start =period, T_end=period)
        period, phase = stats['period'][0], stats['phase'][0]
    else:
        if method=='Arser':
            stats = arser.evaluate()
            period, phase = stats['period'][0], stats['phase'][0]
            if int(period)==24:
                stats = arser.evaluateNew()
                period, phase = stats['period'], stats['phase']
        else:
            stats = arser.evaluateNew()
            period, phase = stats['period'], stats['phase']

    if not cheap:
        series = rollingMeanScale(series, period)
    else:
        series = rollingMeanScale(series, period, gamma=.001)
    normedDays, phase = amplitudeAdjust(series, period, plotAxis=False)
    return normedDays, period, phase
Exemplo n.º 3
0
def plotSeries(series, method='Arser', period=False, figsize=(12,9)):
    fig, axs = subplots(2,2, figsize=figsize)
    if series.index.dtype ==  numpy.dtype('int64'): 
        series = pandas.Series(array(series), index=getTimePoints(series))
    #series = rollingMeanScale(series, 24, plotAxis=axs[0,1])
    arser = Arser(list(series.index), series)
    if period:
        stats = arser.evaluate(T_start =period, T_end=period)
        period, phase = stats['period'][0], stats['phase'][0]
    else:
        if method=='Arser':
            stats = arser.evaluate()
            period, phase = stats['period'][0], stats['phase'][0]
            if int(period)==24:
                stats = arser.evaluateNew()
                period, phase = stats['period'], stats['phase']
        else:
            stats = arser.evaluateNew()
            period, phase = stats['period'], stats['phase']
    
    plotLucData(series, ax=axs[0,0])
    series = rollingMeanScale(series, period, plotAxis=axs[0,1])
    normedDays,phase = amplitudeAdjust(series, period, plotAxis=axs[1,0])
    axs[1,0].set_ylabel('Normalized Luminescence')
    signal = getCharacteristicSignal(normedDays, phase, 
                                     period, plotAxis=axs[1,1])
    return signal, normedDays, period, phase
Exemplo n.º 4
0
def plotSeries(series):
    fig, axs = subplots(2,2, figsize=(12,9))
    arser = Arser(list(series.index), series)
    stats = arser.evaluate()
    period, phase = stats['period'][0], stats['phase'][0]
    
    plotLucData(series, ax=axs[0,0])
    series = rollingMeanScale(series, period, plotAxis=axs[0,1])
    normedDays = amplitudeAdjust(series, phase, period, plotAxis=axs[1,0])
    signal = getCharacteristicSignal(normedDays, phase, period, plotAxis=axs[1,1])
Exemplo n.º 5
0
def plotSeriesOld(series):
    times = arange(5, 106, 2.5)
    numDays = 4
    colors = ['b', 'g', 'r', 'c']

    fig, axs = subplots(1, 2, figsize=(12, 4))
    arser = Arser(list(series.index), series)
    stats = arser.evaluate()
    period, phase = stats['period'][0], stats['phase'][0]
    dayBreaks = [phase + period * day for day in range(numDays + 1)]
    timePoints = []
    for i in range(numDays):
        values = map(
            float,
            list(series.index[(series.index > (dayBreaks[i] - .5))
                              & (series.index < (dayBreaks[i + 1] + .5))]))
        timePoints.append(values)

    axs[0].plot(times, array(series), '--', label='normal', color='black')
    axs[0].plot(times,
                array(series),
                'o',
                label='normal',
                color='black',
                alpha=.3)
    axs[0].set_title('Raw Data')

    normedDays = [
        cycle_adjust(array(series.ix[timePoints[i]])) for i in range(numDays)
    ]
    t0 = array([[t] for day in timePoints for t in day])
    t0 = (t0 - phase) % period
    t0 = [[t] for t in array([t0 - period, t0, t0 + period]).flatten()]
    normedSeries = [e for day in normedDays for e in day]
    normedSeries = array([normedSeries, normedSeries, normedSeries]).flatten()

    for i in range(numDays):
        axs[1].plot(array(timePoints[i] - phase) % period,
                    normedDays[i],
                    'o',
                    label=str(i),
                    color=colors[i])
        axs[1].set_title('Raw Data Phase Shifted')
        axs[1].legend(loc='best')

    svr_rbf = SVR(kernel='rbf', C=1e4, gamma=.03, epsilon=.01, scale_C=True)
    y_rbf = svr_rbf.fit(t0, list(normedSeries))
    t1 = [[t] for t in arange(0, period, period / 100.)]
    axs[1].plot(t1, y_rbf.predict(t1))
    axs[1].set_xbound(0, period)
Exemplo n.º 6
0
def getNormedDays(series, period=False, method='Arser', cheap=False):
    if series.index.dtype == numpy.dtype('int64'):
        series = pandas.Series(array(series), index=getTimePoints(series))
    #series = rollingMeanScale(series, 24, plotAxis=axs[0,1])
    arser = Arser(list(series.index), series)
    if period:
        stats = arser.evaluate(T_start=period, T_end=period)
        period, phase = stats['period'][0], stats['phase'][0]
    else:
        if method == 'Arser':
            stats = arser.evaluate()
            period, phase = stats['period'][0], stats['phase'][0]
            if int(period) == 24:
                stats = arser.evaluateNew()
                period, phase = stats['period'], stats['phase']
        else:
            stats = arser.evaluateNew()
            period, phase = stats['period'], stats['phase']

    if not cheap:
        series = rollingMeanScale(series, period)
    else:
        series = rollingMeanScale(series, period, gamma=.001)
    normedDays, phase = amplitudeAdjust(series, period, plotAxis=False)
    return normedDays, period, phase
Exemplo n.º 7
0
def plotSeries(series, method='Arser', period=False, figsize=(12, 9)):
    fig, axs = subplots(2, 2, figsize=figsize)
    if series.index.dtype == numpy.dtype('int64'):
        series = pandas.Series(array(series), index=getTimePoints(series))
    #series = rollingMeanScale(series, 24, plotAxis=axs[0,1])
    arser = Arser(list(series.index), series)
    if period:
        stats = arser.evaluate(T_start=period, T_end=period)
        period, phase = stats['period'][0], stats['phase'][0]
    else:
        if method == 'Arser':
            stats = arser.evaluate()
            period, phase = stats['period'][0], stats['phase'][0]
            if int(period) == 24:
                stats = arser.evaluateNew()
                period, phase = stats['period'], stats['phase']
        else:
            stats = arser.evaluateNew()
            period, phase = stats['period'], stats['phase']

    plotLucData(series, ax=axs[0, 0])
    series = rollingMeanScale(series, period, plotAxis=axs[0, 1])
    normedDays, phase = amplitudeAdjust(series, period, plotAxis=axs[1, 0])
    axs[1, 0].set_ylabel('Normalized Luminescence')
    signal = getCharacteristicSignal(normedDays,
                                     phase,
                                     period,
                                     plotAxis=axs[1, 1])
    return signal, normedDays, period, phase
Exemplo n.º 8
0
def plotSeriesOld(series):
    times = arange(5,106,2.5)
    numDays=4
    colors = ['b','g','r','c']
    
    fig, axs = subplots(1,2,figsize=(12,4))
    arser = Arser(list(series.index), series)
    stats = arser.evaluate()
    period, phase = stats['period'][0], stats['phase'][0]
    dayBreaks = [phase+period*day for day in range(numDays+1)]
    timePoints = []
    for i in range(numDays):
        values = map(float, list(series.index[  (series.index > (dayBreaks[i]-.5)) 
                                              & (series.index < (dayBreaks[i+1]+.5))]))
        timePoints.append(values)
    
    axs[0].plot(times, array(series), '--',label='normal',color='black')
    axs[0].plot(times, array(series), 'o',label='normal',color='black', alpha=.3)
    axs[0].set_title('Raw Data')
    
    normedDays = [cycle_adjust(array(series.ix[timePoints[i]])) for i in range(numDays)]
    t0 = array([[t] for day in timePoints for t in day])
    t0 = (t0 - phase) % period
    t0 = [[t] for t in array([t0-period,t0,t0+period]).flatten()]
    normedSeries = [e for day in normedDays for e in day]
    normedSeries = array([normedSeries,normedSeries,normedSeries]).flatten()

    for i in range(numDays):
        axs[1].plot(array(timePoints[i]-phase) % period, normedDays[i], 'o', 
                    label=str(i),color=colors[i])
        axs[1].set_title('Raw Data Phase Shifted')
        axs[1].legend(loc='best')
    
    svr_rbf = SVR(kernel='rbf', C=1e4, gamma=.03, epsilon=.01)
    y_rbf = svr_rbf.fit(t0, list(normedSeries))
    t1 = [[t] for t in arange(0,period, period/100.)]
    axs[1].plot(t1, y_rbf.predict(t1));
    axs[1].set_xbound(0,period)
Exemplo n.º 9
0
def plotSeries2(series, method='Arser', period=False, figsize=(12, 9)):
    fig, axs = subplots(1, 4, figsize=figsize)
    if series.index.dtype == numpy.dtype('int64'):
        series = pandas.Series(array(series), index=getTimePoints(series))
    #series = rollingMeanScale(series, 24, plotAxis=axs[0,1])
    arser = Arser(list(series.index), series)
    if period:
        stats = arser.evaluate(T_start=period, T_end=period)
        period, phase = stats['period'][0], stats['phase'][0]
    else:
        if method == 'Arser':
            stats = arser.evaluate()
            period, phase = stats['period'][0], stats['phase'][0]
            if int(period) == 24:
                stats = arser.evaluateNew()
                period, phase = stats['period'], stats['phase']
        else:
            stats = arser.evaluateNew()
            period, phase = stats['period'], stats['phase']

    plotLucData(series, ax=axs[0])
    series = rollingMeanScale(series, period, plotAxis=axs[1])
    normedDays = amplitudeAdjust(series, phase, period, plotAxis=axs[2])
    #axs[1,0].set_ylabel('Normalized Luminescence')
    signal = getCharacteristicSignal(normedDays,
                                     phase,
                                     period,
                                     plotAxis=axs[3])
    for ax in axs[:3]:
        ax.set_xlabel('Hours in LL')
    axs[3].set_xlabel('Hours Past Peak Expression')
    for ax in axs[1:]:
        ax.set_yticks([])
    axs[0].set_xbound(5, 105)
    axs[1].set_xbound(5, 105)
    axs[2].set_xbound(5, 105)
    fig.subplots_adjust(wspace=.05, top=.9, bottom=.2)
    return signal, normedDays, period, phase