jesterTOV.inference.transforms.transform.JesterTransform#
- class JesterTransform(
- eos,
- tov_solver,
- name_mapping=None,
- keep_names=None,
- ndat_TOV=100,
- min_nsat_TOV=0.75,
- fixed_params=None,
- **kwargs,
Bases:
NtoMTransformTransform EOS parameters to neutron star observables (M, R, Λ).
This is the main transform class that combines an equation of state (EOS) model with a TOV solver to produce neutron star observables from microscopic EOS parameters.
The transform can be created either by: 1. Passing EOS and TOV solver instances directly 2. Using from_config() classmethod with configuration dict/object
- Parameters:
eos (Interpolate_EOS_model) – EOS model instance (MetaModel, MetaModelCSE, Spectral, etc.)
tov_solver (TOVSolverBase) – TOV solver instance (GRTOVSolver, AnisotropyTOVSolver, ScalarTensorTOVSolver)
name_mapping (tuple[list[str], list[str]] | None) – Tuple of (input_names, output_names). If None, constructed from EOS and TOV required parameters.
keep_names (list[str] | None) – Parameter names to preserve in output. If None, keeps all inputs.
ndat_TOV (int) – Number of central pressure points for M-R-Λ curves (default: 100)
min_nsat_TOV (float) – Minimum density for TOV integration in units of nsat (default: 0.75)
**kwargs (
Any) – Additional parameters (for compatibility)
- Variables:
eos (Interpolate_EOS_model) – The equation of state model
tov_solver (TOVSolverBase) – The TOV equation solver
tov_params (list[str]) – Parameters required by the TOV solver
Examples
>>> # Direct instantiation >>> from jesterTOV.eos.metamodel import MetaModel_EOS_model >>> from jesterTOV.tov.gr import GRTOVSolver >>> eos = MetaModel_EOS_model(crust_name="DH") >>> solver = GRTOVSolver() >>> transform = JesterTransform(eos=eos, tov_solver=solver)
>>> # From configuration >>> from jesterTOV.inference.config.schema import MetamodelCSEEOSConfig, TOVConfig >>> eos_config = MetamodelCSEEOSConfig(type="metamodel_cse", nb_CSE=8) >>> tov_config = TOVConfig(type="gr") >>> transform = JesterTransform.from_config(eos_config, tov_config)
>>> # Transform parameters to observables >>> params = {"E_sat": -16.0, "K_sat": 230.0, ...} >>> result = transform.forward(params) >>> print(result["masses_EOS"]) # Neutron star masses in M☉
- __init__(
- eos,
- tov_solver,
- name_mapping=None,
- keep_names=None,
- ndat_TOV=100,
- min_nsat_TOV=0.75,
- fixed_params=None,
- **kwargs,
Methods
__init__(eos, tov_solver[, name_mapping, ...])construct_eos_and_solve_tov(params)Construct EOS from parameters and solve TOV equations.
forward(x)Transform parameters and preserve keep_names.
from_config(eos_config, tov_config[, ...])Create transform from configuration objects.
Return EOS type identifier.
Return combined list of sampled EOS and TOV parameter names.
propagate_name(x)Propagate parameter names through the transform.
Attributes
transform_funcname_mapping- construct_eos_and_solve_tov(params)[source]#
Construct EOS from parameters and solve TOV equations.
This is the core transformation method that: 1. Constructs EOS from parameters 2. Solves TOV equations for M-R-Λ family 3. Returns observables with constraint checking
- Parameters:
params (dict[str, Float]) – Input parameters (EOS + TOV parameters)
- Return type:
- Returns:
dict[str, Float | Float[Array, “ n”]] – Dictionary containing: - masses_EOS : Neutron star masses [M☉] - radii_EOS : Neutron star radii [km] - Lambdas_EOS : Tidal deformabilities - logpc_EOS : Log10 central pressures - n, p, h, e, dloge_dlogp, cs2 : EOS quantities - Constraint violation counts
- forward(x)[source]#
Transform parameters and preserve keep_names.
This overrides NtoMTransform.forward() to:
Merge fixed parameters into
xbefore the EOS/TOV pipeline runs.Preserve parameters specified in
self.keep_names.Add fixed parameters to the output so they appear in the result.
- classmethod from_config(
- eos_config,
- tov_config,
- keep_names=None,
- max_nbreak_nsat=None,
- fixed_params=None,
Create transform from configuration objects.
This factory method instantiates the appropriate EOS and TOV solver based on the separate configurations, then creates the transform.
- Parameters:
eos_config (EOSConfig) – EOS configuration (MetamodelEOSConfig, MetamodelCSEEOSConfig, or SpectralEOSConfig)
tov_config (TOVConfig) – TOV solver configuration
keep_names (list[str] | None) – Parameters to preserve in output
max_nbreak_nsat (float | None) – Maximum nbreak value (for MetaModelCSE optimization)
fixed_params (dict[str, float] | None) – Parameters pinned to constant values, excluded from the sampling space but injected into every
forward()call.
- Return type:
- Returns:
JesterTransform – Configured transform instance
- Raises:
ValueError – If EOS or TOV type is unknown
- get_eos_type()[source]#
Return EOS type identifier.
- Return type:
- Returns:
str – EOS class name (e.g., ‘MetaModel_EOS_model’)