Ejemplo n.º 1
0
def write_summary_table(blocks, base=os.path.curdir):
    """Write a summary table in variou formats for users to download

    Parameters
    ----------
    blocks : `dict` of `OmegaChannel`
        the channel blocks scanned in the analysis
    base : `str`
        the path for the `<base>` tag to link in the `<head>`
    """
    # record summary data for each channel
    channel, time, freq, Q, energy, snr = ([], [], [], [], [], [])
    for block in blocks.values():
        for chan in block['channels']:
            channel.append(chan.name)
            time.append(chan.t)
            freq.append(chan.f)
            Q.append(chan.Q)
            energy.append(chan.energy)
            snr.append(chan.snr)
    # store in a table
    data = Table([channel, time, freq, Q, energy, snr],
                 names=('Channel', 'Central Time', 'Central Frequency (Hz)',
                        'Quality Factor', 'Normalized Energy', 'SNR'))
    # write in several formats
    datadir = os.path.join(base, 'data')
    fname = os.path.join(datadir, 'summary')
    data.write(fname + '.txt', format='ascii', overwrite=True)
    data.write(fname + '.csv', format='csv', overwrite=True)
    data.write(fname + '.tex', format='latex', overwrite=True)
Ejemplo n.º 2
0
def write_summary_table(blocks, correlated, base=os.path.curdir):
    """Write a summary table in various formats for users to download

    Parameters
    ----------
    blocks : `dict` of `OmegaChannel`
        the channel blocks scanned in the analysis

    correlated : `bool`
        Boolean switch to determine if cross-correlation is included

    base : `str`
        the path for the `<base>` tag to link in the `<head>`
    """
    # record summary data for each channel
    channel, time, freq, Q, energy, snr = ([], [], [], [], [], [])
    if correlated:
        corr, stdev, delay = ([], [], [])
    for block in blocks.values():
        for chan in block['channels']:
            channel.append(chan.name)
            time.append(chan.t)
            freq.append(chan.f)
            Q.append(chan.Q)
            energy.append(chan.energy)
            snr.append(chan.snr)
            if correlated:
                corr.append(chan.corr)
                stdev.append(chan.stdev)
                delay.append(chan.delay)
    # store in a table
    if correlated:
        data = Table([channel, time, freq, Q, energy, snr, corr, stdev, delay],
                     names=('Channel', 'Central Time',
                            'Central Frequency (Hz)', 'Q', 'Energy', 'SNR',
                            'Correlation', 'Standard Deviation', 'Delay (ms)'))
    else:
        data = Table([channel, time, freq, Q, energy, snr], names=(
            'Channel', 'Central Time', 'Central Frequency (Hz)', 'Q', 'Energy',
            'SNR'))
    # write in several formats
    datadir = os.path.join(base, 'data')
    fname = os.path.join(datadir, 'summary')
    data.write(fname + '.txt', format='ascii', overwrite=True)
    data.write(fname + '.csv', format='csv', overwrite=True)
    data.write(fname + '.tex', format='latex', overwrite=True)
Ejemplo n.º 3
0
def _load_channel_record(summary, use_checkpoint=True, correlate=True):
    """Load a previous Omega scan from its last saved checkpoint
    """
    if not (use_checkpoint and os.path.exists(summary)):
        return ([], [])
    LOGGER.debug('Checkpointing from {}'.format(os.path.abspath(summary)))
    record = Table.read(summary)
    if correlate and ('Standard Deviation' not in record.colnames):
        raise KeyError('Cross-correlation is not available from this record, '
                       'consider running without correlation or starting from '
                       'scratch with --disable-checkpoint')
    completed = list(record['Channel'])
    return (record, completed)
