Skip to content

ozzy.statistics

The statistics submodule encompasses functions that process particle data or otherwise synthesize data into lower-dimensional measures. A classic example is getting the centroid (mean transverse position) of a particle distribution.

charge_in_field_quadrants §

charge_in_field_quadrants(
    raw_ds,
    fields_ds,
    time_dim="t",
    weight_var="q",
    n0=None,
    xi_var=None,
)

Calculate the amount of charge in different quadrants of the "field space". By quadrants we mean the four possible combinations of positive/negative longitudinal fields and positive/negative transverse fields.

Parameters:

Name Type Description Default

raw_ds §

Dataset

Dataset containing particle data.

required

fields_ds §

Dataset

Dataset containing field data.

Warning

This function expects the fields_ds argument to be a dataset containing two variables, one of which corresponds to a longitudinal field/force and the other to a transverse field/force.

required

time_dim §

str

Name of the time dimension in the input datasets. Default is 't'.

't'

weight_var §

str

Name of the variable representing particle weights or particle charge in raw_ds. Default is 'q'.

'q'

n0 §

float | None

Reference plasma density value, in \(\mathrm{cm}^{-3}\). If provided, the charge is converted to physical units. Default is None.

None

xi_var §

str | None

Name of the variable representing the longitudinal axis. Required if n0 is provided.

None

Returns:

Name Type Description
charge_ds Dataset

Dataset containing the charge in different quadrants of the "field space".

Raises:

Type Description
ValueError

If the input datasets do not contain particle and grid data, respectively, or if n0 is provided but xi_var is not.

field_space §

field_space(raw_ds, fields_ds, spatial_dims=['x1', 'x2'])

Get values of fields in the cell where each particle is located (no interpolation is done).

Parameters:

Name Type Description Default

raw_ds §

Dataset

Dataset containing particle data.

required

fields_ds §

Dataset

Dataset containing field data.

required

spatial_dims §

list[str]

List of spatial dimension names in the input datasets. Default is ['x1', 'x2'].

['x1', 'x2']

Returns:

Name Type Description
raw_ds Dataset

Dataset containing particle data with interpolated field values.

Raises:

Type Description
ValueError

If the input datasets contain a time dimension, or if the input datasets do not contain particle and grid data, respectively.

Warning

This function assumes that the second element of spatial_dims is the vertical dimension.