bag.io.sim_data

This module handles simulation data related IO.

Note : when reading data files, we use Numpy to handle the encodings, so BAG encoding settings will not apply.

Module Contents

Classes

SweepArray

Subclass of numpy array that adds sweep parameters attribute.

Functions

_get_sweep_params(fname)

Parse the sweep information file and reverse engineer sweep parameters.

load_sim_results(save_dir)

Load exported simulation results from the given directory.

save_sim_results(results, fname[, compression])

Saves the given simulation results dictionary as a HDF5 file.

load_sim_file(fname)

Read simulation results from HDF5 file.

Attributes

illegal_var_name

bag.io.sim_data.illegal_var_name = ['sweep_params'][source]
class bag.io.sim_data.SweepArray(shape, dtype=float, buffer=None, offset=0, strides=None, order=None)[source]

Bases: numpy.ndarray

Subclass of numpy array that adds sweep parameters attribute.

__array_finalize__(obj)[source]
__reduce__()[source]

Helper for pickle.

__setstate__(state)[source]
bag.io.sim_data._get_sweep_params(fname)[source]

Parse the sweep information file and reverse engineer sweep parameters.

Parameters:

fname (str) – the sweep information file name.

Returns:

  • swp_list (list[str]) – list of sweep parameter names. index 0 is the outer-most loop.

  • values_list (list[list[float or str]]) – list of values list for each sweep parameter.

bag.io.sim_data.load_sim_results(save_dir)[source]

Load exported simulation results from the given directory.

Parameters:

save_dir (str) – the save directory path.

Returns:

results – the simulation data dictionary.

most keys in result is either a sweep parameter or an output signal. the values are the corresponding data as a numpy array. In addition, results has a key called ‘sweep_params’, which contains a dictionary from output signal name to a list of sweep parameters of that output.

Return type:

dict[str, any]

bag.io.sim_data.save_sim_results(results, fname, compression='gzip')[source]

Saves the given simulation results dictionary as a HDF5 file.

Parameters:
  • results (dict[string, any]) – the results dictionary.

  • fname (str) – the file to save results to.

  • compression (str) – HDF5 compression method. Defaults to ‘gzip’.

bag.io.sim_data.load_sim_file(fname)[source]

Read simulation results from HDF5 file.

Parameters:

fname (str) – the file to read.

Returns:

results – the result dictionary.

Return type:

dict[str, any]