pysdic.SDICAnalysis.to_folder#
- SDICAnalysis.to_folder(folder, *, overwrite=False, make_dirs=False, title=None, description=None, export_vtk=False)[source]#
Save the analysis in a folder, one file per atom, to reload it exactly with
from_folder().The folder contains:
folder/ ├── metadata.json format, pysdic version, date, title, description, summary ├── README.txt the same information, readable by a human ├── manifest.json SHA-256 of all the files (checked at the loading) ├── structure.json cameras, views and frames as indices of the atoms, │ and the structures of the analysis ├── mesh/mesh.npz the reference mesh (+ mesh.vtk if export_vtk=True) ├── images/image_0000.npz one per distinct image (data and settings) ├── extrinsics/extrinsic_0000.json one per distinct transformation of each kind ├── distortions/distortion_0000.json ├── intrinsics/intrinsic_0000.json ├── displacements.npz keys frame_0000, ... (only the frames with a displacement) └── times.npz key "times" (only if the times are defined)
Each distinct object (image, transformation) is saved once, even if it is shared by several views or cameras:
from_folder()restores the same sharing. The indices of the file names have the number of digits of the largest index (for example 4 digits for 1543 frames).The save is safe: the content is written in a temporary folder next to
folder, which is renamed at the end. If an error occurs, the temporary folder is removed and an existingfolderis unchanged.Note
The integration points and the pairings are not part of the analysis: save them separately (for example with
integration_points.to_npz_file).- Parameters:
folder (Union[str, os.PathLike]) – The folder to create.
overwrite (bool, optional (default:
False)) – If True, an existing folder is replaced, only if it is a SDIC save (it has ametadata.jsonof this format): a folder with other content is never deleted. It is removed only after the new save is complete.make_dirs (bool, optional (default:
False)) – If True, the missing parent folders are created.title (Optional[str], optional) – A title written in the metadata.
description (Optional[str], optional) – A description written in the metadata.
export_vtk (bool, optional (default:
False)) – If True, the mesh is also exported tomesh/mesh.vtk(binary, with its properties) to be visualized, for example in ParaView. This file is not used byfrom_folder(). Requires the VTK dependencies ofpysdic.Mesh.to_vtk_file().
- Raises:
FileExistsError – If
folderexists andoverwriteis False, or if it exists but is not a SDIC save.FileNotFoundError – If the parent folder does not exist and
make_dirsis False.
- Return type:
None
Examples
analysis.to_folder("results/test_42", title="Tensile test 42") same_sdic = SDICAnalysis.from_folder("results/test_42")