halocat.xi_AB_manager¶
xi_AB_manager
¶
Manager for cumulative-threshold ξ_AB measurements + emulator assembly.
Two user-facing entry points:
-
:class:
XiABLoader— load-or-measure ξ_AB for one realisation (one(gravity, redshift, imodel, ibox)tuple). Mirrors the :class:halocat.dataloader.HMFLoader/ :class:XiHHLoaderworkflow but writes to its ownxi_AB_thresh.hdf5schema and invokes the threshold-grid pair-counting optimisation in :func:halocat.tpcf._measure_xi_AB_threshold_grid. -
:func:
assemble_emulator_training_set— stack across a sub-grid (one gravity, one redshift, many imodels × iboxes) into the emulator-shaped tensors. Optionally materialises a single suite-snapshot HDF5 file and / or memoises the assembled dict in process memory.
The manager calls into existing halocat infrastructure for halo
catalogue access (halocat.io.read_halo_hdf5 + on-demand
.DAT → halo.hdf5 reformatting via
halocat.pipeline.run_single); cosmology parameters
(halocat.cosmology.get_cosmology); and storage
(halocat.xi_AB_io).
DEFAULT_THRESHOLDS
module-attribute
¶
XiABLoader
¶
XiABLoader(thresholds=None, r_edges=None, *, mass_definition: str = 'Mtot', overwrite: bool = False, write_halo_hdf5: bool = False, logger=None)
Bases: _BaseHaloStatLoader
Load-or-measure dataloader for the cumulative-threshold ξ_AB cube.
Each call resolves to a single (gravity, redshift, imodel, ibox)
realisation, loads the cached xi_AB_thresh.hdf5 if its
cache_key matches the current spec, and otherwise invokes the
threshold-grid pair-counting optimisation
(:func:halocat.tpcf._measure_xi_AB_threshold_grid) and writes a
fresh file atomically.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
thresholds
|
array_like
|
Shared mass-threshold grid in log10(M / [Msun/h]). Defaults to
|
None
|
r_edges
|
array_like
|
Separation bin edges (Mpc/h). Defaults to
:data: |
None
|
mass_definition
|
'Mtot'
|
Halo mass column name. Currently only |
"Mtot"
|
overwrite
|
bool
|
If True, ignore the existing cache and re-measure. |
False
|
write_halo_hdf5
|
bool
|
Force re-reformatting |
False
|
logger
|
Logger
|
|
None
|
Examples:
>>> loader = XiABLoader()
>>> rec = loader.get("LCDM", 0.25, imodel=0, ibox=1)
>>> rec.xi_AB.shape
(60, 59, 59)
Source code in halocat/xi_AB_manager.py
r_edges
instance-attribute
¶
r_edges = asarray(r_edges, dtype=float64) if r_edges is not None else asarray(R_EDGES, dtype=float64)
get
¶
Return the ξ_AB record, measuring on demand if missing/stale.
Source code in halocat/xi_AB_manager.py
measure
¶
measure(gravity: str, redshift: float, imodel: int, ibox: int, *, expected_cache_key: str | None = None) -> XiABRecord
Force one ξ_AB measurement and write the file atomically.
Source code in halocat/xi_AB_manager.py
get_grid
¶
get_grid(gravities: list[str] | None = None, redshifts: list[float] | None = None, imodels: list[int] | None = None, iboxes: list[int] | None = None, *, skip_missing: bool = False) -> dict
Stack ξ_AB across a sub-grid into (G, Z, M, B, N_r, N_t, N_t).
Returns a dict with axis labels, the shared
thresholds / r_edges / r, and stacked xi_AB,
n_h_cum, plus a bool present mask of shape
(G, Z, M, B). Mirrors :meth:HMFLoader.get_grid /
:meth:XiHHLoader.get_grid.
Source code in halocat/xi_AB_manager.py
path
classmethod
¶
clear_in_process_cache
¶
Drop the module-level memo cache used by
:func:assemble_emulator_training_set. Call this if the underlying
per-realisation caches were re-measured outside the manager.
assemble_emulator_training_set
¶
assemble_emulator_training_set(gravity: str, redshift: float, imodels: Sequence[int], iboxes: Sequence[int], *, thresholds=None, r_edges=None, mass_definition: str = 'Mtot', avg_iboxes: bool = True, materialise_snapshot: bool = False, snapshot_path: str | None = None, in_process_cache: bool = True, overwrite: bool = False, write_halo_hdf5: bool = False, logger=None) -> dict
Build emulator-shaped tensors for one gravity × one redshift.
Calls :meth:XiABLoader.get for every
(gravity, redshift, imodel, ibox) in the requested sub-grid
(measuring on demand for cache misses), then stacks into the
(N_cosmo, N_r, N_t, N_t) cube the emulator training pipeline
expects, plus the cosmology parameter matrix
:func:halocat.cosmology.theta_keys -ordered.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
gravity
|
('LCDM', 'fRn1')
|
The θ schema is gravity-conditional — LCDM has 4 parameters, fRn1 has 5 — so this function always returns one gravity per call. |
"LCDM"
|
redshift
|
float
|
|
required |
imodels
|
sequence of int
|
|
required |
iboxes
|
sequence of int
|
|
required |
thresholds
|
see :class:`XiABLoader`.
|
|
None
|
r_edges
|
see :class:`XiABLoader`.
|
|
None
|
mass_definition
|
see :class:`XiABLoader`.
|
|
None
|
avg_iboxes
|
bool
|
If True, average ξ_AB and |
True
|
materialise_snapshot
|
bool
|
If True, write the assembled dict to a single suite-level HDF5
file at |
False
|
snapshot_path
|
str
|
|
None
|
in_process_cache
|
bool
|
Memoise the assembled dict in module memory keyed by
|
True
|
overwrite
|
bool
|
Forwarded to :class: |
False
|
write_halo_hdf5
|
bool
|
Forwarded to :class: |
False
|
logger
|
Logger
|
|
None
|
Returns:
| Name | Type | Description |
|---|---|---|
out |
dict
|
Keys (with shapes for
For |
Source code in halocat/xi_AB_manager.py
376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 | |