Example #1
0
def get_found_param(injfile, bankfile, trigfile, param, ifo):
    """
    Translates some popular trigger parameters into functions that calculate
    them from an hdf found injection file

    Parameters
    ----------
    injfile: hdf5 File object
        Injection file of format known to ANitz (DOCUMENTME)
    bankfile: hdf5 File object or None
        Template bank file
    trigfile: hdf5 File object or None
        Single-detector trigger file
    param: string
        Parameter to be calculated for the recovered triggers
    ifo: string or None
        Standard ifo name, ex. 'L1'

    Returns
    -------
    [return value]: NumPy array of floats
        The calculated parameter values
    """
    foundtmp = injfile["found_after_vetoes/template_id"][:]
    if trigfile is not None:
        # get the name of the ifo in the injection file, eg "detector_1"
        # and the integer from that name
        ifolabel = [name for name, val in injfile.attrs.items() if \
                    "detector" in name and val == ifo][0]
        foundtrg = injfile["found_after_vetoes/trigger_id" + ifolabel[-1]]
    if bankfile is not None and param in bankfile.keys():
        return bankfile[param][:][foundtmp]
    elif trigfile is not None and param in trigfile[ifo].keys():
        return trigfile[ifo][param][:][foundtrg]
    else:
        b = bankfile
        found_param_dict = {
            "mtotal": (b['mass1'][:] + b['mass2'][:])[foundtmp],
            "mchirp":
            pnutils.mass1_mass2_to_mchirp_eta(b['mass1'][:],
                                              b['mass2'][:])[0][foundtmp],
            "eta":
            pnutils.mass1_mass2_to_mchirp_eta(b['mass1'][:],
                                              b['mass2'][:])[1][foundtmp],
            "effective_spin":
            pnutils.phenomb_chi(b['mass1'][:], b['mass2'][:], b['spin1z'][:],
                                b['spin2z'][:])[foundtmp]
        }

    return found_param_dict[param]
Example #2
0
def get_found_param(injfile, bankfile, trigfile, param, ifo):
    """
    Translates some popular trigger parameters into functions that calculate
    them from an hdf found injection file

    Parameters
    ----------
    injfile: hdf5 File object
        Injection file of format known to ANitz (DOCUMENTME)
    bankfile: hdf5 File object or None
        Template bank file
    trigfile: hdf5 File object or None
        Single-detector trigger file
    param: string
        Parameter to be calculated for the recovered triggers
    ifo: string or None
        Standard ifo name, ex. 'L1'

    Returns
    -------
    [return value]: NumPy array of floats
        The calculated parameter values
    """
    foundtmp = injfile["found_after_vetoes/template_id"][:]
    if trigfile is not None:
        # get the name of the ifo in the injection file, eg "detector_1"
        # and the integer from that name
        ifolabel = [name for name, val in injfile.attrs.items() if \
                    "detector" in name and val == ifo][0]
        foundtrg = injfile["found_after_vetoes/trigger_id" + ifolabel[-1]]
    if bankfile is not None and param in bankfile.keys():
        return bankfile[param][:][foundtmp]
    elif trigfile is not None and param in trigfile[ifo].keys():
        return trigfile[ifo][param][:][foundtrg]
    else:
        b = bankfile
        found_param_dict = {
          "mtotal" : (b['mass1'][:] + b['mass2'][:])[foundtmp],
          "mchirp" : pnutils.mass1_mass2_to_mchirp_eta(b['mass1'][:],
                     b['mass2'][:])[0][foundtmp],
          "eta"    : pnutils.mass1_mass2_to_mchirp_eta(b['mass1'][:],
                     b['mass2'][:])[1][foundtmp],
          "effective_spin" : pnutils.phenomb_chi(b['mass1'][:],
                                                 b['mass2'][:],
                                                 b['spin1z'][:],
                                                 b['spin2z'][:])[foundtmp]
        }

    return found_param_dict[param]
Example #3
0
def get_inj_param(injfile, param, ifo):
    """
    Translates some popular injection parameters into functions that calculate
    them from an hdf found injection file

    Parameters
    ----------
    injfile: hdf5 File object
        Injection file of format known to ANitz (DOCUMENTME)
    param: string
        Parameter to be calculated for the injected signals
    ifo: string
        Standard detector name, ex. 'L1'

    Returns
    -------
    [return value]: NumPy array of floats
        The calculated parameter values
    """
    det = pycbc.detector.Detector(ifo)
    time_delay = numpy.vectorize(#lambda dec, ra, t :
                                 det.time_delay_from_earth_center)#(dec, ra, t))

    inj = injfile["injections"]
    if param in inj.keys():
        return inj["injections/"+param]
    inj_param_dict = {
        "mtotal" : inj['mass1'][:] + inj['mass2'][:],
        "mchirp" : pnutils.mass1_mass2_to_mchirp_eta(inj['mass1'][:],
                                                     inj['mass2'][:])[0],
        "eta" : pnutils.mass1_mass2_to_mchirp_eta(inj['mass1'][:],
                                                  inj['mass2'][:])[1],
        "effective_spin" : pnutils.phenomb_chi(inj['mass1'][:],
                                               inj['mass2'][:],
                                               inj['spin1z'][:],
                                               inj['spin2z'][:]),
        "end_time_"+ifo[0].lower() :
            inj['end_time'][:] + time_delay(inj['longitude'][:],
                                            inj['latitude'][:],
                                            inj['end_time'][:]),
    }
    return inj_param_dict[param]
