InputOutput (I/O)
IO contains classes and functions to read and write SEM data.
The main modules are:
We have developed wrapper functions that can be used to read and write data in a more user-friendly way. Here we show them:
Wrappers to ease IO
- pysemtools.io.wrappers.read_data(comm, fname: str, keys: list[str], parallel_io: bool = False, dtype=<class 'numpy.float32'>)
Read data from a file and return a dictionary with the names of the files and keys
- Parameters:
- comm, MPI.Comm
The MPI communicator
- fnamestr
The name of the file to read
- keyslist[str]
The keys to read from the file
- parallel_iobool, optional
If True, read the file in parallel, by default False. This is aimed for hdf5 files, and currently it does not work if True
- Returns:
- dict
A dictionary with the keys and the data read from the file
- pysemtools.io.wrappers.write_data(comm, fname: str, data_dict: dict[str, ~numpy.ndarray], parallel_io: bool = False, dtype=<class 'numpy.float32'>, msh: ~pysemtools.datatypes.msh.Mesh | None = None, write_mesh: bool = False)
Write data to a file
- Parameters:
- comm, MPI.Comm
The MPI communicator
- fnamestr
The name of the file to write
- data_dictdict
The data to write to the file
- parallel_iobool, optional
If True, write the file in parallel, by default False. This is aimed for hdf5 files, and currently it does not work if True
- dtypenp.dtype, optional
- mshMesh, optional
The mesh object to write to a fld file, by default None
- write_meshbool, optional
Only valid for writing fld files
Additionally, there exist a class to read probes written in the csv format. Here we show it:
- class pysemtools.io.read_probes.ProbesReader(file_name: str)
A class to read probed fields from a Neko simulation.
- Attributes:
- pointsnp.ndarray of floats
The probe locations.
- timesnp.array of floats
The times at each time step.
- field_nameslist of strings
The names of the fields.
- fieldsdictionary of np.array
The fields at each time step.