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
SimDirand 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
TimeSeriesobjects. :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
_varsdictionary which contains the location of all the files for a specific variable and reduction (asOneScalar).AllScalarsis a dictionary-like object, using the bracket notation you can access values with as TimeSeries. Alternatively, you can access the data as attributes of thefieldsattribute.- 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
variableis not available.
- Returns:
TimeSeriesof the requested variable- Return type:
- class kuibit.cactus_scalars.OneScalar(path)[source]¶
Read scalar data produced by CarpetASCII.
OneScalaris a dictionary-like object with keys the variables and values theTimeSeries.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.
OneScalarrepresents one scalar file, there can be multiple variables inside, (if it was output withone_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:
TimeSerieswith requested variable as read from file- Return type:
- 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
SimDirinstance. 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
TimeSeriesinstances.The constructor is not intended for direct use.
- Parameters:
sd (
SimDirinstance.) – Simulation directory