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.

_check_n0_input §

_check_n0_input(n0, xi_var)

Check if the xi_var is provided when n0 is provided.

Parameters:

Name Type Description Default

n0 §

float | None

Reference density value.

required

xi_var §

str | None

Name of the variable representing the \(\xi\) axis.

required

Raises:

Type Description
ValueError

If n0 is provided but xi_var is not.

Notes

If n0 and xi_var are both provided, a warning is printed assuming the \(\xi\) axis is in normalized units.

_check_raw_and_grid §

_check_raw_and_grid(raw_ds, grid_ds)

Check if the input datasets contain particle and grid data, respectively.

Parameters:

Name Type Description Default

raw_ds §

Dataset

Dataset containing particle data.

required

grid_ds §

Dataset

Dataset containing grid data.

required

Raises:

Type Description
ValueError

If the input datasets do not contain particle and grid data, respectively.

_define_q_units §

_define_q_units(n0, xi_var, dens_ds)

Define the units for the charge density based on the data origin and input parameters.

Parameters:

Name Type Description Default

n0 §

float | None

Reference density value.

required

xi_var §

str | None

Name of the variable representing the xi axis.

required

dens_ds §

Dataset

Dataset containing density data.

required

Returns:

Name Type Description
units_str str

String representing the units for the charge density.

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.