pyhs3.data.UnbinnedData¶
- class pyhs3.data.UnbinnedData(**data)[source]¶
Unbinned data specification for multiple data points.
Represents individual data points in multi-dimensional space with optional weights and uncertainties.
- Variables:
name – Custom string identifier
type – Must be “unbinned”
entries – Array of coordinate arrays for each data point
axes – Axis specifications defining coordinate system (UnbinnedAxis with required min/max)
weights – Optional weights for each entry
entries_uncertainties – Optional uncertainties for each coordinate
- Parameters:
data (
Any)
Validators¶ Validator
Mode
Fields
after
model
- __init__(**data)¶
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- Parameters:
data (
Any)
Methods
to_hist([nbins])Convert to scikit-hep hist.Hist object by binning entries.
Validate consistency of unbinned data arrays.
Attributes
Entries array with each row multiplied by its event weight.
- UnbinnedData.to_hist(nbins=50)[source]¶
Convert to scikit-hep hist.Hist object by binning entries.
Creates a hist.Hist histogram by binning the unbinned entries according to the axis specifications. The resulting histogram can be plotted using matplotlib or other visualization tools.
- Parameters:
nbins (
int) – Number of bins to use for each axis (default: 50)- Returns:
- Histogram representation with:
Axes matching the data axes
Values from binned entries
Weights if provided
- Return type:
Examples
>>> entries = [[0.5], [1.2], [1.8]] >>> axes = [UnbinnedAxis(name="x", min=0, max=3)] >>> data = UnbinnedData( ... name="example", ... type="unbinned", ... entries=entries, ... axes=axes ... ) >>> data.to_hist(nbins=3) Hist(Regular(3, 0, 3, name='x'), storage=Double()) # Sum: 3.0
- UnbinnedData.validate_unbinned_data()[source]¶
Validate consistency of unbinned data arrays.
- Return type:
- UnbinnedData.weighted_entries¶
Entries array with each row multiplied by its event weight.
Returns a numpy array of shape
(n_events, n_axes)— the same structure asentries— where each rowiis scaled byweights[i]. When no weights are present the result equalsnp.array(self.entries).Axis values can be extracted with standard numpy indexing, e.g.
data.weighted_entries[:, 0]for the first observable. Threshold filtering and sorting are left to the caller:vals = data.weighted_entries[:, 0] vals = np.sort(vals[np.abs(vals) > 1e-6])
- Returns:
ndarray of shape (n_events, n_axes)
- UnbinnedData.type¶
- UnbinnedData.entries¶
- UnbinnedData.axes¶
- UnbinnedData.weights¶
- UnbinnedData.entries_uncertainties¶
- UnbinnedData.name¶