From eae0f83f5b94c1b599a942ecc69283467f1798ef Mon Sep 17 00:00:00 2001 From: swittl <simon.wittl@th-deg.de> Date: Thu, 20 Mar 2025 14:01:28 +0100 Subject: [PATCH] add example 5 --- examples/05_save_h5.py | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 examples/05_save_h5.py diff --git a/examples/05_save_h5.py b/examples/05_save_h5.py new file mode 100644 index 0000000..58adc64 --- /dev/null +++ b/examples/05_save_h5.py @@ -0,0 +1,31 @@ +from artist_pythonlib import API +from artist_pythonlib.trajectory import circular_trajectory +from pathlib import Path +import numpy as np + +NUMBER_OF_PROJECTIONS = 200 + +def main(): + # Initialize the api. + artist_api = API() + + # Save Folder + save_folder = Path('./workspace') + save_folder.mkdir(exist_ok=True) + + # Save image / Save images and load them is fastern than to send the images via the rc connection. + trajectory = circular_trajectory(500., 1000., NUMBER_OF_PROJECTIONS) + api = API() + + for i in range(NUMBER_OF_PROJECTIONS): + source, detector, rotation_matrix = trajectory[0][i], trajectory[1][i], trajectory[2][i] + + api.translate('S', *source + 3 * (0.5 - np.random.random(3))) + api.translate('D', *detector + 3 * (0.5 - np.random.random(3))) + api.rotate_from_rotation_matrix('S', rotation_matrix) + api.rotate_from_rotation_matrix('D', rotation_matrix) + + artist_api.save_hdf5(save_folder / 'smurf.h5') + +if __name__ == '__main__': + main() \ No newline at end of file -- GitLab