nrcatalogtools.surrogate¶
NRSur7dq4 loading, evaluation, and prior check utilities.
gwsurrogateis an optional dependency. Importing this module succeeds even whengwsurrogateis not installed; theImportErroris raised only on the first call toload_nrsur7dq4()orgenerate_surrogate_modes().Conceptual background: See Package Internals § 11 for notes on the
f_refclipping strategy and spin-epoch conventions.
Functions¶
surrogate
¶
Surrogate waveform utilities for NR vs NRSur7dq4 comparisons.
Handles loading the surrogate, calling it with NR-compatible parameters, and wrapping the output as physical-unit pycbc TimeSeries objects.
NRSur7dq4 notes
- Precessing model — takes full 3-vector spins, returns all modes up to ell=4.
- The
ellMaxparameter caps the output (max is 4);mode_listis not supported for precessing models. f_lowcontrols waveform truncation only (start frequency); for NRSur7dq4 the recommended value is 0 (return the entire waveform).f_refsets the reference epoch at which the spins are defined; it is in cycles/M (= M * f_GW where M is in seconds). For aligned-spin or non-spinning systemsf_ref = f_lower_NR * M_secondsis sufficient. For precessing SXS systems Phase 2 extracts the instantaneous spins fromHorizons.h5at the epoch corresponding to the chosenf_ref.dtargument is in dimensionless M units.- Output
h[(ell,em)]is a complex numpy array representing the spin-weight -2 spherical harmonic modeh_lm(same convention as SXS/RIT/MAYA NR data:h_+ - i h_×decomposed asΣ h_lm Y_{-2,lm}). - Time array
t_suris in dimensionless M units;t_sur[-1] ≈ +100 Mis near merger (peak amplitude).
Spin epoch conventions
Two cases arise depending on whether the NR waveform starts before or after the surrogate's minimum training frequency (~0.0165 M·Ω_orbital):
-
NR shorter than surrogate (
f_lower_NR > f_min_sur): Passf_low=0(full waveform) andf_ref=f_lower_NR_dimless. The surrogate backward-evolves the spins from the NR epoch to its start. -
NR longer than surrogate (
f_lower_NR < f_min_sur): The surrogate cannot extrapolate before its minimum frequency, sof_refis clipped tof_min_sur. For aligned-spin or non-spinning systems the spin components are constant (no precession), so the metadata spins remain valid regardless of epoch. For precessing SXS systems Phase 2 automatically re-extracts the spin vectors fromHorizons.h5at the clipped epoch so that the spin-epoch is always physically consistent.
load_nrsur7dq4
¶
Load and cache the NRSur7dq4 surrogate model.
Returns:
| Type | Description |
|---|---|
gwsurrogate surrogate object
|
|
Source code in nrcatalogtools/surrogate.py
generate_surrogate_modes
¶
generate_surrogate_modes(params: dict, total_mass: float, distance: float = 1.0, delta_t_seconds: float = 1.0 / 4096, sim_name: str | None = None, catalog=None, nr_wfm=None) -> tuple[dict, float]
Call NRSur7dq4 and return physical-unit modes as a pycbc TimeSeries dict.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
params
|
dict
|
PyCBC-compatible binary parameter dict as returned by
|
required |
total_mass
|
float
|
Total binary mass in solar masses (sets the physical time/frequency scale for the surrogate call). |
required |
distance
|
float
|
Luminosity distance in Mpc for amplitude scaling (default 1). |
1.0
|
delta_t_seconds
|
float
|
Desired sample spacing in physical seconds (default 1/4096). |
1.0 / 4096
|
sim_name
|
str
|
Simulation name, used for epoch-aligned spin extraction on precessing SXS runs. |
None
|
catalog
|
CatalogBase
|
Catalog instance; enables Phase 2 epoch alignment when the catalog is SXS. |
None
|
nr_wfm
|
WaveformModes
|
Unused; kept for API compatibility. |
None
|
Returns:
| Type | Description |
|---|---|
tuple[dict, float]
|
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Source code in nrcatalogtools/surrogate.py
221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 | |
check_surrogate_prior
¶
Return True if the binary parameters fall within the NRSur7dq4 prior volume.
NRSur7dq4 is valid for:
- q = m1/m2 ∈ [1, 4]
- |χ₁|, |χ₂| ≤ 0.8
- Waveform length ≥ ~4350 M (not checked here — handled by the surrogate call).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
params
|
dict
|
PyCBC-compatible parameter dict. |
required |
q_max
|
float
|
Maximum mass ratio (default 4). |
4.0
|
chi_max
|
float
|
Maximum spin magnitude (default 0.8). |
0.8
|
Returns:
| Type | Description |
|---|---|
bool
|
|
Source code in nrcatalogtools/surrogate.py
Constants¶
| Name | Description |
|---|---|
SURROGATE_MODES |
Mode list output by NRSur7dq4: (2,1), (2,2), (3,2), (3,3), (4,3), (4,4) |
NR_MODES |
Superset of SURROGATE_MODES — all modes present in the NR catalogs, including (5,5) |
_SURROGATE_F_MIN_CYCLES_PER_M |
Minimum \(M f_{GW}\) (cycles/M) for NRSur7dq4 training (0.0165) |