Lv2_average_ps_methods.py
def noise_hist(eventfile,segment_length,demod,tbin_size,threshold,PI1,PI2,t1,t2,starting_freq,W):
    """
    Given the average spectrum for an ObsID, return the histogram of powers, such
    that you have N(>P). This is for powers corresponding to frequencies larger
    than some starting frequency (perhaps to avoid red noise).

    eventfile - path to the event file. Will extract ObsID from this for the NICER files.
    segment_length - length of the segments
    demod - whether we're dealing with demodulated data or not!
    tbin_size - size of the time bin
    threshold - if data is under threshold (in percentage), then don't use the segment!
    PI1 - lower bound of PI (not energy in keV!) desired for the energy range
    PI2 - upper bound of PI (not energy in keV!) desired for the energy range
    t1 - starting time for calculation of averaged power spectra
    t2 - ending time for calculation of averaged power spectra
    (note that t=0 corresponds to the MET of the FIRST event in the eventfile, so will need to inspect light curve with Lv2_lc.py to get times)
    starting_freq - frequency to start constructing the histogram of powers from
    W - number of consecutive frequency bins to AVERAGE over
    """
    if demod != True and demod != False:
        raise ValueError("demod should either be True or False!")

    f,ps = average_ps(eventfile,segment_length,demod,tbin_size,threshold,PI1,PI2,t1,t2,starting_freq,W)

    ps_to_use = ps[f>starting_freq]
    ps_bins = np.linspace(min(ps_to_use),max(ps_to_use),1000)
    N_greaterthanP = []
    print('Creating the noise histogram [N(>P)]...')
    for i in range(len(ps_bins)):
        array_greaterthan = ps_to_use[ps_to_use>ps_bins[i]]
        N_greaterthanP.append(len(array_greaterthan))

    return ps_bins, N_greaterthanP

    Given the average spectrum for an ObsID, return the histogram of powers, such
    that you have N(>P). This is for powers corresponding to frequencies larger
    than some starting frequency (perhaps to avoid red noise).

    eventfile - path to the event file. Will extract ObsID from this for the NICER files.
    segment_length - length of the segments
    demod - whether we're dealing with demodulated data or not!
    tbin_size - size of the time bin
    threshold - if data is under threshold (in percentage), then don't use the segment!
    PI1 - lower bound of PI (not energy in keV!) desired for the energy range
    PI2 - upper bound of PI (not energy in keV!) desired for the energy range
    t1 - starting time for calculation of averaged power spectra
    t2 - ending time for calculation of averaged power spectra
    (note that t=0 corresponds to the MET of the FIRST event in the eventfile, so will need to inspect light curve with Lv2_lc.py to get times)
    starting_freq - frequency to start constructing the histogram of powers from
    W - number of consecutive frequency bins to AVERAGE over
    
Given the average spectrum for an ObsID, return the histogram of powers, such
that you have N(>P). This is for powers corresponding to frequencies larger
than some starting frequency (perhaps to avoid red noise).

path to the event file. Will extract ObsID from this for the NICER files.
segment_length - length of the segments
demod - whether we're dealing with demodulated data or not.
tbin_size - size of the time bin
threshold - if data is under threshold (in percentage), then don't use the segment.
Given the average spectrum for an ObsID return the histogram of powers such that you have N ( > P ) . This is for powers corresponding to frequencies larger than some starting frequency ( perhaps to avoid red noise ) . path to the event file . Will extract ObsID from this for the NICER files . segment_length - length of the segments demod - whether we ' re dealing with demodulated data or not . tbin_size - size of the time bin threshold - if data is under threshold ( in percentage ) then don ' t use the segment .
def noise_hist(eventfile,segment_length,demod,tbin_size,threshold,PI1,PI2,t1,t2,starting_freq,W):
    if demod != True and demod != False:
        raise ValueError("demod should either be True or False!")
    f,ps = average_ps(eventfile,segment_length,demod,tbin_size,threshold,PI1,PI2,t1,t2,starting_freq,W)
    ps_to_use = ps[f>starting_freq]
    ps_bins = np.linspace(min(ps_to_use),max(ps_to_use),1000)
    N_greaterthanP = []
    print('Creating the noise histogram [N(>P)]...')
    for i in range(len(ps_bins)):
        array_greaterthan = ps_to_use[ps_to_use>ps_bins[i]]
        N_greaterthanP.append(len(array_greaterthan))
    return ps_bins, N_greaterthanP
def noise_hist ( eventfile , segment_length , demod , tbin_size , threshold , PI1 , PI2 , t1 , t2 , starting_freq , W ) : if demod != True and demod != False : raise ValueError ( "demod should either be True or False!" ) f , ps = average_ps ( eventfile , segment_length , demod , tbin_size , threshold , PI1 , PI2 , t1 , t2 , starting_freq , W ) ps_to_use = ps [ f > starting_freq ] ps_bins = np . linspace ( min ( ps_to_use ) , max ( ps_to_use ) , 1000 ) N_greaterthanP = [ ] print ( 'Creating the noise histogram [N(>P)]...' ) for i in range ( len ( ps_bins ) ) : array_greaterthan = ps_to_use [ ps_to_use > ps_bins [ i ] ] N_greaterthanP . append ( len ( array_greaterthan ) ) return ps_bins , N_greaterthanP
Given the average spectrum for an ObsID, return the histogram of powers, such
that you have N(>P).
Given the average spectrum for an ObsID return the histogram of powers such that you have N ( > P ) .
"""
    Given the average spectrum for an ObsID, return the histogram of powers, such
    that you have N(>P). This is for powers corresponding to frequencies larger
    than some starting frequency (perhaps to avoid red noise).

    eventfile - path to the event file. Will extract ObsID from this for the NICER files.
    segment_length - length of the segments
    demod - whether we're dealing with demodulated data or not!
    tbin_size - size of the time bin
    threshold - if data is under threshold (in percentage), then don't use the segment!
    PI1 - lower bound of PI (not energy in keV!) desired for the energy range
    PI2 - upper bound of PI (not energy in keV!) desired for the energy range
    t1 - starting time for calculation of averaged power spectra
    t2 - ending time for calculation of averaged power spectra
    (note that t=0 corresponds to the MET of the FIRST event in the eventfile, so will need to inspect light curve with Lv2_lc.py to get times)
    starting_freq - frequency to start constructing the histogram of powers from
    W - number of consecutive frequency bins to AVERAGE over
    """
eventfile
segment_length
demod
tbin_size
threshold
PI1
PI2
t1
t2
starting_freq
W