boss_bench.data#
Find and read the BoSS data files.
- boss_bench.data.list_files(data_dir, kind='confinement', split='test')[source]#
List the data files of one kind and split.
- Parameters:
data_dir (str) – the folder with the downloaded files; it is searched recursively.
kind (str) –
"confinement"or"trajectory".split (str) –
"train"or"test".
- Returns:
the file paths, sorted.
- Return type:
list of str
- boss_bench.data.load(paths, fields)[source]#
Read chosen fields of every configuration in a list of files.
Every field can be read except the trajectory fields themselves:
traj_data,traj_offsetsandconfig_offsets. To load trajectories, usetrajectory.read_trajectories. Fields are returned as stored, with one row per configuration and gridded fields flattened:modB, for example, has shape(n, 15 * 41 * 41).- Parameters:
paths (list of str) – the files.
fields (list of str) – the names of the fields to read.
- Returns:
maps each field name to an array with one row per configuration, with the configurations of all files stacked in order.
- Return type:
dict
- boss_bench.data.load_record(f, config, fields=None)[source]#
Read the fields of one configuration.
Every field can be read except the trajectory fields themselves:
traj_data,traj_offsetsandconfig_offsets. To load trajectories, usetrajectory.read_trajectories. Only the requested fields are read from disk, and gridded fields are returned flattened, as stored.- Parameters:
f (h5py.File) – an open file, e.g.
h5py.File(path, "r").config (int or str) – the row index in the file or the
uuidof the configuration.fields (list of str, optional) – the names of the fields to read. By default, every field of the configuration.
- Returns:
maps each field name to its value for the configuration.
- Return type:
dict
- Raises:
KeyError – if no configuration in the file has this
uuid.