Ejemplo n.º 4
0
def write_summary_table(blocks, correlated, base=os.path.curdir):
    """Write a summary table in various formats for users to download

    Parameters
    ----------
    blocks : `dict` of `OmegaChannel`
        the channel blocks scanned in the analysis
    correlated : `bool`
        Boolean switch to determine if cross-correlation is included
    base : `str`
        the path for the `<base>` tag to link in the `<head>`
    """
    # record summary data for each channel
    channel, time, freq, Q, energy, snr = ([], [], [], [], [], [])
    if correlated:
        corr, delay = ([], [])
    for block in blocks.values():
        for chan in block['channels']:
            channel.append(chan.name)
            time.append(chan.t)
            freq.append(chan.f)
            Q.append(chan.Q)
            energy.append(chan.energy)
            snr.append(chan.snr)
            if correlated:
                corr.append(chan.corr)
                delay.append(chan.delay)
    # store in a table
    if correlated:
        data = Table([channel, time, freq, Q, energy, snr, corr, delay],
                     names=('Channel', 'Central Time',
                            'Central Frequency (Hz)', 'Q', 'Energy', 'SNR',
                            'Correlation', 'Delay (ms)'))
    else:
        data = Table([channel, time, freq, Q, energy, snr], names=(
            'Channel', 'Central Time', 'Central Frequency (Hz)', 'Q', 'Energy',
            'SNR'))
    # write in several formats
    datadir = os.path.join(base, 'data')
    fname = os.path.join(datadir, 'summary')
    data.write(fname + '.txt', format='ascii', overwrite=True)
    data.write(fname + '.csv', format='csv', overwrite=True)
    data.write(fname + '.tex', format='latex', overwrite=True)
Ejemplo n.º 5
0
always-plot = True
plot-time-durations = 4
channels = X1:TEST-STRAIN
"""
CONFIG_FILE = StringIO(CONFIGURATION)

CP = config.OmegaConfigParser(ifo='X1')
CP.read_file(CONFIG_FILE)
BLOCKS = CP.get_channel_blocks()
PRIMARY = BLOCKS['primary']
GW = BLOCKS['GW']

ROWS = [[0]] * 8
COLS = ('Q', 'Energy', 'SNR', 'Central Time', 'Central Frequency (Hz)',
        'Correlation', 'Standard Deviation', 'Delay (ms)')
TABLE = Table(ROWS, names=COLS)


# -- test utilities -----------------------------------------------------------

def test_get_default_configuration():
    cfile = config.get_default_configuration(ifo='X1', gpstime=1126259462)
    assert cfile == [os.path.expanduser(
        '~detchar/etc/omega/ER8/X-X1_R-selected.ini')]
    nfile = config.get_default_configuration(ifo='Network', gpstime=1187008882)
    assert nfile == [os.path.expanduser('~detchar/etc/omega/O2/Network.ini')]


def test_get_fancyplots():
    fp = config.get_fancyplots(
        channel='X1:TEST-STRAIN', plottype='test-plot', duration=4)
Ejemplo n.º 6
0
def xml_to_dataframe(prior_file, reference_frequency):
    table = Table.read(prior_file, format="ligolw", tablename="sim_inspiral")
    injection_values = {
        "mass_1": [],
        "mass_2": [],
        "luminosity_distance": [],
        "psi": [],
        "phase": [],
        "geocent_time": [],
        "ra": [],
        "dec": [],
        "theta_jn": [],
        "a_1": [],
        "a_2": [],
        "tilt_1": [],
        "tilt_2": [],
        "phi_12": [],
        "phi_jl": [],
    }
    for row in table:
        injection_values["mass_1"].append(float(row["mass1"]))
        injection_values["mass_2"].append(float(row["mass2"]))

        injection_values["luminosity_distance"].append(float(row["distance"]))
        injection_values["psi"].append(float(row["polarization"]))
        injection_values["phase"].append(float(row["coa_phase"]))
        injection_values["geocent_time"].append(float(row["geocent_end_time"]))
        injection_values["ra"].append(float(row["longitude"]))
        injection_values["dec"].append(float(row["latitude"]))

        args_list = [
            float(arg) for arg in [
                row["inclination"],
                row["spin1x"],
                row["spin1y"],
                row["spin1z"],
                row["spin2x"],
                row["spin2y"],
                row["spin2z"],
                row["mass1"],
                row["mass2"],
                reference_frequency,
                row["coa_phase"],
            ]
        ]
        (
            theta_jn,
            phi_jl,
            tilt_1,
            tilt_2,
            phi_12,
            a_1,
            a_2,
        ) = lalsim.SimInspiralTransformPrecessingWvf2PE(*args_list)
        injection_values["theta_jn"].append(theta_jn)
        injection_values["phi_jl"].append(phi_jl)
        injection_values["tilt_1"].append(tilt_1)
        injection_values["tilt_2"].append(tilt_2)
        injection_values["phi_12"].append(phi_12)
        injection_values["a_1"].append(a_1)
        injection_values["a_2"].append(a_2)

    injection_values = pd.DataFrame.from_dict(injection_values)
    return injection_values