Example #4
0
def get_inj_param(injfile, param, ifo):
    """
    Translates some popular injection parameters into functions that calculate
    them from an hdf found injection file

    Parameters
    ----------
    injfile: hdf5 File object
        Injection file of format known to ANitz (DOCUMENTME)
    param: string
        Parameter to be calculated for the injected signals
    ifo: string
        Standard detector name, ex. 'L1'

    Returns
    -------
    [return value]: NumPy array of floats
        The calculated parameter values
    """
    det = pycbc.detector.Detector(ifo)
    time_delay = numpy.vectorize(  #lambda dec, ra, t :
        det.time_delay_from_earth_center)  #(dec, ra, t))

    inj = injfile["injections"]
    if param in inj.keys():
        return inj["injections/" + param]
    inj_param_dict = {
        "mtotal":
        inj['mass1'][:] + inj['mass2'][:],
        "mchirp":
        pnutils.mass1_mass2_to_mchirp_eta(inj['mass1'][:], inj['mass2'][:])[0],
        "eta":
        pnutils.mass1_mass2_to_mchirp_eta(inj['mass1'][:], inj['mass2'][:])[1],
        "effective_spin":
        pnutils.phenomb_chi(inj['mass1'][:], inj['mass2'][:], inj['spin1z'][:],
                            inj['spin2z'][:]),
        "end_time_" + ifo[0].lower():
        inj['end_time'][:] + time_delay(
            inj['longitude'][:], inj['latitude'][:], inj['end_time'][:]),
    }
    return inj_param_dict[param]
Example #5
0
 def effective_spin(self):
     # FIXME assumes aligned spins
     return pnutils.phenomb_chi(self.mass1, self.mass2, self.spin1z, self.spin2z)
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Match Calculation & plotting
#

print "Extracting and generating waveform"

mass = simulations.simulations[sim_number]['Mmin30Hz']

# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Common params

mass1, mass2 = pnutils.mtotal_eta_to_mass1_mass2(mass,
        simulations.simulations[sim_number]['eta'])

# Estimate ffinal 
chi = pnutils.phenomb_chi(mass1, mass2,
        simulations.simulations[sim_number]['spin1z'],simulations.simulations[sim_number]['spin2z'])
ffinal = pnutils.get_final_freq(approx, mass1, mass2, 
        simulations.simulations[sim_number]['spin1z'],simulations.simulations[sim_number]['spin2z'])
#upp_bound = ffinal
#upp_bound = 1.5*ffinal
upp_bound = 0.5/delta_t

# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# NUMERICAL RELATIVITY

# --- Generate the polarisations
hplus_NR, hcross_NR = nrbu.get_wf_pols(
       simulations.simulations[sim_number]['wavefile'], mass, inclination=inc,
       delta_t=delta_t, f_lower=30.0001, distance=distance)

Example #7
0
 def effective_spin(self):
     # FIXME assumes aligned spins
     return pnutils.phenomb_chi(self.mass1, self.mass2, self.spin1z,
                                self.spin2z)
    SeffdotL[s] = sim['SeffdotL']
    SeffcrossL[s] = sim['SeffcrossL']

    SdotL[s] = sim['theta_SdotL']
    theta_SdotL[s] = sim['theta_SdotL']


    for n in xrange(config.nsampls):

        chirp_masses[s,n] = masses[s,n] * sim['eta']**(3./5) 

    mass1, mass2 = \
            pnutils.mchirp_eta_to_mass1_mass2(np.median(chirp_masses[s,:]),
                    sim['eta'])
    chieff[s] = pnutils.phenomb_chi(mass1, mass2, sim['spin1z'],
            sim['spin2z'])

median_chirp_masses = np.median(chirp_masses, axis=1)
std_chirp_masses    = np.std(chirp_masses, axis=1)

matchsort = np.argsort(median_matches)
print "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
print "Summary for %s"%args[0]
print ""
print "   * Highest (median) Match: %f +/- %f"%(median_matches[matchsort][-1],
        std_matches[matchsort][-1])
print "   * Waveform: %s"%(
        simulations_goodmatch[matchsort][-1]['wavefile'].split('/')[-1])
print "   * mass ratio: %f"%(mass_ratios[matchsort][-1])
print "   * total mass: %f +/- %f"%(median_masses[matchsort][-1],
        std_masses[matchsort][-1])