SphericalDSphEstimationModel#

jeanspy.model.SphericalDSphEstimationModel

See methods and properties for individual lookup pages, or the alphabetical API dictionary to search all classes. The full class contract and existing member anchors are retained below.

class jeanspy.model.SphericalDSphEstimationModel(*args, parameter_specs=None, dtype=None, vmem_prior_from_data=False, **kwargs)#

Bases: jeanspy.model.FittableModel, jeanspy.model.Model

Spherical Jeans inference with a Gaussian LOS-velocity likelihood.

Notes

Inputs and units. SphericalDSphEstimationModel composes DSphModel, FlatPriorModel and PhotometryPriorModel. args_load_data=[data] supplies a DataFrame with R_pc, vlos_kms and e_vlos_kms; kwargs_load_data may contain shared=True. Parameter vectors follow p_names_lnprob exactly. parameter_specs is an ordered sequence of jeanspy.parameters.SamplingParameter objects specifying physical names and transforms. Without specifications, names map by identity only.

Returns and shape. lnlikelihoods gives (N,) log densities; lnlikelihood sums them. lnpriors returns prior terms. lnposterior returns (logposterior, loglikelihood, individual prior terms) for emcee blobs. sample draws starting coordinates; sample_data simulates velocities at supplied positions.

Validity. Nonempty finite 1-D data, R>0, error>=0; mean/error in km/s. dtype=None preserves the common floating dtype of the three input columns (integer-only data use float64). An explicit floating dtype selects storage precision. Shared buffers use that same dtype and cannot change dtype on reset. Numerical solvers may promote arithmetic precision. vmem_prior_from_data defaults to False. WBIC uses inverse_temperature = 1/log(N) and requires N>1. Shared data cannot be resized.

Errors. Invalid prior order/schema/data raise ValueError. FittableModel requires a list args_load_data. Shared buffers must be released with release_shared_memory after workers stop.

Backend. NumPy/SciPy CPU; stateful components, with no JAX tracing.

Differentiation. No physical-parameter automatic differentiation on this API.

Examples. examples/docs_inference.py

property blobs_dtype#

Return emcee blob fields for log likelihood and individual log priors.

The list contains (name, float) pairs in the same order as the values returned by lnposterior after its first element.

convert_params(p)[source]#

Map sampling coordinates to physical parameters.

Notes

Inputs and units. One parameter vector in exact prior order; parameter_specs explicitly supplies each transformation.

Returns and shape. A Series indexed by physical parameter names, with units defined by the composed spherical model. Priors remain in the sampled coordinates; conversion does not add a Jacobian.

property data#

Access stored radii, velocities and velocity errors as named arrays.

Columns R_pc, vlos_kms and e_vlos_kms have shape (N,) and units pc, km/s and km/s. Shared mode returns views of the shared buffers and raises FileNotFoundError or AttributeError if they have not been initialized.

property inverse_temperature#

Return the WBIC inverse temperature 1/log(N_data).

is_required_param_names(param_names_candidates)#

Test a sequence of names against this component’s required parameters.

Returns a list of bool with the same length and order as param_names_candidates. Submodel requirements are not included.

lnlikelihood(p, *args, **kwargs)#

Evaluate the explicit kinematic inference target.

Notes

Inputs and units. p is one parameter vector of shape (ndim,) in p_names_lnprob order. Uses already loaded observations.

Returns and shape. Scalar sum of log likelihoods.

lnlikelihoods(p, *args, **kwargs)#

Evaluate the explicit kinematic inference target.

Notes

Inputs and units. p is one parameter vector of shape (ndim,) in p_names_lnprob order. Uses already loaded observations.

Returns and shape. Per-star log densities, shape (N,).

lnposterior(p, *args, **kwargs)#

Evaluate the explicit kinematic inference target.

Notes

Inputs and units. p is one parameter vector of shape (ndim,) in p_names_lnprob order. Uses already loaded observations.

Returns and shape. Tuple (logposterior, loglikelihood, individual prior terms) for emcee blobs.

lnposterior_wbic(p, *args, **kwargs)#

Evaluate the explicit kinematic inference target.

Notes

Inputs and units. p is one parameter vector of shape (ndim,) in p_names_lnprob order. Uses already loaded observations.

Returns and shape. Tuple using loglikelihood/log(N) plus the original prior; requires N>1.

lnpriors(p, *args, **kwargs)#

Evaluate the explicit kinematic inference target.

Notes

Inputs and units. p is one parameter vector of shape (ndim,) in p_names_lnprob order. Uses already loaded observations.

Returns and shape. Sequence of log prior contributions in prior_names order.

load_data(data, shared=False)[source]#

Load explicitly supplied observed kinematic data.

property n_data#

Return the number of observed stars as an integer.

property ndim#

Number of flattened physical parameters, cached on first access.

property p_names_lnprob#

Return sampling-coordinate names in the exact order expected by lnposterior.

property params_all#

Return a flattened Parameters copy of this model and its submodels.

Values retain their physical units. Later submodels overwrite duplicate names; use params_all_with_model_name to retain role-qualified names.

property params_all_with_model_name#

Return a new Parameters mapping with submodel-role prefixes.

Nested names use role:parameter notation. Values retain their physical units; this operation copies the mapping, not nested mutable values.

prior_names = ['flat_prior', 'photometry_prior']#
release_shared_memory()[source]#

Close and release this model’s three shared observation buffers.

Returns None. Existing array views must no longer be used after their buffers are released.

required_models = {'DSphModel': <class 'jeanspy.model.DSphModel'>, 'FlatPriorModel': <class 'jeanspy.model.FlatPriorModel'>, 'PhotometryPriorModel': <class 'jeanspy.model.PhotometryPriorModel'>}#
required_param_names = []#
property required_param_names_combined#

Return this model’s and all nested submodels’ required parameter names.

The result is a list in traversal order; duplicate names are retained.

reset_data(data)[source]#

Replace observations while sampler workers are idle.

Shared models keep their buffer shape so existing readers stay attached. Construct a new model to use a different number of observations. Explicit velocity-prior bounds are preserved unless the model was constructed with vmem_prior_from_data=True (an empirical-prior choice).

sample(size=None)[source]#

Draw sampling-coordinate vectors from the specified joint prior.

Uniform bounds apply to every coordinate; the log-radius coordinate is drawn from the product of those bounds and the Gaussian photometric prior. size=None returns (ndim,); a sample count/shape precedes that parameter axis. Uses the NumPy/SciPy global random state. Invalid prior schemas raise ValueError before sampling.

sample_data(size=None)[source]#

Draw conditional Gaussian LOS velocities at the stored positions.

The mean is vmem_kms and the variance is the predicted LOS variance plus the squared stored measurement error, in (km/s)^2. size=None returns a broadcast vector of shape (N,); explicit sizes must be compatible with that per-star shape. Uses SciPy’s global random state. Positions and measurement errors remain fixed; this is not a phase-space DF sampler.

sampling_identity()[source]#

Describe the persisted target using observations, priors and parameter order.

Returns host metadata for the sampler’s identity checks. Shared-memory handles, loggers and cached runtime state are excluded; observation values are included for both shared and ordinary storage.

property shared_memory_basename#

Return the observation-buffer name for this instance, or None if unshared.

update(new_params=None, **kwargs)#

Replace named parameters in the owning components.

Notes

Inputs and units. new_params is an optional mapping/Parameters/Series; keyword values are additional replacements. Names are physical names declared by this model and its components. Unknown names raise ValueError before any parameters are changed.

Returns and shape. None; mutates component parameters. params_all returns the resulting flattened copy.