xmlutils
The RIFT.misc.xmlutils module provides the essential bridge between RIFT’s internal data structures and the standardized LIGO-LW XML format. This ensures that RIFT outputs are compatible with other LIGO/Virgo/KAGRA data analysis tools.
Data Persistence Logic
The module focuses on two primary data persistence tasks: archiving simulation parameters and recording likelihood results.
Archiving Samples: The
append_samples_to_xmldocfunction maps sampled parameter sets to theSimInspiralTable. This is critical for preserving the “provenance” of an inference run, allowing researchers to see exactly which points in parameter space were evaluated.Recording Results: The
append_likelihood_result_to_xmldocfunction records the resulting log-likelihood and convergence metrics into theSnglInspiralTable.
The Parameter Mapping (CMAP)
Because RIFT uses intuitive parameter names (e.g., right_ascension, declination) that may differ from the formal LAL table column names (e.g., longitude, latitude), the module employs a central mapping dictionary called CMAP.
This mapping ensures that:
- Parameters are correctly assigned to the corresponding LAL table columns.
- Specialized transformation functions (like assign_time) are applied during the mapping process to handle unit conversions or time-stamping.
Database Integration
For very large simulation sets where XML files become unwieldy, xmlutils provides SQLite integration:
- db_to_samples: Efficiently extracts sets of parameters and results from a SQL database, returning them as Python named-tuples.
- db_identify_param: Allows quick lookup of specific process parameters.
API Reference
- RIFT.misc.xmlutils.append_likelihood_result_to_xmldoc(xmldoc, loglikelihood, neff=0, converged=False, **cols)
- RIFT.misc.xmlutils.append_samples_to_xmldoc(xmldoc, sampdict)
- RIFT.misc.xmlutils.assign_id(row, i)
- RIFT.misc.xmlutils.assign_time(row, t)
- RIFT.misc.xmlutils.db_identify_param(db_fname, process_id, param)
Extract the event time for a given process ID. This may fail in the case that the event time was not given on the command line (rather in a pointer to a XML file) NOTE: This is definitely not the best way to do this.
- RIFT.misc.xmlutils.db_to_samples(db_fname, tbltype, cols)
Pull samples from db_fname and return object that resembles a row from an XML table.
- RIFT.misc.xmlutils.gps_add_seconds_exact(gps_seconds, gps_nanoseconds, offset_seconds)
Add float relative offsets to an exact GPS pair using integer nanoseconds.
The offset is rounded once to the SimInspiral schema’s nanosecond resolution. Absolute GPS arithmetic is never performed in float64, whose spacing at current epochs is coarser than some sub-sample time-posterior draws. Returns arrays
(seconds, nanoseconds)with nanoseconds normalized to[0, 1e9); negative offsets and second-boundary carries are supported.
- RIFT.misc.xmlutils.likelihood_to_snglinsp_row(table, loglikelihood, neff=0, converged=False, **cols)
- RIFT.misc.xmlutils.samples_to_siminsp_row(table, colmap={}, **sampdict)