sdf_xarray.dataset_accessor.EpochAccessor#

class sdf_xarray.dataset_accessor.EpochAccessor(xarray_obj)[source]#

Bases: object

Parameters:

xarray_obj (xr.Dataset)

__init__(xarray_obj)[source]#
Parameters:

xarray_obj (Dataset)

Methods

__init__(xarray_obj)

animate_multiple(*variables[, datasets_kwargs])

Animate multiple Dataset variables on the same axes.

rescale_coords(unit_label, coord_names[, ...])

Rescales specified coordinates in a Dataset by a given unit.

animate_multiple(*variables, datasets_kwargs=None, **kwargs)[source]#

Animate multiple Dataset variables on the same axes.

Parameters:
  • variables (str | DataArray) – The variables to animate.

  • datasets_kwargs (list[dict] | None) – Per-dataset keyword arguments passed to plotting.

  • kwargs – Common keyword arguments forwarded to animation.

Return type:

FuncAnimation

Examples

>>> anim = ds.epoch.animate_multiple(
        ds["Derived_Number_Density_Electron"],
        ds["Derived_Number_Density_Ion"],
        datasets_kwargs=[{"label": "Electron"}, {"label": "Ion"}],
        ylabel="Derived Number Density [1/m$^3$]"
    )
>>> anim.save("animation.gif")
>>> # Or in a jupyter notebook:
>>> anim.show()
rescale_coords(unit_label, coord_names, multiplier=None)[source]#

Rescales specified coordinates in a Dataset by a given unit. If the multiplier is not specified then the coordinates are automatically scaled using pint, if the multiplier is specified then it will be used to rescale the coordinate.

Parameters:
  • unit_label (str) – The new unit label for the coordinates (e.g., “µm”).

  • coord_names (str or list of str) – The name(s) of the coordinate variable(s) to rescale. If a string, only that coordinate is rescaled. If a list, all listed coordinates are rescaled.

  • multiplier (float or None) – The factor by which to multiply the coordinate values (e.g., 1e6 for meters to microns). If not specified then pint is used to rescale the units automatically.

Return type:

Dataset

Examples

>>> # Convert X, Y, and Z from meters to microns using pint
>>> ds_in_microns = ds.epoch.rescale_coords("µm", coord_names=["X_Grid", "Y_Grid", "Z_Grid"])
>>>
>>> # Convert X, Y, and Z from meters to microns
>>> ds_in_microns = ds.epoch.rescale_coords("µm", coord_names=["X_Grid", "Y_Grid", "Z_Grid"], 1e6)
>>>
>>> # Convert time to femtoseconds
>>> ds_in_mm = ds.epoch.rescale_coords("fs", coord_names="time")