コード例 #1
0
def PopulatePrototypeSignal(opts):
    approxSignal = lalsim.GetApproximantFromString(opts.approx)
    approxTemplate = approxSignal
    ampO = opts.amporder  # sets which modes to include in the physical signal
    Lmax = opts.Lmax  # sets which modes to include
    fref = opts.fref
    fminWavesSignal = opts.fmin_Template  # too long can be a memory and time hog, particularly at 16 kHz
    fminSNR = opts.fmin_SNR
    fSample = opts.srate

    Psig = None

    # Read in *coincidence* XML (overridden by injection, if present)
    if opts.coinc:
        xmldoc = utils.load_filename(opts.coinc)
        coinc_table = table.get_table(xmldoc,
                                      lsctables.CoincInspiralTable.tableName)
        assert len(coinc_table) == 1
        coinc_row = coinc_table[0]
        # Populate the SNR sequence and mass sequence
        sngl_inspiral_table = table.get_table(
            xmldoc, lsctables.SnglInspiralTable.tableName)
        m1, m2 = None, None
        for sngl_row in sngl_inspiral_table:
            # NOTE: gstlal is exact match, but other pipelines may not be
            assert m1 is None or (sngl_row.mass1 == m1
                                  and sngl_row.mass2 == m2)
            m1, m2 = sngl_row.mass1, sngl_row.mass2
        m1 = m1 * lal.MSUN_SI
        m2 = m2 * lal.MSUN_SI
        # Create a 'best recovered signal'
        Psig = lalsimutils.ChooseWaveformParams(
            m1=m1,
            m2=m2,
            approx=approxSignal,
            fmin=fminWavesSignal,
            dist=factored_likelihood.distMpcRef * 1e6 *
            lal.PC_SI,  # default distance
            fref=fref,
            ampO=ampO
        )  # FIXME: Parameter mapping from trigger space to search space

    # Read in *injection* XML
    if opts.inj:
        Psig = lalsimutils.xml_to_ChooseWaveformParams_array(str(opts.inj))[
            opts.event_id]  # Load in the physical parameters of the injection.
        Psig.deltaT = 1. / fSample  # needed if we will generate fake data from the injection xml *by this program, internally*
        timeWaveform = lalsimutils.estimateWaveformDuration(Psig)
        Psig.deltaF = 1. / lalsimutils.nextPow2(
            opts.seglen
        )  # Frequency binning needs to account for target segment length

    if not Psig and opts.channel_name:  # If data loaded but no signal generated
        if (not opts.template_mass1) or (not opts.template_mass2) or (
                not opts.force_gps_time):
            print(
                " CANCEL: Specifying parameters via m1, m2, and time on the command line "
            )
        Psig = lalsimutils.ChooseWaveformParams(
            approx=approxSignal,
            fmin=fminWavesSignal,
            dist=factored_likelihood.distMpcRef * 1e6 *
            lal.PC_SI,  # default distance
            fref=fref)
        Psig.m1 = lal.MSUN_SI * opts.template_mass1
        Psig.m2 = lal.MSUN_SI * opts.template_mass2
        Psig.tref = lal.LIGOTimeGPS(
            0.000000000)  # Initialize as GPSTime object
        Psig.tref += opts.force_gps_time  # Pass value of float into it

    if not (Psig):
        m1 = 4 * lal.MSUN_SI
        m2 = 3 * lal.MSUN_SI
        Psig = lalsimutils.ChooseWaveformParams(m1=m1,
                                                m2=m2,
                                                fmin=fminWavesSignal,
                                                fref=fref,
                                                approx=approxSignal,
                                                ampO=ampO)
    # Use forced parameters, if provided
    if opts.template_mass1:
        Psig.m1 = opts.template_mass1 * lal.LAL_MSUN_SI
    if opts.template_mass2:
        Psig.m2 = opts.template_mass2 * lal.LAL_MSUN_SI

    return Psig
コード例 #2
0
    event = opts.event_id
    xmldoc = utils.load_filename(filename,
                                 verbose=True,
                                 contenthandler=lalsimutils.cthdler)
    sim_inspiral_table = table.get_table(xmldoc,
                                         lsctables.SimInspiralTable.tableName)
    P.copy_sim_inspiral(sim_inspiral_table[int(event)])
    P.taper = lalsimutils.lsu_TAPER_START
    if opts.approx:
        P.approx = lalsim.GetApproximantFromString(str(opts.approx))
P.taper = lalsimutils.lsu_TAPER_START  # force taper
P.detector = opts.instrument
P.print_params()

T_est = lalsimutils.estimateWaveformDuration(P)
T_est = P.deltaT * lalsimutils.nextPow2(T_est / P.deltaT)
if T_est < opts.seglen:
    T_est = opts.seglen
P.deltaF = 1. / T_est
print(" Duration ", T_est)
if T_est < opts.seglen:
    print(" Buffer length too short, automating retuning forced ")

# Generate signal
hoft = lalsimutils.hoft(
    P
)  # include translation of source, but NOT interpolation onto regular time grid
# zero pad to be opts.seglen long, if necessary
if opts.seglen / hoft.deltaT > hoft.data.length:
    TDlenGoal = int(opts.seglen / hoft.deltaT)
    hoft = lal.ResizeREAL8TimeSeries(hoft, 0, TDlenGoal)
コード例 #3
0
            sys.exit(1)
print(" Event ", gwid)
base_dir = os.getcwd()
if opts.use_ini:
    base_dir =''  # all directories are provided as full path names


if opts.choose_data_LI_seglen:
    cmd_event = "gracedb_legacy download " + opts.gracedb_id + " coinc.xml"
    os.system(cmd_event)
    event_dict = retrieve_event_from_coinc("coinc.xml")
    P=lalsimutils.ChooseWaveformParams()
    P.m1 = event_dict["m1"]*lal.MSUN_SI; P.m2=event_dict["m2"]*lal.MSUN_SI; P.s1z = event_dict["s1z"]; P.s2z = event_dict["s2z"]
    P.fmin = opts.fmin  #  fmin we will use internally
    T_wave = lalsimutils.estimateWaveformDuration(P) +2  # 2 second buffer on end; note that with next power of 2, will go up to 4s
    T_wave_round = lalsimutils.nextPow2( T_wave)

    # For frequency-domain approximants, I need another factor of 2!
    # We have an extra buffer
    if lalsim.SimInspiralImplementedFDApproximants(P.approx)==1:
            print( " FD approximant, needs extra buffer for RIFT at present ")
            T_wave_round *=2 

    print( " Assigning auto-selected segment length ", T_wave_round)
    opts.data_LI_seglen  = T_wave_round

    # Problem with SEOBNRv3 starting frequencies
    mtot_msun = event_dict["m1"]+event_dict["m2"] 
    if ('SEOB' in opts.approx) and mtot_msun > 90*(20./opts.fmin):
            fmin_template = int(14*(90/mtot_msun))   # should also decrease this due to lmax!
            print( "  SEOB starting frequencies need to be reduced for this event; trying ", fmin_template)