m1, m2, ovrlp = odata["mass1"], odata["mass2"], odata["overlaps"]
    if opts.verbose:
        print "Using overlap data from %s" % wfrm_fam

# Hopefully the point is already present and we can just get it, otherwise it
# could incur an overlap calculation, or suffer from the effects of being close
# only in Euclidean terms

intr_prms, expand_prms = parse_param(opts.intrinsic_param)
pin_prms, _ = parse_param(opts.pin_param)
intr_pt = numpy.array([intr_prms[k] for k in intr_prms])
# This keeps the list of parameters consistent across runs
intr_prms = sorted(intr_prms.keys())

# Transform and repack initial point
intr_pt = amrlib.apply_transform(intr_pt[numpy.newaxis,:], intr_prms, opts.distance_coordinates)[0]
intr_pt = dict(zip(intr_prms, intr_pt))

#
# Step 1: retrieve templates / result
#
xmldoc = utils.load_filename(opts.tmplt_bank, contenthandler=ligolw.LIGOLWContentHandler)
tmplt_bank = lsctables.SnglInspiralTable.get_table(xmldoc)

#
# Step 2: Set up metric space
#

if ovrlp.shape[1] != len(tmplt_bank):
    pts = numpy.array([odata[a] for a in intr_prms]).T
else:
예제 #2
0
wtype = "%s_%s" % (args.approximant1, args.approximant2)
toc = {"types": {wtype: []}}
bdir = "%s/" % wtype
if not os.path.exists(bdir):
    os.mkdir(bdir)

# FIXME: This code should probably be libized
# FIXME: Unhardcode
intr_prms = ("mass1", "mass2", "spin1z", "spin2z")
pts = numpy.array([tuple(getattr(t, a) for a in intr_prms) for t in tmplt_bank])

# Dump full m1/m2 bank to JSON
with open("bank.json", "w") as fout:
    json.dump([list(a) + ["%s/%s_%d.json" % (bdir, wtype, i)] for i, a in enumerate(pts)], fout)

pts = amrlib.apply_transform(pts, intr_prms, args.distance_coordinates)

#
# Construct objects needed to identify neighbors and do overlaps
#
tree = BallTree(pts)

ovrlp = lalsimutils.Overlap(fLow=f_low, fMax=2000, deltaF=delta_f, psd=psd, analyticPSD_Q=False)

idx_range = range(args.tmplt_start_index or 0, args.tmplt_end_index or len(tmplt_bank))

# FIXME:
npts = len(tmplt_bank)
import h5py
h5file = h5py.File("test.hdf", "w")
olapdata = h5file.create_group(wtype)
pyplot.subplot(2,2,1)
pyplot.grid(True, color='0.5', linewidth=0.125, linestyle='-')
pyplot.scatter(m1, m2, c=chi, s=1, edgecolor='none', cmap=cm.gist_earth)
if args.template_id:
    pyplot.scatter([m1_in], [m2_in], s=5, marker='x', color='m')
pyplot.xlabel("mass 1 ($M_{\odot}$)")
pyplot.ylabel("mass 2 ($M_{\odot}$)")
pyplot.xlim(0.95 * m1.min(), 1.05 * m1.max())
pyplot.ylim(0.95 * m2.min(), 1.05 * m2.max())
pyplot.locator_params(nbins=4)
pyplot.gca().set_axisbelow(True)

#
# Transform to mchirp / eta
#
mc, eta = amrlib.apply_transform(numpy.array((m1, m2)).T, ("mass1", "mass2"), "mchirp_eta").T

pyplot.subplot(2,2,2)
pyplot.grid(True, color='0.5', linewidth=0.125, linestyle='-')
pyplot.scatter(mc, eta, c=chi, s=1, edgecolor='none', cmap=cm.gist_earth)
#pyplot.scatter(mc, eta, s=1, edgecolor='none', cmap=cm.gist_earth)
if args.template_id:
    mc_in, eta_in = amrlib.apply_transform(numpy.array(([m1_in], [m2_in])).T, ("mass1", "mass2"), "mchirp_eta").T
    pyplot.scatter([mc_in], [eta_in], s=5, marker='x', color='m')
pyplot.xlabel("$\mathcal{M}_c$ ($M_{\odot}$)")
pyplot.ylabel("$\eta$")
pyplot.xlim(0.95 * mc.min(), 1.05 * mc.max())
pyplot.ylim(0.95 * eta.min(), 1.05 * eta.max())
pyplot.locator_params(nbins=4)
pyplot.gca().set_axisbelow(True)
    m1, m2, ovrlp = odata["mass1"], odata["mass2"], odata["overlaps"]
    if opts.verbose:
        print "Using overlap data from %s" % wfrm_fam

# Hopefully the point is already present and we can just get it, otherwise it
# could incur an overlap calculation, or suffer from the effects of being close
# only in Euclidean terms

intr_prms, expand_prms = common_cl.parse_param(opts.intrinsic_param)
pin_prms, _ = common_cl.parse_param(opts.pin_param)
intr_pt = numpy.array([intr_prms[k] for k in sorted(intr_prms)])
# This keeps the list of parameters consistent across runs
intr_prms = sorted(intr_prms.keys())

# Transform and repack initial point
intr_pt = amrlib.apply_transform(intr_pt[numpy.newaxis, :], intr_prms,
                                 opts.distance_coordinates)[0]
intr_pt = dict(zip(intr_prms, intr_pt))

#
# Step 1: retrieve templates / result
#
xmldoc = utils.load_filename(opts.tmplt_bank,
                             contenthandler=ligolw.LIGOLWContentHandler)
tmplt_bank = lsctables.SnglInspiralTable.get_table(xmldoc)

#
# Step 2: Set up metric space
#

if ovrlp.shape[1] != len(tmplt_bank):
    pts = numpy.array([odata[a] for a in intr_prms]).T
예제 #5
0
    os.mkdir(bdir)

# FIXME: This code should probably be libized
# FIXME: Unhardcode
intr_prms = ("mass1", "mass2", "spin1z", "spin2z")
pts = numpy.array(
    [tuple(getattr(t, a) for a in intr_prms) for t in tmplt_bank])

# Dump full m1/m2 bank to JSON
with open("bank.json", "w") as fout:
    json.dump([
        list(a) + ["%s/%s_%d.json" % (bdir, wtype, i)]
        for i, a in enumerate(pts)
    ], fout)

pts = amrlib.apply_transform(pts, intr_prms, args.distance_coordinates)

#
# Construct objects needed to identify neighbors and do overlaps
#
tree = BallTree(pts)

ovrlp = lalsimutils.Overlap(fLow=f_low,
                            fMax=2000,
                            deltaF=delta_f,
                            psd=psd,
                            analyticPSD_Q=False)

idx_range = range(args.tmplt_start_index or 0, args.tmplt_end_index
                  or len(tmplt_bank))