本文整理汇总了Python中pycbc.pnutils.mass1_mass2_to_mchirp_eta函数的典型用法代码示例。如果您正苦于以下问题:Python mass1_mass2_to_mchirp_eta函数的具体用法?Python mass1_mass2_to_mchirp_eta怎么用?Python mass1_mass2_to_mchirp_eta使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了mass1_mass2_to_mchirp_eta函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: get_found_param
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]
开发者ID:cmbiwer,项目名称:pycbc,代码行数:49,代码来源:triggers.py
示例2: convert_to_sngl_inspiral_table
def convert_to_sngl_inspiral_table(params, proc_id):
"""
Convert a list of m1,m2,spin1z,spin2z values into a basic sngl_inspiral
table with mass and spin parameters populated and event IDs assigned
Parameters
-----------
params : iterable
Each entry in the params iterable should be a sequence of
[mass1, mass2, spin1z, spin2z] in that order
proc_id : ilwd char
Process ID to add to each row of the sngl_inspiral table
Returns
----------
SnglInspiralTable
Bank of templates in SnglInspiralTable format
"""
sngl_inspiral_table = lsctables.New(lsctables.SnglInspiralTable)
col_names = ["mass1", "mass2", "spin1z", "spin2z"]
for values in params:
tmplt = return_empty_sngl()
tmplt.process_id = proc_id
for colname, value in zip(col_names, values):
setattr(tmplt, colname, value)
tmplt.mtotal, tmplt.eta = pnutils.mass1_mass2_to_mtotal_eta(tmplt.mass1, tmplt.mass2)
tmplt.mchirp, junk = pnutils.mass1_mass2_to_mchirp_eta(tmplt.mass1, tmplt.mass2)
tmplt.template_duration = 0 # FIXME
tmplt.event_id = sngl_inspiral_table.get_next_id()
sngl_inspiral_table.append(tmplt)
return sngl_inspiral_table
开发者ID:vitale82,项目名称:pycbc,代码行数:34,代码来源:bank_output_utils.py
示例3: __init__
def __init__(self, filename, f_lower, sample_rate, minimum_buffer,
approximant=None, increment=8, parameters=None,
load_compressed=True, load_compressed_now=False,
**kwds):
self.increment = increment
self.f_lower = f_lower
self.filename = filename
self.sample_rate = sample_rate
self.minimum_buffer = minimum_buffer
super(LiveFilterBank, self).__init__(filename, approximant=approximant,
parameters=parameters, load_compressed=load_compressed,
load_compressed_now=load_compressed_now, **kwds)
if not hasattr(self.table, 'template_duration'):
self.table = self.table.add_fields(numpy.zeros(len(self.table),
dtype=numpy.float32), 'template_duration')
from pycbc.pnutils import mass1_mass2_to_mchirp_eta
self.table = sorted(self.table, key=lambda t: mass1_mass2_to_mchirp_eta(t.mass1, t.mass2)[0])
self.hash_lookup = {}
for i, p in enumerate(self.table):
hash_value = hash((p.mass1, p.mass2, p.spin1z, p.spin2z))
self.hash_lookup[hash_value] = i
开发者ID:gravity-waves,项目名称:pycbc,代码行数:26,代码来源:bank.py
示例4: get_param
def get_param(par, args, m1, m2, s1z, s2z):
"""
Helper function
Parameters
----------
par : string
Name of parameter to calculate
args : Namespace object returned from ArgumentParser instance
Calling code command line options, used for f_lower value
m1 : float or array of floats
First binary component mass (etc.)
Returns
-------
parvals : float or array of floats
Calculated parameter values
"""
if par == 'mchirp':
parvals, _ = pnutils.mass1_mass2_to_mchirp_eta(m1, m2)
elif par == 'mtotal':
parvals = m1 + m2
elif par == 'template_duration':
# default to SEOBNRv4 duration function
parvals = pnutils.get_imr_duration(m1, m2, s1z, s2z, args.f_lower,
args.approximant or "SEOBNRv4")
if args.min_duration:
parvals += args.min_duration
elif par in pnutils.named_frequency_cutoffs.keys():
parvals = pnutils.frequency_cutoff_from_name(par, m1, m2, s1z, s2z)
else:
# try asking for a LALSimulation frequency function
parvals = pnutils.get_freq(par, m1, m2, s1z, s2z)
return parvals
开发者ID:cmbiwer,项目名称:pycbc,代码行数:34,代码来源:trigger_fits.py
示例5: read_samples_from_walker
def read_samples_from_walker(self, variable_arg, nwalker,
thin_start=None, thin_interval=1):
""" Reads all samples from a specific walker for a parameter.
Parameters
-----------
variable_arg : str
Name of parameter to get independent samples.
nwalker : int
Index of the walker to get samples.
thin_start : int
Index of the sample to begin returning samples.
thin_interval : int
Interval to accept every i-th sample.
Returns
-------
numpy.array
Samples from a specific walker for a parameter.
"""
# default is to skip burn in samples
thin_start = self.attrs["burn_in_iterations"] if thin_start is None else thin_start
# derived parameter case for mchirp will calculate mchrip
# from mass1 and mass2
if variable_arg == "mchirp" and "mchirp" not in self.keys():
mass1 = self.read_samples_from_walker("mass1", nwalker,
thin_start=thin_start,
thin_interval=thin_interval)
mass2 = self.read_samples_from_walker("mass2", nwalker,
thin_start=thin_start,
thin_interval=thin_interval)
return pnutils.mass1_mass2_to_mchirp_eta(mass1, mass2)[0]
# derived parameter case for eta will calculate eta
# from mass1 and mass2
elif variable_arg == "eta" and "eta" not in self.keys():
mass1 = self.read_samples_from_walker("mass1", nwalker,
thin_start=thin_start,
thin_interval=thin_interval)
mass2 = self.read_samples_from_walker("mass2", nwalker,
thin_start=thin_start,
thin_interval=thin_interval)
return pnutils.mass1_mass2_to_mchirp_eta(mass1, mass2)[1]
return self[variable_arg]["walker%d"%nwalker][thin_start::thin_interval]
开发者ID:millsjc,项目名称:pycbc,代码行数:47,代码来源:inference_hdf.py
示例6: get_inj_param
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]
开发者ID:cmbiwer,项目名称:pycbc,代码行数:42,代码来源:triggers.py
示例7: __init__
def __init__(self, filename, f_lower, sample_rate, minimum_buffer,
approximant=None,
**kwds):
self.f_lower = f_lower
self.filename = filename
self.sample_rate = sample_rate
self.minimum_buffer = minimum_buffer
super(LiveFilterBank, self).__init__(filename, approximant=approximant, **kwds)
from pycbc.pnutils import mass1_mass2_to_mchirp_eta
self.table = sorted(self.table, key=lambda t: mass1_mass2_to_mchirp_eta(t.mass1, t.mass2)[0])
开发者ID:aravind-pazhayath,项目名称:pycbc,代码行数:13,代码来源:bank.py
示例8: __init__
def __init__(self, filename, f_lower, sample_rate, minimum_buffer,
approximant=None, increment=8,
**kwds):
self.increment = increment
self.f_lower = f_lower
self.filename = filename
self.sample_rate = sample_rate
self.minimum_buffer = minimum_buffer
super(LiveFilterBank, self).__init__(filename, approximant=approximant, **kwds)
from pycbc.pnutils import mass1_mass2_to_mchirp_eta
self.table = sorted(self.table, key=lambda t: mass1_mass2_to_mchirp_eta(t.mass1, t.mass2)[0])
self.hash_lookup = {}
for i, p in enumerate(self.table):
hash_value = hash((p.mass1, p.mass2, p.spin1z, p.spin2z))
self.hash_lookup[hash_value] = i
开发者ID:RorySmith,项目名称:pycbc,代码行数:19,代码来源:bank.py
示例9: _imrphenombfreq
def _imrphenombfreq(**p):
import lalinspiral
params = lalinspiral.InspiralTemplate()
m1 = p['mass1']
m2 = p['mass2']
mc, et = pnutils.mass1_mass2_to_mchirp_eta(m1, m2)
params.approximant = lalsimulation.IMRPhenomB
params.fLower = p['f_lower']
params.eta = et
params.distance = p['distance'] * lal.PC_SI * 1e6
params.mass1 = m1
params.mass2 = m2
params.spin1[2] = p['spin1z']
params.spin2[2] = p['spin2z']
params.startPhase = p['coa_phase']*2 - lal.PI
params.startTime = 0
params.tSampling = 8192
N = int(params.tSampling / p['delta_f'])
n = N / 2
# Create temporary memory to hold the results and call the generator
hpt = zeros(N, dtype=float32)
hct = zeros(N, dtype=float32)
hpt=hpt.lal()
hct=hct.lal()
lalinspiral.BBHPhenWaveBFreqDomTemplates(hpt, hct, params)
# Copy the results to a complex frequencyseries format
hctc = FrequencySeries(zeros(n, dtype=complex64), delta_f=p['delta_f'])
hptc = FrequencySeries(zeros(n, dtype=complex64), delta_f=p['delta_f'])
hptc.data += hpt.data[0:n]
hptc.data[1:n] += hpt.data[N:N-n:-1] * 1j
hctc.data += hct.data[0:n]
hctc.data[1:n] += hct.data[N:N-n:-1] * 1j
return hptc.astype(complex128), hctc.astype(complex128)
开发者ID:shasvath,项目名称:pycbc,代码行数:40,代码来源:waveform.py
示例10: to_coinc_xml_object
def to_coinc_xml_object(self, file_name):
# FIXME: This function will only work with two ifos!!
outdoc = ligolw.Document()
outdoc.appendChild(ligolw.LIGO_LW())
ifos = [ifo for ifo in self.sngl_files.keys()]
proc_id = ligolw_process.register_to_xmldoc(outdoc, 'pycbc',
{}, ifos=ifos, comment='', version=pycbc_version.git_hash,
cvs_repository='pycbc/'+pycbc_version.git_branch,
cvs_entry_time=pycbc_version.date).process_id
search_summ_table = lsctables.New(lsctables.SearchSummaryTable)
coinc_h5file = self.coinc_file.h5file
start_time = coinc_h5file['segments']['coinc']['start'][:].min()
end_time = coinc_h5file['segments']['coinc']['end'][:].max()
num_trigs = len(self.sort_arr)
search_summary = return_search_summary(start_time, end_time,
num_trigs, ifos)
search_summ_table.append(search_summary)
outdoc.childNodes[0].appendChild(search_summ_table)
sngl_inspiral_table = lsctables.New(lsctables.SnglInspiralTable)
coinc_def_table = lsctables.New(lsctables.CoincDefTable)
coinc_event_table = lsctables.New(lsctables.CoincTable)
coinc_inspiral_table = lsctables.New(lsctables.CoincInspiralTable)
coinc_event_map_table = lsctables.New(lsctables.CoincMapTable)
time_slide_table = lsctables.New(lsctables.TimeSlideTable)
# Set up time_slide table
time_slide_id = lsctables.TimeSlideID(0)
for ifo in ifos:
time_slide_row = lsctables.TimeSlide()
time_slide_row.instrument = ifo
time_slide_row.time_slide_id = time_slide_id
time_slide_row.offset = 0
time_slide_row.process_id = proc_id
time_slide_table.append(time_slide_row)
# Set up coinc_definer table
coinc_def_id = lsctables.CoincDefID(0)
coinc_def_row = lsctables.CoincDef()
coinc_def_row.search = "inspiral"
coinc_def_row.description = "sngl_inspiral<-->sngl_inspiral coincidences"
coinc_def_row.coinc_def_id = coinc_def_id
coinc_def_row.search_coinc_type = 0
coinc_def_table.append(coinc_def_row)
bank_col_names = ['mass1', 'mass2', 'spin1z', 'spin2z']
bank_col_vals = {}
for name in bank_col_names:
bank_col_vals[name] = self.get_bankfile_array(name)
coinc_event_names = ['ifar', 'time1', 'fap', 'stat']
coinc_event_vals = {}
for name in coinc_event_names:
coinc_event_vals[name] = self.get_coincfile_array(name)
sngl_col_names = ['snr', 'chisq', 'chisq_dof', 'bank_chisq',
'bank_chisq_dof', 'cont_chisq', 'cont_chisq_dof',
'end_time', 'template_duration', 'coa_phase',
'sigmasq']
sngl_col_vals = {}
for name in sngl_col_names:
sngl_col_vals[name] = self.get_snglfile_array_dict(name)
for idx in xrange(len(self.sort_arr)):
# Set up IDs and mapping values
coinc_id = lsctables.CoincID(idx)
# Set up sngls
# FIXME: As two-ifo is hardcoded loop over all ifos
sngl_combined_mchirp = 0
sngl_combined_mtot = 0
for ifo in ifos:
sngl_id = self.trig_id[ifo][idx]
event_id = lsctables.SnglInspiralID(sngl_id)
sngl = return_empty_sngl()
sngl.event_id = event_id
sngl.ifo = ifo
for name in sngl_col_names:
val = sngl_col_vals[name][ifo][idx]
if name == 'end_time':
sngl.set_end(LIGOTimeGPS(val))
else:
setattr(sngl, name, val)
for name in bank_col_names:
val = bank_col_vals[name][idx]
setattr(sngl, name, val)
sngl.mtotal, sngl.eta = pnutils.mass1_mass2_to_mtotal_eta(
sngl.mass1, sngl.mass2)
sngl.mchirp, _ = pnutils.mass1_mass2_to_mchirp_eta(
sngl.mass1, sngl.mass2)
sngl.eff_distance = (sngl.sigmasq)**0.5 / sngl.snr
sngl_combined_mchirp += sngl.mchirp
sngl_combined_mtot += sngl.mtotal
sngl_inspiral_table.append(sngl)
# Set up coinc_map entry
#.........这里部分代码省略.........
开发者ID:aburony1970,项目名称:pycbc,代码行数:101,代码来源:hdf.py
示例11: test_get_random_mass
#.........这里部分代码省略.........
# Okay, not possible from eta
pass
elif max_chirp_mass > self.max_chirp_mass:
# Okay, not possible from chirp mass
pass
else:
err_msg = "Maximum total mass changed unexpectedly."
self.fail(err_msg)
massRangeParams = pycbc.tmpltbank.massRangeParameters(\
self.min_mass1,\
self.max_mass1, self.min_mass2, self.max_mass2,\
maxNSSpinMag=self.max_ns_spin_mag,\
maxBHSpinMag=self.max_bh_spin_mag,\
maxTotMass=self.max_total_mass,\
minTotMass=self.min_total_mass,\
max_chirp_mass=self.max_chirp_mass,\
min_chirp_mass=self.min_chirp_mass,\
maxEta=self.max_eta,\
minEta=self.min_eta,\
ns_bh_boundary_mass=self.ns_bh_boundary_mass)
# And again with the nsbh flag
massRangeParams2 = pycbc.tmpltbank.massRangeParameters(\
self.min_mass1,\
self.max_mass1, self.min_mass2, self.max_mass2,\
maxNSSpinMag=self.max_ns_spin_mag,\
maxBHSpinMag=self.max_bh_spin_mag,\
maxTotMass=self.max_total_mass,\
minTotMass=self.min_total_mass,\
max_chirp_mass=self.max_chirp_mass,\
min_chirp_mass=self.min_chirp_mass,\
maxEta=self.max_eta,\
minEta=self.min_eta,\
nsbhFlag=True)
mass,eta,beta,sigma,gamma,spin1z,spin2z = \
pycbc.tmpltbank.get_random_mass(100000, massRangeParams)
errMsg = "pycbc.tmpltbank.get_random_mass returns invalid ranges."
if (mass < self.min_total_mass).any():
idx = mass.argmin()
diff = (mass*mass * (1-4*eta))**0.5
mass1 = (mass + diff)/2.
mass2 = (mass - diff)/2.
self.assertTrue(not (mass < self.min_total_mass).any(),msg=errMsg)
self.assertTrue(not (mass > self.max_total_mass).any(),msg=errMsg)
# Get individual masses
diff = (mass*mass * (1-4*eta))**0.5
mass1 = (mass + diff)/2.
mass2 = (mass - diff)/2.
self.assertTrue(not (mass1 > self.max_mass1 * 1.001).any(),
msg=errMsg)
self.assertTrue(not (mass1 < self.min_mass1 * 0.999).any(),
msg=errMsg)
self.assertTrue(not (mass2 > self.max_mass2 * 1.001).any(),
msg=errMsg)
self.assertTrue(not (mass2 < self.min_mass2 * 0.999).any(),
msg=errMsg)
self.assertTrue(not (mass1 < mass2).any(),msg=errMsg)
# Chirp mass and eta
mchirp, eta = pnutils.mass1_mass2_to_mchirp_eta(mass1,mass2)
if self.max_chirp_mass:
self.assertTrue(not (mchirp > self.max_chirp_mass*1.0001).any(),
msg=errMsg)
if self.min_chirp_mass:
self.assertTrue(not (mchirp < self.min_chirp_mass*0.9999).any(),
msg=errMsg)
if self.min_eta:
self.assertTrue(not (eta < self.min_eta*0.9999).any(),
msg=errMsg)
self.assertTrue(not (eta > self.max_eta*1.0001).any(),
msg=errMsg)
nsSpin1 = spin1z[mass1 < self.ns_bh_boundary_mass]
nsSpin2 = spin2z[mass2 < self.ns_bh_boundary_mass]
bhSpin1 = spin1z[mass1 > self.ns_bh_boundary_mass]
bhSpin2 = spin2z[mass2 > self.ns_bh_boundary_mass]
self.assertTrue(not (abs(nsSpin1) > 0.5).any(), msg=errMsg)
self.assertTrue(not (abs(nsSpin2) > 0.5).any(), msg=errMsg)
self.assertTrue(not (abs(bhSpin1) > 0.9).any(), msg=errMsg)
self.assertTrue(not (abs(bhSpin2) > 0.9).any(), msg=errMsg)
# Check that *some* spins are bigger than 0.5
if len(bhSpin1):
self.assertTrue((abs(bhSpin1) > 0.5).any(), msg=errMsg)
if len(bhSpin2):
self.assertTrue((abs(bhSpin2) > 0.5).any(), msg=errMsg)
# This can be used to test the boundaries are all applied visually
# FIXME: This would need to be updated for all of the mass limits
#pylab.plot(mass1, mass2, 'b.')
#pylab.plot([3.0,5.0],[3.0,1.0],'r-')
#pylab.plot([1.7216566400945545,1.9921146662296347,3.4433132801891091,4.01175560949798],[1.1477710933963694,1.0066274466204264,2.2955421867927388,1.002938902374495],'mx')
#pylab.ylim([0.8,3.0])
#pylab.xlim([1.5,5.0])
#pylab.savefig("masses_%d.png" %(idx,))
# Check nsbh flag
mass,eta,beta,sigma,gamma,spin1z,spin2z = \
pycbc.tmpltbank.get_random_mass(100000, massRangeParams2)
self.assertTrue(not (abs(spin1z) > 0.9).any(), msg=errMsg)
self.assertTrue(not (abs(spin2z) > 0.5).any(), msg=errMsg)
self.assertTrue((abs(spin1z) > 0.5).any(), msg=errMsg)
开发者ID:RorySmith,项目名称:pycbc,代码行数:101,代码来源:test_tmpltbank.py
示例12: eta
def eta(self):
mchirp, eta = pnutils.mass1_mass2_to_mchirp_eta(self.mass1, self.mass2)
return eta
开发者ID:andrew-lundgren,项目名称:pycbc,代码行数:3,代码来源:hdf.py
示例13: __init__
def __init__(self, ifos, coinc_results):
"""Initialize a ligolw xml representation of a zerolag trigger
for upload from pycbc live to gracedb.
Parameters
----------
ifos: list of strs
A list of the ifos pariticipating in this trigger
coinc_results: dict of values
A dictionary of values. The format is define
in pycbc/events/coinc.py
and matches the on disk representation in the hdf file for this time.
"""
# remember if this should be marked as HWINJ
self.is_hardware_injection = False
if 'HWINJ' in coinc_results:
self.is_hardware_injection = True
# Set up the bare structure of the xml document
outdoc = ligolw.Document()
outdoc.appendChild(ligolw.LIGO_LW())
proc_id = ligolw_process.register_to_xmldoc(
outdoc, 'pycbc',
{}, ifos=ifos, comment='', version=pycbc_version.git_hash,
cvs_repository='pycbc/'+pycbc_version.git_branch,
cvs_entry_time=pycbc_version.date).process_id
# Set up coinc_definer table
coinc_def_table = lsctables.New(lsctables.CoincDefTable)
coinc_def_id = lsctables.CoincDefID(0)
coinc_def_row = lsctables.CoincDef()
coinc_def_row.search = "inspiral"
coinc_def_row.description = "sngl_inspiral<-->sngl_inspiral coincs"
coinc_def_row.coinc_def_id = coinc_def_id
coinc_def_row.search_coinc_type = 0
coinc_def_table.append(coinc_def_row)
outdoc.childNodes[0].appendChild(coinc_def_table)
# Set up coinc inspiral and coinc event tables
coinc_id = lsctables.CoincID(0)
coinc_event_table = lsctables.New(lsctables.CoincTable)
coinc_event_row = lsctables.Coinc()
coinc_event_row.coinc_def_id = coinc_def_id
coinc_event_row.nevents = len(ifos)
coinc_event_row.instruments = ','.join(ifos)
coinc_event_row.time_slide_id = lsctables.TimeSlideID(0)
coinc_event_row.process_id = proc_id
coinc_event_row.coinc_event_id = coinc_id
coinc_event_row.likelihood = 0.
coinc_event_table.append(coinc_event_row)
outdoc.childNodes[0].appendChild(coinc_event_table)
# Set up sngls
sngl_inspiral_table = lsctables.New(lsctables.SnglInspiralTable)
coinc_event_map_table = lsctables.New(lsctables.CoincMapTable)
sngl_id = 0
for ifo in ifos:
names = [n.split('/')[-1] for n in coinc_results
if 'foreground/%s' % ifo in n]
sngl_id += 1
sngl = return_empty_sngl()
sngl.event_id = lsctables.SnglInspiralID(sngl_id)
sngl.ifo = ifo
for name in names:
val = coinc_results['foreground/%s/%s' % (ifo, name)]
if name == 'end_time':
sngl.set_end(LIGOTimeGPS(val))
else:
try:
setattr(sngl, name, val)
except AttributeError:
pass
sngl.mtotal, sngl.eta = pnutils.mass1_mass2_to_mtotal_eta(
sngl.mass1, sngl.mass2)
sngl.mchirp, _ = pnutils.mass1_mass2_to_mchirp_eta(
sngl.mass1, sngl.mass2)
sngl.eff_distance = (sngl.sigmasq)**0.5 / sngl.snr
sngl_inspiral_table.append(sngl)
# Set up coinc_map entry
coinc_map_row = lsctables.CoincMap()
coinc_map_row.table_name = 'sngl_inspiral'
coinc_map_row.coinc_event_id = coinc_id
coinc_map_row.event_id = sngl.event_id
coinc_event_map_table.append(coinc_map_row)
outdoc.childNodes[0].appendChild(coinc_event_map_table)
outdoc.childNodes[0].appendChild(sngl_inspiral_table)
# Set up the coinc inspiral table
coinc_inspiral_table = lsctables.New(lsctables.CoincInspiralTable)
coinc_inspiral_row = lsctables.CoincInspiral()
# This seems to be used as FAP, which should not be in gracedb
coinc_inspiral_row.false_alarm_rate = 0
coinc_inspiral_row.minimum_duration = 0.
coinc_inspiral_row.set_ifos(ifos)
coinc_inspiral_row.coinc_event_id = coinc_id
coinc_inspiral_row.mchirp = sngl.mchirp
#.........这里部分代码省略.........
开发者ID:prayush,项目名称:pycbc,代码行数:101,代码来源:live.py
示例14: __init__
#.........这里部分代码省略.........
cvs_repository='pycbc/'+pycbc_version.git_branch,
cvs_entry_time=pycbc_version.date).process_id
# Set up coinc_definer table
coinc_def_table = lsctables.New(lsctables.CoincDefTable)
coinc_def_id = lsctables.CoincDefID(0)
coinc_def_row = lsctables.CoincDef()
coinc_def_row.search = "inspiral"
coinc_def_row.description = "sngl_inspiral<-->sngl_inspiral coincs"
coinc_def_row.coinc_def_id = coinc_def_id
coinc_def_row.search_coinc_type = 0
coinc_def_table.append(coinc_def_row)
outdoc.childNodes[0].appendChild(coinc_def_table)
# Set up coinc inspiral and coinc event tables
coinc_id = lsctables.CoincID(0)
coinc_event_table = lsctables.New(lsctables.CoincTable)
coinc_event_row = lsctables.Coinc()
coinc_event_row.coinc_def_id = coinc_def_id
coinc_event_row.nevents = len(usable_ifos)
coinc_event_row.instruments = ','.join(usable_ifos)
coinc_event_row.time_slide_id = lsctables.TimeSlideID(0)
coinc_event_row.process_id = proc_id
coinc_event_row.coinc_event_id = coinc_id
coinc_event_row.likelihood = 0.
coinc_event_table.append(coinc_event_row)
outdoc.childNodes[0].appendChild(coinc_event_table)
# Set up sngls
sngl_inspiral_table = lsctables.New(lsctables.SnglInspiralTable)
coinc_event_map_table = lsctables.New(lsctables.CoincMapTable)
sngl_populated = None
for sngl_id, ifo in enumerate(usable_ifos):
sngl = return_empty_sngl(nones=True)
sngl.event_id = lsctables.SnglInspiralID(sngl_id)
sngl.process_id = proc_id
sngl.ifo = ifo
names = [n.split('/')[-1] for n in coinc_results
if 'foreground/%s' % ifo in n]
for name in names:
val = coinc_results['foreground/%s/%s' % (ifo, name)]
if name == 'end_time':
sngl.set_end(lal.LIGOTimeGPS(val))
else:
try:
setattr(sngl, name, val)
except AttributeError:
pass
if sngl.mass1 and sngl.mass2:
sngl.mtotal, sngl.eta = pnutils.mass1_mass2_to_mtotal_eta(
sngl.mass1, sngl.mass2)
sngl.mchirp, _ = pnutils.mass1_mass2_to_mchirp_eta(
sngl.mass1, sngl.mass2)
sngl_populated = sngl
if sngl.snr:
sngl.eff_distance = (sngl.sigmasq)**0.5 / sngl.snr
sngl_inspiral_table.append(sngl)
# Set up coinc_map entry
coinc_map_row = lsctables.CoincMap()
coinc_map_row.table_name = 'sngl_inspiral'
coinc_map_row.coinc_event_id = coinc_id
coinc_map_row.event_id = sngl.event_id
coinc_event_map_table.append(coinc_map_row)
if self.upload_snr_series:
snr_series_to_xml(self.snr_series[ifo], outdoc, sngl.event_id)
# for subthreshold detectors, respect BAYESTAR's assumptions and checks
bayestar_check_fields = ('mass1 mass2 mtotal mchirp eta spin1x '
'spin1y spin1z spin2x spin2y spin2z').split()
for sngl in sngl_inspiral_table:
if sngl.ifo in followup_ifos:
for bcf in bayestar_check_fields:
setattr(sngl, bcf, getattr(sngl_populated, bcf))
sngl.set_end(lal.LIGOTimeGPS(subthreshold_sngl_time))
outdoc.childNodes[0].appendChild(coinc_event_map_table)
outdoc.childNodes[0].appendChild(sngl_inspiral_table)
# Set up the coinc inspiral table
coinc_inspiral_table = lsctables.New(lsctables.CoincInspiralTable)
coinc_inspiral_row = lsctables.CoincInspiral()
# This seems to be used as FAP, which should not be in gracedb
coinc_inspiral_row.false_alarm_rate = 0
coinc_inspiral_row.minimum_duration = 0.
coinc_inspiral_row.set_ifos(usable_ifos)
coinc_inspiral_row.coinc_event_id = coinc_id
coinc_inspiral_row.mchirp = sngl_populated.mchirp
coinc_inspiral_row.mass = sngl_populated.mtotal
coinc_inspiral_row.end_time = sngl_populated.end_time
coinc_inspiral_row.end_time_ns = sngl_populated.end_time_ns
coinc_inspiral_row.snr = coinc_results['foreground/stat']
far = 1.0 / (lal.YRJUL_SI * coinc_results['foreground/ifar'])
coinc_inspiral_row.combined_far = far
coinc_inspiral_table.append(coinc_inspiral_row)
outdoc.childNodes[0].appendChild(coinc_inspiral_table)
self.outdoc = outdoc
self.time = sngl_populated.get_end()
开发者ID:a-r-williamson,项目名称:pycbc,代码行数:101,代码来源:live.py
示例15: get_td_waveform_resp
def get_td_waveform_resp(params):
"""
Generate time domain data of gw detector response
This function will produce data of a gw detector response based on a
numerical relativity waveform.
Parameters
----------
params: object
The fields of this object correspond to the kwargs of the
`pycbc.waveform.get_td_waveform()` method and the positional
arguments of `pycbc.detector.Detector.antenna_pattern()`. For the later
the fields should be supplied as `params.ra`, `.dec`, `.polarization`
and `.geocentric_end_time`
Returns
-------
h_plus: pycbc.Types.TimeSeries
h_cross: pycbc.Types.TimeSeries
pats: dictionary
Dictionary containing 'H1' and 'L1' keys. Each key maps to an object
of containing the field `.f_plus` and `.f_cross` corresponding to
the plus and cross antenna patterns for the two ifos 'H1' and 'L1'.
"""
# # construct waveform string that can be parsed by lalsimulation
waveform_string = params.approximant
if not pn_orders[params.order] == -1:
waveform_string += params.order
name, phase_order = legacy_approximant_name(waveform_string)
# Populate additional fields of params object
params.mchirp, params.eta = pnutils.mass1_mass2_to_mchirp_eta(
params.mass1, params.mass2)
params.waveform = waveform_string
params.approximant = name
params.phase_order = phase_order
# generate waveform
h_plus, h_cross = get_td_waveform(params)
# Generate antenna patterns for all ifos
pats = {}
for ifo in params.instruments:
# get Detector instance for IFO
det = Detector(ifo)
# get antenna pattern
f_plus, f_cross = det.antenna_pattern(
params.ra,
params.dec,
params.polarization,
params.geocentric_end_time)
# Populate antenna patterns with new pattern
pat = type('AntennaPattern', (object,), {})
pat.f_plus = f_plus
pat.f_cross = f_cross
pats[ifo] = pat
return h_plus, h_cross, pats
开发者ID:Cyberface,项目名称:nrutils_dev,代码行数:63,代码来源:hackh5_utils.py
示例16: __init__
#.........这里部分代码省略.........
coinc_event_row.instruments = ','.join(usable_ifos)
coinc_event_row.time_slide_id = lsctables.TimeSlideID(0)
coinc_event_row.process_id = proc_id
coinc_event_row.coinc_event_id = coinc_id
coinc_event_row.likelihood = 0.
coinc_event_table.append(coinc_event_row)
outdoc.childNodes[0].appendChild(coinc_event_table)
# Set up sngls
sngl_inspiral_table = lsctables.New(lsctables.SnglInspiralTable)
coinc_event_map_table = lsctables.New(lsctables.CoincMapTable)
sngl_populated = None
network_snrsq = 0
for sngl_id, ifo in enumerate(usable_ifos):
sngl = return_empty_sngl(nones=True)
sngl.event_id = lsctables.SnglInspiralID(sngl_id)
sngl.process_id = proc_id
sngl.ifo = ifo
names = [n.split('/')[-1] for n in coinc_results
if 'foreground/%s' % ifo in n]
for name in names:
val = coinc_results['foreground/%s/%s' % (ifo, name)]
if name == 'end_time':
sngl.set_end(lal.LIGOTimeGPS(val))
else:
try:
setattr(sngl, name, val)
except AttributeError:
pass
if sngl.mass1 and sngl.mass2:
sngl.mtotal, sngl.eta = pnutils.mass1_mass2_to_mtotal_eta(
sngl.mass1, sngl.mass2)
sngl.mchirp, _ = pnutils.mass1_mass2_to_mchirp_eta(
sngl.mass1, sngl.mass2)
sngl_populated = sngl
if sngl.snr:
sngl.eff_distance = (sngl.sigmasq)**0.5 / sngl.snr
network_snrsq += sngl.snr ** 2.0
if 'channel_names' in kwargs and ifo in kwargs['channel_names']:
sngl.channel = kwargs['channel_names'][ifo]
sngl_inspiral_table.append(sngl)
# Set up coinc_map entry
coinc_map_row = lsctables.CoincMap()
coinc_map_row.table_name = 'sngl_inspiral'
coinc_map_row.coinc_event_id = coinc_id
coinc_map_row.event_id = sngl.event_id
coinc_event_map_table.append(coinc_map_row)
if self.snr_series is not None:
snr_series_to_xml(self.snr_series[ifo], outdoc, sngl.event_id)
# for subthreshold detectors, respect BAYESTAR's assumptions and checks
bayestar_check_fields = ('mass1 mass2 mtotal mchirp eta spin1x '
'spin1y spin1z spin2x spin2y spin2z').split()
subthreshold_sngl_time = numpy.mean(
[coinc_results['foreground/{}/end_time'.format(ifo)]
for ifo in ifos])
for sngl in sngl_inspiral_table:
if sngl.ifo in followup_ifos:
for bcf in bayestar_check_fields:
setattr(sngl, bcf, getattr(sngl_populated, bcf))
sngl.set_end(lal.LIGOTimeGPS(subthreshold_sngl_time))
outdoc.childNodes[0].appendChild(coinc_event_map_table)
开发者ID:tdent,项目名称:pycbc,代码行数:67,代码来源:live.py
示例17: to_coinc_xml_object
#.........这里部分代码省略.........
bank_col_names = ["mass1", "mass2", "spin1z", "spin2z"]
bank_col_vals = {}
for name in bank_col_names:
bank_col_vals[name] = self.get_bankfile_array(name)
coinc_event_names = ["ifar", "time1", "fap", "stat"]
coinc_event_vals = {}
for name in coinc_event_names:
coinc_event_vals[name] = self.get_coincfile_array(name)
sngl_col_names = [
"snr",
"chisq",
"chisq_dof",
"bank_chisq",
"bank_chisq_dof",
"cont_chisq",
"cont_chisq_dof",
"end_time",
"template_duration",
"coa_phase",
"sigmasq",
]
sngl_col_vals = {}
for name in sngl_col_names:
sngl_col_vals[name] = self.get_snglfile_array_dict(name)
for idx, coinc_idx in enumerate(self.sort_arr):
# Set up IDs and mapping values
curr_tmplt_id = self.template_id[idx]
coinc_id = lsctables.CoincID(idx)
# Set up sngls
# FIXME: As two-ifo is hardcoded loop over all ifos
sngl_combined_mchirp = 0
sngl_combined_mtot = 0
for ifo in ifos:
sngl_id = self.trig_id[ifo][idx]
event_id = lsctables.SnglInspiralID(sngl_id)
sngl = return_empty_sngl()
sngl.event_id = event_id
sngl.ifo = ifo
curr_sngl_file = self.sngl_files[ifo].h5file[ifo]
for name in sngl_col_names:
val = sngl_col_vals[name][ifo][idx]
setattr(sngl, name, val)
for name in bank_col_names:
val = bank_col_vals[name][idx]
setattr(sngl, name, val)
sngl.mtotal, sngl.eta = pnutils.mass1_mass2_to_mtotal_eta(sngl.mass1, sngl.mass2)
sngl.mchirp, junk = pnutils.mass1_mass2_to_mchirp_eta(sngl.mass1, sngl.mass2)
sngl.eff_distance = (sngl.sigmasq) ** 0.5 / sngl.snr
sngl_combined_mchirp += sngl.mchirp
sngl_combined_mtot += sngl.mtotal
sngl_inspiral_table.append(sngl)
# Set up coinc_map entry
coinc_map_row = lsctables.CoincMap()
coinc_map_row.table_name = "sngl_inspiral"
coinc_map_row.coinc_event_id = coinc_id
coinc_map_row.event_id = event_id
coinc_event_map_table.append(coinc_map_row)
sngl_combined_mchirp = sngl_combined_mchirp / len(ifos)
sngl_combined_mtot = sngl_combined_mtot / len(ifos)
# Set up coinc inspiral and coinc event tables
coinc_event_row = lsctables.Coinc()
|
请发表评论