27The KNOwn Pulsar pipelinE - lalpulsar_knope_result_page
29Script from creating results pages for pulsars from the known pulsar search
32from __future__
import print_function, division
35from configparser
import ConfigParser
46from scipy
import stats
57from lalinference
import git_version
59__author__ =
"Matthew Pitkin <matthew.pitkin@ligo.org>"
60__version__ =
"git id %s" % git_version.id
61__date__ = git_version.date
65 from scotchcorner
import scotchcorner
68 "Could no import scotchcorner: make sure scotchcorner is installed (e.g. 'pip install scotchcorner') and in the PYTHONPATH",
79 <meta http-equiv="Content-Type" content=
"text/html; charset=utf-8"/>
80 <meta name=
"description" content=
"PSR {psrname}"/>
81 <meta charset=
"UTF-8">
83 <title>{title}</title>
85 <link rel=
"stylesheet" type=
"text/css" href=
"{cssfile}"/>
91<!- add
in javascript to allow text toggling -->
92<script language=
"javascript">
94 var ele = document.getElementById(id);
95 if(ele.style.display ==
"block"){{
96 ele.style.display =
"none";
99 ele.style.display =
"block";
106<!-- Links to the parts of the page -->
107<div
class=
"pagelinks">
111<!-- table of pulsar parameters
from EM data -->
115<div
class=
"pulsartable" id=
"pulsartable">
121<!-- table of derived gravitational wave upper limits, SNRs
and evidence ratios -->
122<div
class=
"limitstable" id=
"limitstable">
131<!-- plots of 1D
and 2D marginalised posteriors
for GW amplitude
and phase parameters -->
132<div
class=
"selectedposteriors" id=
"selectedposteriors">
138<!-- corner plot of all parameters (hidden by default) -->
139<div
class=
"jointposteriors" id=
"jointposteriors">
145<!-- (
if background runs have been produced):
if running a multi-detector analysis the plot
146 coherent vs. incoherent Bayes factors (
with SNR giving colour of points) of background
147 and foreground,
or if single detector plot signal vs. noise Bayes factor against SNR. -->
148<div
class=
"evidenceplots" id=
"evidenceplots">
154<!-- plots of pre-processed data (heterodyned/spectrally interpolated time series) -->
155<div
class=
"dataplots" id=
"dataplots">
161<!-- plots of the posterior samples
for all parameters -->
162<div
class=
"posteriorsamples" id=
"posteriorsamples">
168<!-- table of posterior statistics: means, max. likelihoods, confidence intervals -->
169<div
class=
"posteriorstats" id=
"posteriorstats">
185def set_spin_down(p1_I, assoc, f0, f1, n=5.0):
187 Set the spin-down of the source based on the intrinsic period derivative (p1_I) corrected for any proper motion/
188 globular cluster acceleration
if available,
or if not give AND the pulsar
is in a globular cluster base the
189 spin-down on assuming an age of 10^9 years (defaulting to the source being a gravitar,
with n=5).
190 Otherwise just
return the unadjusted spin-down.
193 if p1_I !=
None and p1_I > 0.0:
197 return -f0 / ((n - 1.0) * 1.0e9 * 365.25 * 86400.0)
206 Create a html table of some information from the pulsar parameter file.
228 for param
in paramdisplist:
232 dispfunc = paramhtmldispfunc.__dict__[param]
233 table.adddata(paramhtmldict[param])
234 table.adddata(dispfunc(
str(pa)))
236 return table.tabletext
241 self, datafiles, outputdir, figformats=["png"], asdtime=86400, harmonics=[2.0]
244 Initialise with a dictionary keyed
in detector names containing paths to the equivalent pre-processed
245 data
file(s)
for that detector (
if harmonics contains more than one frequency harmonic this there should
246 be a list of files,
with one
for each harmonic
and given
in the same order
as the harmonics lists).
247 figformats gives a list of the output figure formats (defaulting to .png),
and asd time
is the time to use
248 for each FFT when creating the spectrograms/ASDs, which defaults to 86400 seconds (1 day).
252 "h2",
"Analysis statistics", newline=
True
255 if not isinstance(harmonics, list):
260 self.
_ifos = list(datafiles.keys())
265 for i, ifo
in enumerate(datafiles):
266 if isinstance(datafiles[ifo], list):
269 "Error... number of pre-processed data files is not the same as the number of harmonics.",
278 for j, df
in enumerate(datafiles[ifo]):
279 if not os.path.isfile(df):
281 "Error... pre-processed data file '%s' for '%s' does not exist."
292 if not os.path.isfile(df):
294 "Error... pre-processed data file '%s' for '%s' does not exist."
302 "Error... number of pre-processed data files is not the same as the number of harmonics.",
310 "Error... output path '%s' for data plots does not exist"
317 if "png" not in figformats:
319 "Error... must include 'png' in the output figure formats",
364 harmtext =
"_%d" %
int(h)
367 for i, ifo
in enumerate(self.
_ifos):
368 self.
_asds[h][ifo] = asdlist[
373 for fig, fignameprefix
in zip(
374 [Bkfigs[i], fscanfigs[i], asdfigs[i]], [
"Bk",
"fscan",
"ASD"]
377 figname = os.path.join(
378 outdir,
"%s_%s%s.%s" % (fignameprefix, ifo, harmtext, ftype)
384 "Error... problem creating figure '%s'." % figname,
390 self.
_Bkplots[h][ifo] = os.path.join(
391 outdir,
"Bk_%s%s.%s" % (ifo, harmtext, ftype)
394 outdir,
"ASD_%s%s.%s" % (ifo, harmtext, ftype)
397 outdir,
"fscan_%s%s.%s" % (ifo, harmtext, ftype)
422 for i, ifo
in enumerate(self.
_ifos):
430 "Error... could not load file '%s'."
437 self.
_ends[ifo] = bkd[-1, 0]
438 dt = np.min(np.diff(bkd[:, 0]))
448 table.adddata(
" ")
449 table.adddata(ifo, dataclass=ifo)
458 table.adddata(item[0])
459 table.adddata(item[1])
461 return table.tabletext
466 for ifo
in self.
_ifos:
470 table.adddata(
"Data for %df" %
int(h), colspan=2, header=
True)
477 os.path.basename(self.
_Bkplots[h][ifo]),
478 '<img class="dataplot" src="{}"/>'.
format(
479 os.path.basename(self.
_Bkplots[h][ifo])
482 table.adddata(plotlink)
485 os.path.basename(self.
_asdplots[h][ifo]),
486 '<img class="asdplot" src="{}"/>'.
format(
490 table.adddata(plotlink)
493 '<img class="dataplot" src="{}"/>'.
format(
497 table.adddata(plotlink)
507 Get sample posteriors and created a set of functions
for outputting tables, plots
and posterior statistics
516 modeltype="waveform",
521 subtracttruths=False,
525 Initialise with a dictionary keyed
in detector names containing paths to the equivalent posterior samples
526 file
for that detector.
531 "Error... output path '%s' for data plots does not exist"
538 self.
_ifos = list(postfiles.keys())
540 if isinstance(ifos, list):
545 for ifo
in self.
_ifos:
546 if ifo
not in postfiles:
548 "Error... posterior files for detector '%s' not given" % ifo,
591 "Error... cannot read injection parameter file '%s'."
624 if "Joint" in self.
_ifos:
635 "Error... cannot read prior file '%s'." % self.
_priorfile,
640 for line
in pf.readlines():
641 priorlinevals = line.split()
642 if len(priorlinevals) < 4:
644 "Error... there must be at least four values on each line of the prior file '%s'."
650 if priorlinevals[1]
not in [
658 "Error... the prior for '%s' must be either 'uniform', 'loguniform', 'gmm', 'fermidirac', or 'gaussian'."
664 if priorlinevals[1]
in [
670 if len(priorlinevals) != 4:
672 "Error... there must be four values on each line of the prior file '%s'."
678 [
float(priorlinevals[2]),
float(priorlinevals[3])]
682 self.
_usegwphase and priorlinevals[0].lower() ==
"phi0"
684 ranges = 2.0 * ranges
685 elif priorlinevals[1] ==
"gmm":
688 ranges[
"nmodes"] = priorlinevals[2]
689 ranges[
"means"] = ast.literal_eval(priorlinevals[3])
690 ranges[
"covs"] = ast.literal_eval(
693 ranges[
"weights"] = ast.literal_eval(
698 p.lower()
for p
in priorlinevals[0].split(
":")
700 npars = len(splitpars)
701 for lims
in priorlinevals[6:-1]:
702 plims.append(np.array(ast.literal_eval(lims)))
703 ranges[
"limits"] = plims
704 ranges[
"npars"] = npars
706 phi0idx = splitpars.index(
"phi0")
708 for ci
in range(ranges[
"nmodes"]):
709 ranges[
"means"][ci][phi0idx] = (
710 2.0 * ranges[
"means"][ci][phi0idx]
715 ranges[
"covs"][ci][phi0idx][ck] = (
716 2.0 * ranges[
"covs"][ci][phi0idx][ck]
718 ranges[
"covs"][ci][ck][phi0idx] = (
719 2.0 * ranges[
"covs"][ci][ck][phi0idx]
721 ranges[
"limits"][phi0idx] = 2.0 * ranges[
"limits"][phi0idx]
722 for sidx, spar
in enumerate(splitpars):
723 ranges[
"pindex"] = sidx
733 for ifo
in postfiles:
734 if not os.path.isfile(postfiles[ifo]):
736 "Error... posterior samples file '%s' for '%s' does not exist."
737 % (postfiles[ifo], ifo),
746 self.
_Bsn[ifo] = sigev - noiseev
749 for param
in pos.names:
752 for testpar
in [
"logl",
"logw",
"logprior"]:
753 if testpar
in param.lower():
757 theseparams.append(param)
762 for param
in theseparams:
765 "Error... parameter '%s' is not defined in posteriors samples for '%s'."
772 if modeltype ==
"source":
775 if "phi0" in pos.names:
776 phi0samples = pos[
"phi0"].samples
777 if "psi" in pos.names:
778 psisamples = pos[
"psi"].samples
781 if psisamples
is not None:
782 for i
in range(len(psisamples)):
784 np.floor(psisamples[i] / (np.pi / 2.0))
786 psisamples[i] = np.mod(psisamples[i], np.pi / 2.0)
787 if phi0samples
is not None:
788 phi0samples[i] += nrots * (np.pi / 2.0)
794 if phi0samples
is not None:
795 phi0samples = np.mod(phi0samples, np.pi)
803 if "phi0" in pos.names:
811 if "c22" in pos.names
and self.
_modeltype ==
"waveform":
826 if "phi22" in pos.names
and modeltype ==
"waveform":
828 "phi0", 0.5 * pos[
"phi22"].samples
851 if "phi21" in pos.names:
853 "phi22", 2.0 * pos[
"phi21"].samples
897 if ifo
in self.
_h0ul:
898 return self.
_h0ul[ifo]
912 return self.
_q22[ifo]
919 return self.
_C21[ifo]
926 return self.
_C22[ifo]
933 return self.
_I21[ifo]
940 return self.
_I31[ifo]
953 for ifo
in self.
_ifos:
962 snrfiles = [sf
for sf
in os.listdir(pdir)
if "SNR" in sf]
963 if len(snrfiles) < 1:
964 print(
"Error... no SNR files are given for '%s'" % ifo, file=sys.stderr)
972 fp = open(os.path.join(pdir, snrfile),
"r")
973 lines = [line.strip()
for line
in fp.readlines()]
975 if "# Recovered SNR" not in lines:
977 "Error... no recovered SNRs are given in the SNR file '%s'."
984 linevals = lines[-1].split()
985 snr +=
float(linevals[-1])
986 return snr / len(snrfiles)
988 def _get_bayes_factors(self):
992 for ifo
in self.
_ifos:
1008 list(i)
for i
in itertools.product([
"s",
"n"], repeat=nifos)
1010 incoherentcombs = -np.inf
1014 if comb.count(
"n") != len(
1018 for i, cval
in enumerate(comb):
1019 combsum += ifosn[i][cval]
1020 incoherentcombs = np.logaddexp(incoherentcombs, combsum)
1021 if comb.count(
"s") == len(comb):
1022 incoherentsig = combsum
1025 if len(self.
_ifos) > 2
and "Joint" in self.
_ifos:
1034 fe = os.path.splitext(postfile)[-1].lower()
1035 if fe ==
".h5" or fe ==
".hdf":
1037 f = h5py.File(postfile,
"r")
1038 a = f[
"lalinference"][
"lalinference_nest"]
1040 a.attrs[
"log_bayes_factor"],
1041 a.attrs[
"log_evidence"],
1042 a.attrs[
"log_noise_evidence"],
1043 a.attrs[
"log_max_likelihood"],
1047 B = np.loadtxt(postfile.replace(
".gz",
"") +
"_B.txt")
1048 evdata = tuple(B.tolist())
1051 "Error... could not extract evidences from '%s'." % postfile,
1073 credintervals=[0.9],
1084 if ifo !=
None and ifo
in self.
_ifos:
1087 plotifos = self.
_ifos
1090 if "Joint" in plotifos:
1091 j = plotifos.pop(plotifos.index(
"Joint"))
1092 plotifos.insert(0, j)
1103 if len(parameters) < 2
or len(parameters) > len(self.
_parameters):
1105 "Error... can only plot posterior distributions for more than one parameters",
1111 for param
in parameters:
1114 "Error... the requested parameter '%s' is not recognised" % param,
1127 if truths
is not None:
1128 if isinstance(truths, list):
1130 if len(truths) != len(parameters):
1132 "Error... number of true values must be the same as number of parameters.",
1138 for ifo
in plotifos:
1139 newtruths[ifo] = truths
1144 for ifo
in plotifos:
1145 if ifo
not in truths:
1147 "Error... problem in truths values. Detector '%s' not recognised."
1153 if len(truths[ifo]) != len(parameters):
1155 "Error... number of true values must be the same as number of parameters.",
1161 for ifo
in plotifos:
1165 subtract_truths = []
1183 if parameters[0]
not in amppars:
1184 subtract_truths.append(0)
1187 x = self.
_posteriors[plotifos[0]][parameters[0]].samples
1189 if parameters[0].upper()
in paramlatexdict:
1190 labels.append(paramlatexdict[parameters[0].upper()])
1192 labels.append(parameters[0])
1193 for param
in parameters[1:]:
1194 x = np.hstack((x, self.
_posteriors[plotifos[0]][param].samples))
1195 if param.upper()
in paramlatexdict:
1196 labels.append(paramlatexdict[param.upper()])
1198 labels.append(param)
1200 if param
not in amppars:
1201 subtract_truths.append(parameters.index(param))
1203 if len(subtract_truths) == 0:
1204 subtract_truths =
None
1207 if plotifos[0] ==
"Joint":
1209 "histtype":
"stepfilled",
1210 "color":
"darkslategrey",
1211 "edgecolor": coldict[
"Joint"],
1214 contourops = {
"colors": coldict[plotifos[0]]}
1216 if whichtruth ==
"Joint" or whichtruth ==
"all":
1217 truthops = {
"color":
"black",
"markeredgewidth": 2}
1220 showpoints = jointsamples
1223 contourops = {
"colors":
"dark" + coldict[plotifos[0]]}
1225 if len(plotifos) == 1:
1227 "histtype":
"stepfilled",
1228 "color": coldict[plotifos[0]],
1229 "edgecolor": coldict[plotifos[0]],
1232 truthops = {
"color":
"black",
"markeredgewidth": 2}
1236 "color": coldict[plotifos[0]],
1237 "edgecolor": coldict[plotifos[0]],
1240 if whichtruth == plotifos[0]:
1241 truthops = {
"color":
"black",
"markeredgewidth": 2}
1242 elif whichtruth ==
"all":
1244 "color":
"dark" + coldict[plotifos[0]],
1245 "markeredgewidth": 2,
1255 truths=truths[plotifos[0]],
1256 datatitle=plotifos[0],
1258 hist_kwargs=histops,
1259 showcontours=showcontours,
1260 contour_levels=credintervals,
1261 contour_kwargs=contourops,
1262 truths_kwargs=truthops,
1263 contour_limits=contourlimits,
1265 show_level_labels=
False,
1266 showpoints=showpoints,
1267 scatter_kwargs=scatter_kwargs,
1268 subtract_truths=subtract_truths,
1272 if len(plotifos) > 1:
1273 for k, ifo
in enumerate(plotifos[1:]):
1276 "color": coldict[ifo],
1277 "edgecolor": coldict[ifo],
1281 for param
in parameters[1:]:
1282 x = np.hstack((x, self.
_posteriors[ifo][param].samples))
1284 contourops = {
"colors":
"dark" + coldict[plotifos[k + 1]]}
1285 if whichtruth == plotifos[k + 1]:
1286 truthops = {
"color":
"black",
"markeredgewidth": 2}
1287 elif whichtruth ==
"all":
1289 "color":
"dark" + coldict[plotifos[k + 1]],
1290 "markeredgewidth": 2,
1296 hist_kwargs=histops,
1299 showcontours=showcontours,
1300 contour_kwargs=contourops,
1301 contour_levels=credintervals,
1302 show_level_labels=
False,
1303 truths_kwargs=truthops,
1304 scatter_kwargs=scatter_kwargs,
1305 contour_limits=contourlimits,
1312 if priorparam.lower()
in parameters:
1314 thisax = sc.get_axis(labels[parameters.index(priorparam.lower())])
1320 and priorparam.lower()
not in amppars
1322 atruth = truths[plotifos[0]][
1323 parameters.index(priorparam.lower())
1327 vertaxrange = sc.histvert[-1].get_ylim()
1328 yl = thisax.get_ylim()
1330 yl[0] == vertaxrange[0]
and yl[1] == vertaxrange[1]
1337 orientation=
"vertical",
1345 orientation=
"horizontal",
1349 if "png" not in figformats
and "svg" not in figformats:
1351 "Error... must include 'png' and/or 'svg' in the output figure formats",
1356 if filename ==
None:
1358 outfilepre = os.path.join(self.
_outputdir,
"all_posteriors")
1360 outfilepre = os.path.join(self.
_outputdir,
"vs".join(parameters))
1362 outfilepre = os.path.join(self.
_outputdir, filename)
1365 for ftype
in figformats:
1366 outfile = outfilepre +
"." + ftype
1368 sc.fig.subplots_adjust(
1369 left=0.18, bottom=0.18
1374 "Error... could not output posterior plot file '%s'." % outfile,
1378 outfiles.append(outfile)
1383 self, ax, param, prior, orientation="horizontal", truth=0.0, npoints=100
1386 priortype = list(prior[param].keys())[0]
1387 priorrange = list(prior[param].values())[0]
1392 if orientation ==
"horizontal":
1393 valrange = np.linspace(ax.get_xlim()[0], ax.get_xlim()[1], npoints)
1394 elif orientation ==
"vertical":
1395 valrange = np.linspace(ax.get_ylim()[0], ax.get_ylim()[1], npoints)
1398 "Error... axis orientation not recognised. Must be 'horizontal' or 'vertical'.",
1404 if priortype ==
"uniform":
1405 vals = stats.uniform.pdf(
1406 valrange, priorrange[0] - truth, priorrange[1] - priorrange[0]
1408 elif priortype ==
"gaussian":
1410 if param.lower() ==
"psi":
1411 priorrange[0] = np.mod(priorrange[0], np.pi / 2.0)
1412 if param.lower() ==
"phi0":
1414 priorrange[0] = np.mod(priorrange[0], 2.0 * pi)
1416 priorrange[0] = np.mod(priorrange[0], pi)
1418 vals = stats.norm.pdf(valrange, priorrange[0] - truth, priorrange[1])
1420 priortype ==
"fermidirac"
1422 sigma = priorrange[0]
1426 (sigma * np.log(1.0 + np.exp(r)))
1427 * (np.exp((valrange - mu) / sigma) + 1.0)
1429 elif priortype ==
"loguniform":
1430 vals = np.zeros(len(valrange))
1431 indices = (valrange >= priorrange[0]) & (valrange <= priorrange[1])
1432 vals[indices] = 1.0 / (
1433 valrange[indices] * np.log(priorrange[1] / priorrange[0])
1435 elif priortype ==
"gmm":
1436 vals = np.zeros(len(valrange))
1437 nmodes = priorrange[
"nmodes"]
1438 pindex = priorrange[
"pindex"]
1439 mmeans = np.array([mm[pindex]
for mm
in priorrange[
"means"]])
1440 mcovs = priorrange[
"covs"]
1443 mstddevs.append(np.sqrt(cov[pindex][pindex]))
1444 mweights = priorrange[
"weights"]
1448 plims = priorrange[
"limits"][pindex]
1449 if np.isfinite(plims[0]):
1451 if np.isfinite(plims[1]):
1453 indices = (valrange >= bmin) & (valrange <= bmax)
1456 if param.lower() ==
"psi":
1457 mmeans = np.mod(mmeans, np.pi / 2.0)
1458 if param.lower() ==
"phi0":
1460 mmeans = np.mod(mmeans, 2.0 * pi)
1462 mmeans = np.mod(mmeans, pi)
1465 for i
in range(nmodes):
1466 vals[indices] += mweights[i] * stats.norm.pdf(
1467 valrange[indices], mmeans[i] - truth, mstddevs[i]
1470 vals = vals / np.trapz(vals, valrange)
1473 "Error... prior type '%s' not recognised." % priortype, file=sys.stderr
1478 if orientation ==
"horizontal":
1480 valrange, vals, linestyle=
"--", color=
"lightslategray", linewidth=1.5
1482 if orientation ==
"vertical":
1484 vals, valrange, linestyle=
"--", color=
"lightslategray", linewidth=1.5
1490 header =
htmltag(
"h2", title, newline=
True)
1502 for ifo
in self.
_ifos:
1508 limits[param] = (0.0,
None)
1510 elif param ==
"cosiota":
1511 limits[param] = (-1.0, 1.0)
1512 elif param ==
"phi0":
1514 limits[param] = (0.0, 2.0 * np.pi)
1516 limits[param] = (0.0, np.pi)
1517 elif param ==
"psi":
1519 limits[param] = (0.0, np.pi)
1521 limits[param] = (0.0, np.pi / 2.0)
1522 elif param ==
"c21" or param ==
"c22":
1527 for ifo
in self.
_ifos:
1533 limits[param] = (0.0,
None)
1535 elif param ==
"lambda":
1536 limits[param] = (0.0, np.pi)
1537 elif param ==
"costheta":
1538 limits[param] = (0.0, 1.0)
1546 if harmonics[0] == 2.0:
1548 paramlist = [[
"h0",
"cosiota"], [
"phi0",
"psi"]]
1552 "Error... do not know 'source' parameterisation for emission at purely the rotation frequency",
1558 paramlist = [[
"c21",
"cosiota"], [
"phi21",
"psi"]]
1564 [
"i31",
"cosiota",
"phi0"],
1565 [
"psi",
"lambda",
"costheta"],
1570 [
"i21",
"i31",
"cosiota"],
1571 [
"phi0",
"psi",
"lambda",
"costheta"],
1575 paramlist = [[
"c21",
"c22",
"cosiota"], [
"psi",
"phi21",
"phi22"]]
1578 for parampairs
in paramlist:
1581 for p
in parampairs:
1585 contourlimits.append(limits[p])
1586 figlimits.append(limits[p])
1594 figlimits=figlimits,
1595 contourlimits=contourlimits,
1599 tagclass =
"jointplot"
1601 tagclass =
"posplot"
1604 os.path.basename(pf[0]),
1605 '<img class="{}" src="{}"/>'.
format(
1606 tagclass, os.path.basename(pf[0])
1611 return header.text + table.tabletext
1615 if "png" not in figformats:
1617 "Error... must include 'png' in the output figure formats",
1623 "h2",
"Posterior samples", newline=
True
1633 chainfile = os.path.join(self.
_outputdir, param +
"_postchain")
1635 for ftype
in figformats:
1636 thischainfile = chainfile +
"." + ftype
1638 chainfig.savefig(thischainfile)
1641 "Error... could not output posterior samples plot for '%s'."
1651 os.path.basename(thischainfile),
1652 '<img class="chainplot" src="{}"/>'.
format(
1653 os.path.basename(thischainfile)
1665 if ci >= 100.0
or ci <= 0.0:
1667 "Error... credible interval '%s' is outside the range between 0%% and 100%%."
1673 header =
htmltag(
"h2",
"Posterior statistics", newline=
True)
1677 cols = [
"Detector",
"max. poterior",
"mean",
"median",
"σ"]
1679 cols.append(
"%d%% credible interval" %
int(ci))
1681 cols.insert(0,
"Inj. value")
1682 cols.insert(0,
" ")
1687 table.adddata(col, header=
True)
1697 if pu
in paramhtmldict:
1698 pdisp = paramhtmldict[pu]
1701 if pu
in [
"RA",
"DEC",
"RAJ",
"DECJ"]:
1706 dispkwargs = {
"dp": 2}
1711 if pu
in paramhtmldispfunc.__dict__:
1712 dispfunc = paramhtmldispfunc.__dict__[pu]
1714 dispfunc = paramhtmldispfunc.__dict__[
"DEFAULTSTR"]
1716 for j, ifo
in enumerate(self.
_ifos):
1719 table.adddata(pdisp, rowspan=len(self.
_ifos))
1727 rowspan=len(self.
_ifos),
1731 "*", rowspan=len(self.
_ifos)
1741 table.adddata(ifo, dataclass=ifo)
1743 dispfunc(
str(maxLparams[param]), **dispkwargs)
1749 dispfunc(
str(self.
_posteriors[ifo].medians[param]), **dispkwargs)
1751 tdispkwargs = dispkwargs
1752 if param.upper()
in [
"T0",
"TASC"]:
1753 tdispkwargs = {
"stype":
"diff"}
1755 dispfunc(
str(self.
_posteriors[ifo].stdevs[param]), **tdispkwargs)
1758 for k, ci
in enumerate(credints):
1771 dispfunc(
str(low), **dispkwargs),
1772 dispfunc(
str(high), **dispkwargs),
1797 table.adddata(
" ", header=
True)
1800 table.adddata(paramhtmldict[
"H0UL"].
format(ul), header=
True)
1801 table.adddata(paramhtmldict[
"ELL"], header=
True)
1802 table.adddata(paramhtmldict[
"Q22"], header=
True)
1803 table.adddata(paramhtmldict[
"SDRAT"], header=
True)
1809 table.adddata(paramhtmldict[
"C21UL"].
format(ul), header=
True)
1811 table.adddata(paramhtmldict[
"C21UL"].
format(ul), header=
True)
1812 table.adddata(paramhtmldict[
"C22UL"].
format(ul), header=
True)
1814 paramhtmldict[
"H0UL"].
format(ul) +
" (from C<sub>22</sub>)", header=
True
1816 table.adddata(paramhtmldict[
"ELL"] +
" (from C<sub>22</sub>)", header=
True)
1817 table.adddata(paramhtmldict[
"Q22"] +
" (from C<sub>22</sub>)", header=
True)
1818 table.adddata(
"ratio", header=
True)
1820 if not self._biaixal:
1822 paramhtmldict[
"I21UL"].
format(ul), header=
True
1824 table.adddata(paramhtmldict[
"I31UL"].
format(ul), header=
True)
1827 "Error... do not know how to output results table for this situation.",
1833 table.adddata(paramhtmldict[
"SNR"], header=
True)
1836 table.adddata(paramhtmldict[
"MAXL"], header=
True)
1839 table.adddata(paramhtmldict[
"BSN"], header=
True)
1842 if len(self.
_ifos) > 2
and "Joint" in self.
_ifos:
1843 table.adddata(paramhtmldict[
"BCI"], header=
True)
1844 table.adddata(paramhtmldict[
"BCIN"], header=
True)
1846 for ifo
in self.
_ifos:
1848 table.adddata(
"{}".
format(ifo), dataclass=ifo)
1851 for p
in [
"c21",
"c22"]:
1853 self.
_posteriors[ifo][p].samples, upperlimit=(ul / 100.0)
1857 self.
_C21[ifo] = Cul
1859 self.
_C22[ifo] = Cul
1872 self.
_posteriors[ifo][
"h0"].samples, upperlimit=(ul / 100.0)
1874 self.
_h0ul[ifo] = h0ul
1880 table.adddata(
"*", dataclass=ifo)
1883 self.
_h0ul[ifo], freq, dist
1891 self.
_q22[ifo] =
None
1892 table.adddata(
"*", dataclass=ifo)
1900 table.adddata(
"*", dataclass=ifo)
1903 table.adddata(
"%.02f" % self.
_sdratio[ifo], dataclass=ifo)
1908 self.
_posteriors[ifo][
"I21"].samples, upperlimit=(ul / 100.0)
1913 self.
_posteriors[ifo][
"I31"].samples, upperlimit=(ul / 100.0)
1919 table.adddata(
"%.1f" % self.
_optimal_snrs[ifo], dataclass=ifo)
1921 table.adddata(
"*", dataclass=ifo)
1925 "%.f" % (self.
_maxL[ifo] / np.log(10.0)), dataclass=ifo
1928 "%.1f" % (self.
_Bsn[ifo] / np.log(10.0)), dataclass=ifo
1932 if len(self.
_ifos) > 2
and "Joint" in self.
_ifos:
1935 "%.1f" % (self.
_Bci / np.log(10.0)), dataclass=ifo
1938 "%.1f" % (self.
_Bcin / np.log(10.0)), dataclass=ifo
1941 table.adddata(
"*", dataclass=ifo)
1942 table.adddata(
"*", dataclass=ifo)
1951 samples = self.
_posteriors[ifo][param].samples.squeeze()
1953 lowbound, highbound, _ = self.
_ci_loop(samples, ci)
1956 if paramval !=
None:
1959 for cit
in range(1, 101):
1960 l, h, cr = self.
_ci_loop(samples, cit)
1961 if paramval >= l
and paramval <= h:
1968 return lowbound, highbound, cival
1970 def _ci_loop(self, sortedsamples, ci):
1971 lowbound = sortedsamples[0]
1972 highbound = sortedsamples[-1]
1973 cregion = highbound - lowbound
1974 lsam = len(sortedsamples)
1975 cllen =
int(lsam *
float(ci) / 100.0)
1976 for j
in range(lsam - cllen):
1977 if sortedsamples[j + cllen] - sortedsamples[j] < cregion:
1978 lowbound = sortedsamples[j]
1979 highbound = sortedsamples[j + cllen]
1980 cregion = highbound - lowbound
1982 return lowbound, highbound, cregion
1987 Get information (evidence ratios and SNRs)
from any the background analyses
2003 self.
_ifos_ifos = list(backgrounddirs.keys())
2034 "whichtruth":
"all",
2035 "scatter_kwargs": {
"alpha": 0.5},
2052 if ifo
not in Bsn
or ifo
not in snrs:
2054 "Error... Bsn/SNR dictionary is not consistent with the background directories dictionary.",
2074 "Error... no background results directories were present for '%s'."
2082 if dirlen[i] != dirlen[0]:
2084 "Error... number of background results directories not then same for different detectors."
2115 def _get_snrs(self):
2122 def _get_bayes_factors(self):
2124 incoherent = np.zeros(
2129 for i, pdir
in enumerate(self.
_dir_lists[ifo]):
2130 pfiles = os.listdir(pdir)
2132 for pfile
in pfiles:
2134 pfile,
"posterior_samples*.hdf"
2135 )
or fnmatch.fnmatch(pfile,
"posterior_samples*.h5"):
2137 os.path.join(pdir, pfile)
2147 "Error... no HDF5 file with 'posterior_samples' in the name was found in '%s'."
2165 def _get_bsn_prob(self):
2170 kernel = stats.gaussian_kde(self.
_Bsn_Bsn[ifo])
2171 self.
_Bsn_prob[ifo] = kernel.integrate_box_1d(
2175 def _get_bci_prob(self):
2176 kernel = stats.gaussian_kde(self.
_Bci_Bci)
2197 "bsn", np.array([self.
_Bsn_Bsn[ifo]]).T / np.log(10.0)
2210 bins=
int(np.log2(len(snrs.samples))),
2212 credintervals=credint,
2247 bins=
int(np.log2(len(snrs.samples))),
2249 credintervals=credint,
2259 background_plots_table =
htmltag(
2260 "h2",
"Evidence distributions", newline=
True
2271 os.path.basename(bsnplot[0]),
2272 '<img class="backgroundplot" src="{}"/>'.
format(
2273 os.path.basename(bsnplot[0])
2279 bciplot = self.
bci_plot(which=
"bci")
2282 os.path.basename(bciplot[0]),
2283 '<img class="backgroundplot" src="{}"/>'.
format(
2284 os.path.basename(bciplot[0])
2291 bcinplot = self.
bci_plot(which=
"bcin")
2294 os.path.basename(bcinplot[0]),
2295 '<img class="backgroundplot" src="{}"/>'.
format(
2296 os.path.basename(bcinplot[0])
2303 innertable =
htmltable(tableclass=
"evidencetable")
2305 innertable.adddata(
" ")
2307 "Probability of background distribution being greater than foreground",
2312 innertable.adddata(
"Detector", header=
True)
2314 innertable.adddata(ifo, dataclass=ifo)
2316 innertable.adddata(
"B<sub>CvI</sub>")
2318 innertable.adddata(
"B<sub>CvIN</sub>")
2321 innertable.adddata(
" ")
2332 table.adddata(innertable.tabletext, colspan=cols)
2334 background_plots_table += table.tabletext
2336 return background_plots_table
2339if __name__ ==
"__main__":
2340 description =
"""This script will create a results page for a single pulsar from the known pulsar analysis pipeline. A configuration (.ini) file is required."""
2341 epilog =
"""An example configuration file could contain the following:
2343# a section for general analysis information
2345parfile = 'path_to_par_file'
2346detectors = [
'H1',
'L1']
2349with_background =
False
2352credible_interval = [95]
2355model_type = waveform
2357priorfile =
'path_to_prior'
2360[parameter_estimation]
2361posteriors = {
'H1':
'path_to_H1_posteriors',
'L1':
'path_to_L1_posteriors',
'Joint':
'path_to_Joint_posteriors'}
2362background = {
'H1':
'path_to_H1_background_dir',
'L1':
'path_to_L1_background_dir',
'Joint':
'path_to_Joint_backgroud_dir'}
2366files = {
'H1':
'path_to_H1_data',
'L1':
'path_to_L1_data'}
2370path =
'path_to_output_base_directory'
2371indexpage =
'path_to_index_page'
2375all_posteriors =
False
2376subtract_truths =
False
2377show_contours =
False
2383 parser = argparse.ArgumentParser(
2384 description=description,
2386 formatter_class=argparse.RawDescriptionHelpFormatter,
2388 parser.add_argument("inifile", help=
"The configuration (.ini) file")
2391 opts = parser.parse_args()
2393 inifile = opts.inifile
2401 "Error... cannot parse configuration file '%s'" % inifile, file=sys.stderr
2407 outdir = cp.get(
"output",
"path")
2410 "Error... no output directory 'path' specified in [output] section.",
2416 if not os.access(outdir, os.W_OK)
and not os.path.isdir(
2423 "Error... cannot make output directory '%s'." % outdir, file=sys.stderr
2429 indexpage = cp.get(
"output",
"indexpage")
2436 parfile = cp.get(
"general",
"parfile")
2439 "Error... Pulsar parameter 'parfile' must specified in the [general] section.",
2449 "Error... Pulsar parameter (.par) file '%s' could not be opened!" % parfile,
2458 "Error... no PSRJ name set in pulsar parameter file '%s'." % parfile,
2466 "Error... no 'F0' value in the parameter file '%s'." % parfile,
2477 upperlim = ast.literval_eval(cp.get(
"general",
"upper_limit"))
2483 credints = ast.literval_eval(cp.get(
"general",
"credible_interval"))
2489 injection = cp.getboolean(
"general",
"injection")
2497 usegwphase = cp.getboolean(
"general",
"use_gw_phase")
2503 priorfile = cp.get(
"general",
"priorfile")
2508 dist = p1_I = assoc = sdlim = f1sd =
None
2513 "http://www.atnf.csiro.au/people/pulsar/psrcat/proc_form.php?version="
2516 atnfurl +=
"&startUserDefined=true&pulsar_names=" + re.sub(
r"\+",
"%2B", pname)
2517 atnfurl +=
"&ephemeris=long&submit_ephemeris=Get+Ephemeris&state=query"
2520 jsonfile = os.path.join(outdir, pname +
".json")
2522 if os.path.isfile(jsonfile):
2524 fp = open(jsonfile,
"r")
2525 info = json.load(fp)
2529 dist = info[
"Pulsar data"][
"DIST"]
2530 p1_I = info[
"Pulsar data"][
"P1_I"]
2531 assoc = info[
"Pulsar data"][
"ASSOC"]
2535 "Warning... could not read in JSON file '%s'." % jsonfile,
2541 if pinfo
is not None:
2542 dist, p1_I, assoc, atnfurlref = pinfo
2546 dist = par[
"DIST"] / KPC
2552 if f1sd
is not None and dist
is not None:
2557 jointonly = cp.getboolean(
"general",
"joint_only")
2563 harmonics = ast.literal_eval(cp.get(
"general",
"harmonics"))
2569 modeltype = cp.get(
"general",
"model_type")
2571 modeltype =
"waveform"
2573 if modeltype
not in [
"waveform",
"source"]:
2575 "Error... unknown 'model type' '%s' specified." % modeltype, file=sys.stderr
2580 biaxial = cp.getboolean(
"general",
"biaxial")
2586 with_background = cp.getboolean(
"general",
"with_background")
2588 with_background =
False
2592 backgrounddir = ast.literal_eval(
2593 cp.get(
"parameter_estimation",
"background")
2596 with_background =
False
2600 allposteriors = cp.getboolean(
"plotting",
"all_posteriors")
2602 allposteriors =
False
2606 subtracttruths = cp.getboolean(
"plotting",
"subtract_truths")
2608 subtracttruths =
False
2612 showcontours = cp.getboolean(
"plotting",
"show_contours")
2614 showcontours =
False
2619 witheps = cp.getboolean(
"plotting",
"eps_output")
2624 figformat.append(
"eps")
2628 withpdf = cp.getboolean(
"plotting",
"pdf_output")
2633 figformat.append(
"pdf")
2642 ifos = ast.literal_eval(cp.get(
"general",
"detectors"))
2645 "Error... could not parse list of 'detectors' in the [general] section.",
2650 if not isinstance(ifos, list):
2652 "Error... the 'detectors' value in the [general] section must be a list.",
2659 "Error... the 'detectors' value in the [general] section must contain at least one detector name.",
2667 withjoint = cp.getboolean(
"general",
"with_joint")
2673 preprocdat = ast.literal_eval(cp.get(
"data",
"files"))
2676 "Error... could not parse dictionary of 'files' in the [data] section.",
2681 if not isinstance(preprocdat, dict):
2683 "Error... the 'files' value in the [data] section must be a dictionary.",
2690 if ifo
not in preprocdat:
2692 "Error... no pre-processed data file is given for '%s'." % ifo,
2699 preprocdat, outdir, figformats=figformat, harmonics=harmonics
2703 if withjoint
or jointonly:
2704 ifos.append(
"Joint")
2708 postfiles = ast.literal_eval(cp.get(
"parameter_estimation",
"posteriors"))
2711 "Error... could not parse dictionary of 'posteriors' in the [parameter_estimation] section.",
2716 if not isinstance(postfiles, dict):
2718 "Error... the 'posteriors' value in the [parameter_estimation] section must be a dictionary.",
2724 if ifo
not in postfiles:
2726 "Error... no posterior file is given for '%s'." % ifo, file=sys.stderr
2730 if not os.path.isfile(postfiles[ifo]):
2732 "Error... posterior file '%s' for '%s' does not exist."
2733 % (postfiles[ifo], ifo),
2739 linktable =
htmltag(
"div", tagstyle=
"text-align: left; float: left")
2746 htmlinput[
"psrname"] = pname
2747 htmlinput[
"title"] = pname
2749 titlename =
"INJ " + pname
2751 titlename =
"PSR " + pname
2753 htmlinput[
"h1title"] =
atag(atnfurl, linktext=titlename).text
2755 htmlinput[
"h1title"] = titlename
2759 htmlinput[
"pulsartable"] = psrtable
2766 harmonics=harmonics,
2767 modeltype=modeltype,
2770 usegwphase=usegwphase,
2771 subtracttruths=subtracttruths,
2772 priorfile=priorfile,
2773 showcontours=showcontours,
2777 htmlinput[
"limitstable"] = postinfo.create_limits_table(
2778 f0, sdlim=sdlim, dist=dist, ul=upperlim
2781 htmlinput[
"selectedposteriors"] = postinfo.create_joint_plots_table(
2782 title=
"Selected parameters"
2786 htmlinput[
"jointposteriors"] = postinfo.create_joint_plots_table(allparams=
True)
2789 +
atag(
"#selectedposteriors", linktext=
"Selected").text
2791 +
atag(
"#jointposteriors", linktext=
"All").text
2793 dataclass=
"rightborder",
2796 htmlinput[
"jointposteriors"] =
""
2798 atag(
"#selectedposteriors", linktext=
"Posteriors").text,
2799 dataclass=
"rightborder",
2813 htmlinput[
"evidenceplots"] = bginfo.create_background_table()
2815 atag(
"#evidenceplots", linktext=
"Backgrounds").text, dataclass=
"rightborder"
2818 htmlinput[
"evidenceplots"] =
""
2821 if datatable
is not None:
2822 htmlinput[
"dataplots"] =
str(datatable)
2824 atag(
"#dataplots", linktext=
"Data Plots").text, dataclass=
"rightborder"
2828 htmlinput[
"posteriorsamples"] = postinfo.create_sample_plot_table(
2829 figformats=figformat
2832 atag(
"#posteriorsamples", linktext=
"Samples").text, dataclass=
"rightborder"
2836 htmlinput[
"posteriorstats"] = postinfo.create_stats_table(credints=credints)
2837 linkstable.adddata(
atag(
"#posteriorstats", linktext=
"Statistics").text)
2839 linktable.set_tagtext(linkstable.tabletext)
2842 if indexpage !=
None:
2844 "div", tagstyle=
"text-align: left; float: right; padding-right: 8px"
2846 indexlink.set_tagtext(
atag(indexpage, linktext=
"Index Page").text)
2847 indexlinktxt = indexlink.text
2851 htmlinput[
"linkstable"] = linktable.text + indexlinktxt
2854 cssfile = os.path.join(outdir,
"resultspage.css")
2855 fp = open(cssfile,
"w")
2856 fp.write(result_page_css)
2859 htmlinput[
"cssfile"] = os.path.basename(cssfile)
2862 now = datetime.datetime.now()
2865 htmlinput[
"footer"] =
"{} - {}<br><br>Command lines used:<br>{}<br>{}<br>".
format(
2866 __author__, now.strftime(
"%a %d %b %Y"),
" ".join(sys.argv), __version__
2871 htmlfile = os.path.join(outdir, pname +
".html")
2872 fp = open(htmlfile,
"w")
2873 fp.write(htmlpage.format(**htmlinput))
2876 print(
"Error... there was a problem outputting the html page.", file=sys.stderr)
2885 info[
"Pulsar data"] = {}
2886 info[
"Pulsar data"][
"F0"] = f0
2887 info[
"Pulsar data"][
"F0ROT"] = f0
2888 info[
"Pulsar data"][
"F0GW"] = 2.0 * f0
2889 info[
"Pulsar data"][
"F1"] = f1
2890 info[
"Pulsar data"][
"F1ROT"] = f1
2891 info[
"Pulsar data"][
"F1GW"] = 2.0 * f1
2892 info[
"Pulsar data"][
"F1SD"] = f1sd
2893 info[
"Pulsar data"][
2896 info[
"Pulsar data"][
"DIST"] = dist
2897 info[
"Pulsar data"][
"RA"] = par[
"RA_RAD"]
2898 info[
"Pulsar data"][
"DEC"] = par[
"DEC_RAD"]
2899 info[
"Pulsar data"][
"START"] = par[
"START"]
2900 info[
"Pulsar data"][
"FINISH"] = par[
"FINISH"]
2901 info[
"Pulsar data"][
"BINARY"] = par[
"BINARY"]
2902 info[
"Pulsar data"][
"PEPOCH"] = par[
"PEPOCH"]
2903 info[
"Pulsar data"][
"POSEPOCH"] = par[
"POSEPOCH"]
2904 info[
"Pulsar data"][
"EPHEM"] = par[
"EPHEM"]
2905 info[
"Pulsar data"][
"UNITS"] = par[
"UNITS"]
2906 info[
"Pulsar data"][
"ASSOC"] = assoc
2907 info[
"Pulsar data"][
"spin-down limit"] = sdlim
2908 info[
"Pulsar data"][
"par file"] = parfile
2909 info[
"Pulsar data"][
"ATNF URL"] = atnfurl
2914 info[ifo][
"Upper limits"] = {}
2915 info[ifo][
"Upper limits"][
"credible region"] = upperlim
2916 info[ifo][
"Upper limits"][
"H0"] = postinfo.h0_ul(ifo)
2917 info[ifo][
"Upper limits"][
"ELL"] = postinfo.ellipticity_ul(ifo)
2918 info[ifo][
"Upper limits"][
"Q22"] = postinfo.q22_ul(ifo)
2919 info[ifo][
"Upper limits"][
"C21"] = postinfo.C21_ul(ifo)
2920 info[ifo][
"Upper limits"][
"C22"] = postinfo.C22_ul(ifo)
2921 info[ifo][
"Upper limits"][
"I21"] = postinfo.I21_ul(ifo)
2922 info[ifo][
"Upper limits"][
"I31"] = postinfo.I21_ul(ifo)
2923 info[ifo][
"Upper limits"][
"spin-down ratio"] = postinfo.sdlim_ratio(ifo)
2926 info[ifo][
"Bayes factors"] = {}
2927 info[ifo][
"Bayes factors"][
"Signal vs Noise"] = postinfo.bsn[ifo]
2930 info[ifo][
"Bayes factors"][
"Coherent vs Incoherent"] = postinfo.bci
2931 info[ifo][
"Bayes factors"][
2932 "Coherent vs Incoherent or Noise"
2935 info[ifo][
"SNR"] = postinfo.snr(ifo)
2939 info[ifo][
"Amplitude spectral density"] = {}
2941 if len(harmonics) == 1:
2942 info[ifo][
"Amplitude spectral density"][
"Spectrum"] = datatable.asds[
2945 info[ifo][
"Amplitude spectral density"][
"Mean"] = np.mean(
2946 datatable.asds[harmonics[0]][ifo]
2948 info[ifo][
"Amplitude spectral density"][
"Median"] = np.median(
2949 datatable.asds[harmonics[0]][ifo]
2951 info[ifo][
"Amplitude spectral density"][
"Maximum"] = np.max(
2952 datatable.asds[harmonics[0]][ifo]
2956 info[ifo][
"Amplitude spectral density"][
2957 "%df harmonic" %
int(h)
2959 info[ifo][
"Amplitude spectral density"][
"%df harmonic" %
int(h)][
2961 ] = datatable.asds[h][ifo].tolist()
2962 info[ifo][
"Amplitude spectral density"][
"%df harmonic" %
int(h)][
2964 ] = np.mean(datatable.asds[h][ifo])
2965 info[ifo][
"Amplitude spectral density"][
"%df harmonic" %
int(h)][
2967 ] = np.median(datatable.asds[h][ifo])
2968 info[ifo][
"Amplitude spectral density"][
"%df harmonic" %
int(h)][
2970 ] = np.max(datatable.asds[h][ifo])
2972 jsonfile = os.path.join(outdir, pname +
".json")
2973 fp = open(jsonfile,
"w")
2974 json.dump(info, fp, indent=2)
Class to make and return a html table.
A class to create a html tag.
Get information (evidence ratios and SNRs) from any the background analyses.
def bsn_plot(self, credint=[0.5, 0.95])
def create_background_table(self)
def bci_plot(self, credint=[0.5, 0.95], which="bci")
def __init__(self, backgrounddirs, snrs, Bsn, outputdir, Bci=None, Bcin=None, showcontours=True)
Initialise with a dictionary keyed in detector names containing paths to the equivalent posterior sam...
def _get_bayes_factors(self)
def analysis_stats_td(self, ifo)
def __init__(self, datafiles, outputdir, figformats=["png"], asdtime=86400, harmonics=[2.0])
Initialise with a dictionary keyed in detector names containing paths to the equivalent pre-processed...
Get sample posteriors and created a set of functions for outputting tables, plots and posterior stati...
def __init__(self, postfiles, outputdir, ifos=None, harmonics=[2], modeltype="waveform", biaxial=False, usegwphase=False, parfile=None, priorfile=None, subtracttruths=False, showcontours=False)
Initialise with a dictionary keyed in detector names containing paths to the equivalent posterior sam...
def create_joint_plots_table(self, allparams=False, title="Joint distributions")
def create_sample_plot_table(self, figformats=["png"])
def create_stats_table(self, credints=[95])
def _get_bayes_factors(self)
def _ci_loop(self, sortedsamples, ci)
def create_limits_table(self, freq, sdlim=None, dist=None, ul=95)
def plot_prior(self, ax, param, prior, orientation="horizontal", truth=0.0, npoints=100)
def ellipticity_ul(self, ifo)
def create_joint_posterior_plot(self, parameters, bins=20, ifo=None, truths=None, credintervals=[0.9], filename=None, figformats=["png"], ratio=3, figlimits=None, contourlimits=None, jointsamples=True, whichtruth=None, scatter_kwargs={})
def sdlim_ratio(self, ifo)
def get_bayes_factor(self, postfile)
_injection_credible_regions
def credible_interval(self, ifo, param, ci=95, paramval=None)
def exp_str(f, p=1, otype="html")
def pulsar_nest_to_posterior(postfile, nestedsamples=False, removeuntrig=True)
This function will import a posterior sample file created by lalapps_nest2pos (or a nested sample fil...
def upper_limit_greedy(pos, upperlimit=0.95, nbins=100)
def h0_to_quadrupole(h0, freq, dist)
def spin_down_limit(freq, fdot, dist)
def plot_posterior_chain(poslist, param, ifos, grr=None, withhist=0, mplparams=False)
def get_atnf_info(psr)
Get the pulsar (psr) distance (DIST in kpc), proper motion corrected period derivative (P1_I) and any...
def plot_Bks_ASDs(Bkdata, delt=86400, plotpsds=True, plotfscan=False, removeoutlier=None, mplparams=False)
def h0_to_ellipticity(h0, freq, dist)
def create_psr_table(par)
Create a html table of some information from the pulsar parameter file.
def set_spin_down(p1_I, assoc, f0, f1, n=5.0)
Set the spin-down of the source based on the intrinsic period derivative (p1_I) corrected for any pro...