Reference on kuibit.cactus_scalars

The cactus_scalars module provides simple interfaces to access time series data as output by CarpetASCII, including all the reductions.

There are multiple classes defined in this module:

  • :py:class`~.ScalarsDir` interfaces with SimDir and organizes the data according to their reduction. This is a dictionary-like object with keys the possible reduction (e.g., max, average, norm2). -

  • :py:class`~.AllScalars` takes all the files that correspond to a given reduction and organize them according to the variables they contain.

  • :py:class`~.OneScalar` represents one single scalar variable, with data that is represented as TimeSeries objects. :py:class`~.AllScalars` contains many :py:class`~.OneScalar` objects.

These are hierarchical classes, one containing the others, so one typically ends up with a series of brackets or dots to access the actual data. For example, if sim is a SimDir, sim.ts.max['rho_b'] is maximum of rho_b represented as TimeSeries.

class kuibit.cactus_scalars.AllScalars(allfiles, reduction_type)[source]

Helper class to read various types of scalar data in a list of files and properly order them. The core of this object is the _vars dictionary which contains the location of all the files for a specific variable and reduction (as OneScalar).

AllScalars is a dictionary-like object, using the bracket notation you can access values with as TimeSeries. Alternatively, you can access the data as attributes of the fields attribute.

Variables:

reduction_type – Type of reduction.

Constructor.

Parameters:
  • allfiles (list of str) – List of all the files

  • reduction_type (str) – Type of reduction.

get(key, default=None)[source]

Return variable if available, else return the default value.

Parameters:
  • key (str) – Requested variable.

  • default (any) – Returned value if variable is not available.

Returns:

TimeSeries of the requested variable

Return type:

TimeSeries

keys()[source]

Return the available variables corresponding to the given reduction.

Returns:

Variables with given reduction

Return type:

dict_keys

class kuibit.cactus_scalars.OneScalar(path)[source]

Read scalar data produced by CarpetASCII.

OneScalar is a dictionary-like object with keys the variables and values the TimeSeries.

Single variable per file or single file per group are supported. In the latter case, the header is inspected to understand the content of the file. Compressed files (gz and bz2) are supported too.

OneScalar represents one scalar file, there can be multiple variables inside, (if it was output with one_file_per_group = yes).

Variables:
  • path – Path of the file.

  • folder – Path of the folder that contains the file.

  • reduction_type – Type of reduction.

Constructor.

Here we understand what the file contains.

Parameters:

path (str) – Path of the file.

keys()[source]

Return the list of variables available.

Returns:

Variables in the file

Return type:

dict_keys

load(variable)[source]

Read file and return a TimeSeries with the requested variable.

Parameters:

variable (str) – Requested variable.

Returns:

TimeSeries with requested variable as read from file

Return type:

TimeSeries

class kuibit.cactus_scalars.ScalarsDir(sd)[source]

This class provides acces to various types of scalar data in a given simulation directory. Typically used from a SimDir instance. The different scalars are available as attributes:

Variables:
  • scalar – access to grid scalars.

  • minimum – access to minimum reduction.

  • maximum – access to maximum reduction.

  • norm1 – access to norm1 reduction.

  • norm2 – access to norm2 reduction.

  • average – access to average reduction.

  • infnorm – access to inf-norm reduction.

Each of those works as a dictionary mapping variable names to TimeSeries instances.

The constructor is not intended for direct use.

Parameters:

sd (SimDir instance.) – Simulation directory

get(key, default=None)[source]

Return a reduction if available, else return the default value.

Parameters:
  • key (str) – Requested reduction.

  • default (any) – Returned value if reduction is not available.

Returns:

Collection of all the variables with a given reduction.

Return type:

AllScalars