fluiddyn.util.serieofarrays
Serie of arrays
Provides classes to iterate over numbered files in a directory:
- class fluiddyn.util.serieofarrays.SerieOfArrays(path)[source]
Bases:
object
Serie of arrays used for post-processing.
- Parameters:
- pathstr
The path of the base directory or of a file example.
- Attributes:
- pathstr
The path of the base directory.
- class fluiddyn.util.serieofarrays.SerieOfArraysFromFiles(path, slicing=None)[source]
Bases:
SerieOfArrays
Serie of arrays saved in files (images, netcdf, etc.).
- Parameters:
- pathstr
The path of the base directory or of a file example.
- slicingNone or iterable of iterables or str
Iterable of slides (start, stop, step).
Can also be a string of the form “0:2:6, 1” (in this case for two indexes).
- Attributes:
- path_dirstr
The path of the base directory.
- get_slicing_tuples/set_slicing_tupleslist of tuples
Lists of slicing tuples “(start, stop, step)” (one for each index). This list can be changed to loop over different sets of files.
Notes
An instance of SerieOfArraysFromFiles is an iterable and provides other iterables.
Use the function
set_slicing_tuples()
to specify the files over which iterate.- get_array_from_indices(*indices)[source]
Get an array from its indices.
- Parameters:
- *indices
As many indices as used in the serie. For example with names of the form ‘im100a.png’, 2 indices are needed.
- get_tuples_indices()[source]
Get a list of tuples containing the indices computed from self._slicing_tuples
- get_array_from_index(index)[source]
Get the ith array of the serie.
- Parameters:
- index: int
Index of the array, for example 0 to get the first array.
- get_path_files()[source]
Get all paths of the serie.
If the serie is formed from arrays in one file, only one path is given.
- get_path_arrays()[source]
Get all paths of the arrays of the serie.
If the serie is formed from arrays in one file,
len(path) == len(arrays)
.
- get_str_for_name_from_idim_idx(idim, idx)[source]
Compute the str corresponding to the index
idx
for the dimensionidim
- compute_str_indices_from_indices(*indices)[source]
Compute the string corresponding to the indices.
- Parameters:
- indices: iterable of int.
- compute_name_from_indices(*indices)[source]
Compute a file name from a list of indices.
- Parameters:
- indices: iterable of int.
- compute_indices_from_name(name)[source]
Compute a list of indices from a file name.
- Parameters:
- name: str
Name of the array.
- get_slicing_tuples_all_files()[source]
Get nb_indices “slices” (to get all the arrays in the directory).
The “slices” are tuples of size 1 (
(start,)
), 2 ((start, stop)
) or 3 ((start, stop, step)
).
- get_slicing_tuples()[source]
Get nb_indices “slices” to get all the arrays of the serie.
The “slices” are tuples of size 1 (
(start,)
), 2 ((start, stop)
) or 3 ((start, stop, step)
).
- set_slicing_tuples(*slicing_tuples)[source]
Set the (nb_indices) “slicing tuples”.
The “slicing tuples” are tuples of size 1 (
(start,)
), 2 ((start, stop)
) or 3 ((start, stop, step)
).
- get_index_slices()
Get nb_indices “slices” to get all the arrays of the serie.
The “slices” are tuples of size 1 (
(start,)
), 2 ((start, stop)
) or 3 ((start, stop, step)
).
- get_index_slices_all_files()
Get nb_indices “slices” (to get all the arrays in the directory).
The “slices” are tuples of size 1 (
(start,)
), 2 ((start, stop)
) or 3 ((start, stop, step)
).
- set_index_slices(*slicing_tuples)
Set the (nb_indices) “slicing tuples”.
The “slicing tuples” are tuples of size 1 (
(start,)
), 2 ((start, stop)
) or 3 ((start, stop, step)
).
- set_index_slices_from_str(str_slices)
Set slicing_tuples from a string.
- class fluiddyn.util.serieofarrays.SeriesOfArrays(serie, slicing_tuples_from_indserie=None, ind_start='first', ind_stop=None, ind_step=1)[source]
Bases:
object
Series of arrays.
This class can be used to produce series of arrays from a
SerieOfArrays
.- Parameters:
- serie: SerieOfArrays or str
- slicing_tuples_from_indserie: str or function
The function has to take an integer and to return an iterable of “slicing tuples” used to compute a file name.
Functions
|
Add a depreciated function like get_index_slices |
|
Return a tuple of slices |
|
Classes
|
Serie of arrays used for post-processing. |
|
Serie of arrays saved in files (images, netcdf, etc.). |
|
Series of arrays. |
|
|
|
Exceptions
|
Specific IndexError |