Lv2_ps_method.py
def pdgm(times,counts,xlims,vlines,toplot,oversampling):
    """
    Generating the power spectrum through the signal.periodogram method.

    times - array of binned times
    counts - array of counts from the binned data
    xlims - a list or array: first entry = True/False as to whether to impose an
    xlim; second and third entry correspond to the desired x-limits of the plot
    vlines - a list or array: first entry = True/False as to whether to draw
    a vertical line in the plot; second entry is the equation for the vertical line
    toplot - whether to show the plot or not
    oversampling - whether to perform oversampling. Array will consist of
    [True/False, oversampling factor]
    """
    if type(times) != list and type(times) != np.ndarray:
        raise TypeError("times should either be a list or an array!")
    if type(counts) != list and type(counts) != np.ndarray:
        raise TypeError("counts should either be a list or an array!")
    if type(xlims) != list and type(xlims) != np.ndarray:
        raise TypeError("xlims should either be a list or an array!")
    if type(vlines) != list and type(vlines) != np.ndarray:
        raise TypeError("vlines should either be a list or an array!")
    if toplot != True and toplot != False:
        raise ValueError("toplot should either be True or False!")
    if type(oversampling) != list and type(oversampling) != np.ndarray:
        raise TypeError("oversampling should either be a list or an array!")

    T = times[-1] - times[0]
    dt = T/len(times)
    freq = 1/dt
    f,pxx = signal.periodogram(counts,fs=freq)
    print(T,dt,freq)

    if oversampling[0] == True:
        os_counts = oversample(oversampling[1],counts)
        dt = T/len(times)
        freq = 1/dt
        f,pxx = signal.periodogram(os_counts,fs=freq)

    if toplot == True:
        plt.semilogy(f[1:],pxx[1:])#/np.mean(pxx[1:]))
        plt.xlabel('Hz',fontsize=12)
        plt.ylabel('Normalized power spectrum',fontsize=12)
        if xlims[0] == True:
            plt.xlim([xlims[1],xlims[2]])
        if vlines[0] == True:
            plt.axvline(x=vlines[1],color='k',alpha=0.5,lw=0.5)

    return f[1:],pxx[1:]

    Generating the power spectrum through the signal.periodogram method.

    times - array of binned times
    counts - array of counts from the binned data
    xlims - a list or array: first entry = True/False as to whether to impose an
    xlim; second and third entry correspond to the desired x-limits of the plot
    vlines - a list or array: first entry = True/False as to whether to draw
    a vertical line in the plot; second entry is the equation for the vertical line
    toplot - whether to show the plot or not
    oversampling - whether to perform oversampling. Array will consist of
    [True/False, oversampling factor]
    
Generating the power spectrum through the signal.periodogram method.
times - array of binned times
counts - array of counts from the binned data
xlims - a list or array: first entry = True/False as to whether to impose an
xlim; second and third entry correspond to the desired x-limits of the plot
vlines - a list or array: first entry = True/False as to whether to draw
a vertical line in the plot; second entry is the equation for the vertical line
toplot - whether to show the plot or not
oversampling - whether to perform oversampling. Array will consist of
[True/False, oversampling factor]
Generating the power spectrum through the signal . periodogram method . times - array of binned times counts - array of counts from the binned data xlims - a list or array : first entry = True / False as to whether to impose an xlim ; second and third entry correspond to the desired x - limits of the plot vlines - a list or array : first entry = True / False as to whether to draw a vertical line in the plot ; second entry is the equation for the vertical line toplot - whether to show the plot or not oversampling - whether to perform oversampling . Array will consist of [ True / False oversampling factor ]
def pdgm(times,counts,xlims,vlines,toplot,oversampling):
    if type(times) != list and type(times) != np.ndarray:
        raise TypeError("times should either be a list or an array!")
    if type(counts) != list and type(counts) != np.ndarray:
        raise TypeError("counts should either be a list or an array!")
    if type(xlims) != list and type(xlims) != np.ndarray:
        raise TypeError("xlims should either be a list or an array!")
    if type(vlines) != list and type(vlines) != np.ndarray:
        raise TypeError("vlines should either be a list or an array!")
    if toplot != True and toplot != False:
        raise ValueError("toplot should either be True or False!")
    if type(oversampling) != list and type(oversampling) != np.ndarray:
        raise TypeError("oversampling should either be a list or an array!")
    T = times[-1] - times[0]
    dt = T/len(times)
    freq = 1/dt
    f,pxx = signal.periodogram(counts,fs=freq)
    print(T,dt,freq)
    if oversampling[0] == True:
        os_counts = oversample(oversampling[1],counts)
        dt = T/len(times)
        freq = 1/dt
        f,pxx = signal.periodogram(os_counts,fs=freq)
    if toplot == True:
        plt.semilogy(f[1:],pxx[1:])
        plt.xlabel('Hz',fontsize=12)
        plt.ylabel('Normalized power spectrum',fontsize=12)
        if xlims[0] == True:
            plt.xlim([xlims[1],xlims[2]])
        if vlines[0] == True:
            plt.axvline(x=vlines[1],color='k',alpha=0.5,lw=0.5)
    return f[1:],pxx[1:]
def pdgm ( times , counts , xlims , vlines , toplot , oversampling ) : if type ( times ) != list and type ( times ) != np . ndarray : raise TypeError ( "times should either be a list or an array!" ) if type ( counts ) != list and type ( counts ) != np . ndarray : raise TypeError ( "counts should either be a list or an array!" ) if type ( xlims ) != list and type ( xlims ) != np . ndarray : raise TypeError ( "xlims should either be a list or an array!" ) if type ( vlines ) != list and type ( vlines ) != np . ndarray : raise TypeError ( "vlines should either be a list or an array!" ) if toplot != True and toplot != False : raise ValueError ( "toplot should either be True or False!" ) if type ( oversampling ) != list and type ( oversampling ) != np . ndarray : raise TypeError ( "oversampling should either be a list or an array!" ) T = times [ - 1 ] - times [ 0 ] dt = T / len ( times ) freq = 1 / dt f , pxx = signal . periodogram ( counts , fs = freq ) print ( T , dt , freq ) if oversampling [ 0 ] == True : os_counts = oversample ( oversampling [ 1 ] , counts ) dt = T / len ( times ) freq = 1 / dt f , pxx = signal . periodogram ( os_counts , fs = freq ) if toplot == True : plt . semilogy ( f [ 1 : ] , pxx [ 1 : ] ) plt . xlabel ( 'Hz' , fontsize = 12 ) plt . ylabel ( 'Normalized power spectrum' , fontsize = 12 ) if xlims [ 0 ] == True : plt . xlim ( [ xlims [ 1 ] , xlims [ 2 ] ] ) if vlines [ 0 ] == True : plt . axvline ( x = vlines [ 1 ] , color = 'k' , alpha = 0.5 , lw = 0.5 ) return f [ 1 : ] , pxx [ 1 : ]
Generating the power spectrum through the signal.periodogram method.
Generating the power spectrum through the signal . periodogram method .
"""
    Generating the power spectrum through the signal.periodogram method.

    times - array of binned times
    counts - array of counts from the binned data
    xlims - a list or array: first entry = True/False as to whether to impose an
    xlim; second and third entry correspond to the desired x-limits of the plot
    vlines - a list or array: first entry = True/False as to whether to draw
    a vertical line in the plot; second entry is the equation for the vertical line
    toplot - whether to show the plot or not
    oversampling - whether to perform oversampling. Array will consist of
    [True/False, oversampling factor]
    """ #/np.mean(pxx[1:]))
times
counts
xlims
vlines
toplot
oversampling