aurel.reading
reading.py
This module contains functions to read/write data, and has specific functions for using data generated from Einstein Toolkit simulations. This includes:
reading parameters from the simulation
listing available iterations of the simulation
reading data from the simulation output files
joining chunks of data together
fixing the x-z indexing of the data
saving data to files
Note
Users should first provide the path to their simulations:
export SIMLOC=”/path/to/simulations/”
- aurel.reading.bash(command)[source]
Run a bash command and return the output as a string.
- Parameters:
command (str) – The bash command to run.
- Returns:
The output of the command as a string.
- Return type:
str
- aurel.reading.iterations(param, skip_last=True)[source]
Lists available iterations of the simulation’s 3D output files.
Prints available iterations on screen and records this in a file called iterations.txt in the simulation directory.
- Parameters:
param (dict) – The parameters of the simulation.
skip_last (bool, optional) – If True, skip the last restart. The default is True. This is to not mess with things in case they’re still running.
- aurel.reading.join_chunks(cut_data, **kwargs)[source]
Join the chunks of data together.
- Parameters:
cut_data (dict of dict) – A dictionary containing the data from the simulation output files. dict.keys() = tuple of the chunks ‘iorigin’ attribute which maps out how the data is to be joined together.
veryverbose (bool, optional) – If True, print additional information during the joining process. The default is False.
- Returns:
uncut_data – The data now joined together.
- Return type:
array_like
- aurel.reading.parameters(simname)[source]
Read the parameters from the simulation.
This also counts the number of restarts, and calculates the size and number of grid points in each direction of the simulation box.
- Parameters:
simname (str) – The name of the simulation to read the parameters from.
- Returns:
A dictionary containing the parameters of the simulation.
- Return type:
dict
Note
Users should first provide the path to their simulations:
export SIMLOC=”/path/to/simulations/”
- aurel.reading.read_ET_data(param, var, **kwargs)[source]
Read the data from Einstein Toolkit simulation output files.
- Parameters:
param (dict) – The parameters of the simulation.
var (list) – The variables to read from the simulation output files.
it (list, optional) – The iterations to save from the data. The default is [0].
rl (int, optional) – The refinement level to read from the simulation output files. The default is 0.
restart (int, optional) – The restart number to save the data to. The default is 0.
veryverbose (bool, optional) – If True, print additional information during the joining process. The default is False.
- Returns:
A dictionary containing the data from the simulation output files. dict.keys() = [‘it’, ‘t’, var[0], var[1], …]
- Return type:
dict
- aurel.reading.read_ET_var(path, filename, varkey, cmax, rank, **kwargs)[source]
Read variables from Einstein Toolkit simulation output files.
- Parameters:
path (str) – The path to the simulation output files.
filename (str) – Identifying part of the variable output file name.
varkey (str) – Identifying part of the variable’s hdf5 key.
cmax (int) – The maximum number of chunks to read from the simulation output files. If ‘in file’, it will be extracted from the file.
rank (int) – The rank of the variable to read from the simulation output files. 0 scalar, 1 vector, 2 tensor.
it (list, optional) – The iterations to save from the data. The default is [0].
rl (int, optional) – The refinement level to read from the simulation output files. The default is 0.
veryverbose (bool, optional) – If True, print additional information during the joining process. The default is False.
- Returns:
A dictionary containing the data from the simulation output files.
dict.keys() = [‘it’, ‘t’, var]
- Return type:
dict
- aurel.reading.read_aurel_data(param, var, **kwargs)[source]
Read the data from AurelCore simulation output files.
- Parameters:
param (dict) – The parameters of the simulation.
var (list) – The variables to read from the simulation output files.
it (list, optional) – The iterations to read from the simulation output files. The default is [0].
rl (int, optional) – The refinement level to read from the simulation output files. The default is 0.
restart (int, optional) – The restart number to read from the simulation output files. The default is 0.
- Returns:
A dictionary containing the data from the simulation output files. dict.keys() = [‘it’, ‘t’, var[0], var[1], …]
- Return type:
dict
- aurel.reading.read_data(param, var, **kwargs)[source]
Read the data from the simulation output files.
- Parameters:
param (dict) – The parameters of the simulation.
var (list) – The variables to read from the simulation output files.
it (list, optional) – The iterations to read from the simulation output files. The default is [0].
rl (int, optional) – The refinement level to read from the simulation output files. The default is 0.
restart (int, optional) – The restart number to save the data to. The default is 0.
split_per_it (bool, optional) – If True, if possible read the data from the split iterations. Complete request ET files and save variables in individual files per iteration. Else just read ET files.
verbose (bool, optional) – If True, print additional information during the reading process.
veryverbose (bool, optional) – If True, print even more information during the reading process.
- Returns:
A dictionary containing the data from the simulation output files. dict.keys() = [‘it’, ‘t’, var[0], var[1], …]
- Return type:
dict
- aurel.reading.save_data(param, data, **kwargs)[source]
Save the data to a file
- Parameters:
param (dict) – The parameters of the simulation. Needs to contain the key ‘datapath’, this is where the data will be saved.
data (dict) – The data to be saved. dict.keys() = [‘it’, ‘t’, var[0], var[1], …]
vars (list, optional) – The variables to save from the data. If not provided, all variables in data will be saved. The default is [].
it (list, optional) – The iterations to save from the data. The default is [0].
rl (int, optional) – The refinement level to save from the data. The default is 0.
restart (int, optional) – The restart number to save the data to. The default is 0.
Note
The data will be saved in the format: datapath/it_<iteration>.hdf5 where <iteration> is the iteration number. The variables will be saved as datasets in the file, with keys ‘<variable_name> rl=<refinement_level>’