imas.backends.netcdf.ids_tensorizer.IDSTensorizer

class imas.backends.netcdf.ids_tensorizer.IDSTensorizer(ids: IDSToplevel, paths_to_tensorize: list[str])

Bases: object

Common functionality for tensorizing IDSs. Used in IDS2NC and util.to_xarray.

__init__(ids: IDSToplevel, paths_to_tensorize: list[str])

Initialize IDSTensorizer.

Parameters:
ids: IDSToplevel

IDSToplevel to store in the netCDF group

paths_to_tensorize: list[str]

Restrict tensorization to the provided paths. If an empty list is provided, all filled quantities in the IDS will be tensorized.

Methods

__init__(ids, paths_to_tensorize)

Initialize IDSTensorizer.

collect_filled_data()

Collect all filled data in the IDS and determine dimension sizes.

determine_data_shapes()

Determine tensorized data shapes and sparsity, save in shapes.

filter_coordinates(path)

Filter the coordinates list from NCMetadata to filled variables only.

include_coordinate_paths()

Append all paths that are coordinates of self.paths_to_tensorize

tensorize(path, fillvalue)

Tensorizes the data at the given path with the specified fill value.

Attributes

ids

IDS to tensorize.

paths_to_tensorize

List of paths to tensorize

ncmeta

NetCDF related metadata.

dimension_size

Map dimension name to its size.

filled_data

Map of IDS paths to filled data nodes.

filled_variables

Set of filled IDS variables

homogeneous_time

True iff the IDS time mode is homogeneous.

shapes

Map of IDS paths to data shape arrays.

collect_filled_data() None

Collect all filled data in the IDS and determine dimension sizes.

Results are stored in filled_data and dimension_size.

determine_data_shapes() None

Determine tensorized data shapes and sparsity, save in shapes.

dimension_size

Map dimension name to its size.

filled_data

Map of IDS paths to filled data nodes.

filled_variables

Set of filled IDS variables

filter_coordinates(path: str) str

Filter the coordinates list from NCMetadata to filled variables only.

homogeneous_time

True iff the IDS time mode is homogeneous.

ids

IDS to tensorize.

include_coordinate_paths() None

Append all paths that are coordinates of self.paths_to_tensorize

ncmeta

NetCDF related metadata.

paths_to_tensorize

List of paths to tensorize

shapes

Map of IDS paths to data shape arrays.

tensorize(path, fillvalue)

Tensorizes the data at the given path with the specified fill value.

Parameters:
path

The path to the data in the IDS.

fillvalue

The value to fill the tensor with. Can be of any type, including strings.

Returns:

A tensor filled with the data from the specified path.


Last update: 2026-01-28