pyfast_adt.main.fast_adt_func ============================= .. py:module:: pyfast_adt.main.fast_adt_func Functions --------- .. autoapisummary:: pyfast_adt.main.fast_adt_func.fake pyfast_adt.main.fast_adt_func.go_to pyfast_adt.main.fast_adt_func.undo pyfast_adt.main.fast_adt_func.acquire_image pyfast_adt.main.fast_adt_func.acquire_image_and_show pyfast_adt.main.fast_adt_func.get_beam_intensity pyfast_adt.main.fast_adt_func.set_image_setting pyfast_adt.main.fast_adt_func.set_diff_setting pyfast_adt.main.fast_adt_func.test_beam_shift pyfast_adt.main.fast_adt_func.calibrate_beam_shift pyfast_adt.main.fast_adt_func.acquire_tracking_images pyfast_adt.main.fast_adt_func.process_tracking_images pyfast_adt.main.fast_adt_func.reset_tracking_images pyfast_adt.main.fast_adt_func.display_crystal_tracking pyfast_adt.main.fast_adt_func.generate_tracking_file pyfast_adt.main.fast_adt_func.load_tracking_file pyfast_adt.main.fast_adt_func.initialize_beam_position pyfast_adt.main.fast_adt_func.start_experiment pyfast_adt.main.fast_adt_func.save_tracking_images pyfast_adt.main.fast_adt_func.stop_experiment pyfast_adt.main.fast_adt_func.write_report_experiment pyfast_adt.main.fast_adt_func.write_pets_file pyfast_adt.main.fast_adt_func.write_eadt_file pyfast_adt.main.fast_adt_func.raster_scanning_userbeamshift pyfast_adt.main.fast_adt_func.read_tracking_file pyfast_adt.main.fast_adt_func.write_tracking_file pyfast_adt.main.fast_adt_func.retrieve_parameters_for_acquisition pyfast_adt.main.fast_adt_func.set_parameters_gui pyfast_adt.main.fast_adt_func.rotation_speed_value pyfast_adt.main.fast_adt_func.calculate_wavelength pyfast_adt.main.fast_adt_func.load_camera_table pyfast_adt.main.fast_adt_func.image_pixelsize pyfast_adt.main.fast_adt_func.beam_shift_vs_image_calibration pyfast_adt.main.fast_adt_func.load_initial_parameters_experiment pyfast_adt.main.fast_adt_func.draw_circle_beam_shift pyfast_adt.main.fast_adt_func.to_json pyfast_adt.main.fast_adt_func.write_cam_table pyfast_adt.main.fast_adt_func.list_pix_to_beamshift_stem pyfast_adt.main.fast_adt_func.stem_mode_imaging pyfast_adt.main.fast_adt_func.evaluate_timings pyfast_adt.main.fast_adt_func.tracking_precision_run pyfast_adt.main.fast_adt_func.evaluate_tracking_precision pyfast_adt.main.fast_adt_func.overall_tracking_precision pyfast_adt.main.fast_adt_func.re_evaluate_tracking_precision pyfast_adt.main.fast_adt_func.re_evaluate_crystal_tracking_path pyfast_adt.main.fast_adt_func.semi_manual_stepwise pyfast_adt.main.fast_adt_func.display_image1 pyfast_adt.main.fast_adt_func.display_image2 pyfast_adt.main.fast_adt_func.display_image3 pyfast_adt.main.fast_adt_func.calculate_storage_capacity pyfast_adt.main.fast_adt_func.get_available_memory_gb pyfast_adt.main.fast_adt_func.automatic_eucentric_height pyfast_adt.main.fast_adt_func.backlash_data_acquisition pyfast_adt.main.fast_adt_func.calculate_shift_with_opencv pyfast_adt.main.fast_adt_func.process_images_in_folder pyfast_adt.main.fast_adt_func.re_evaluate_backlash_data pyfast_adt.main.fast_adt_func.backlash_correction_single_axis pyfast_adt.main.fast_adt_func.backlash_correction_alpha pyfast_adt.main.fast_adt_func.backlash_stage_acquisition pyfast_adt.main.fast_adt_func.evaluate_average_displacement_track_precision pyfast_adt.main.fast_adt_func.eucentric_height_z_scan pyfast_adt.main.fast_adt_func.acquire_z_scan_tem_mode pyfast_adt.main.fast_adt_func.linear_interpolation_tracking_path pyfast_adt.main.fast_adt_func.re_evaluate_manual_tracking_precision pyfast_adt.main.fast_adt_func.fit_rigid_body_model_single_dataset Module Contents --------------- .. py:function:: fake(self) .. py:function:: go_to(self) .. py:function:: undo(self) .. py:function:: acquire_image(self, exposure, binning, processing) .. py:function:: acquire_image_and_show(self, exposure, binning, processing) .. py:function:: get_beam_intensity(self) .. py:function:: set_image_setting(self) .. py:function:: set_diff_setting(self) .. py:function:: test_beam_shift(self) .. py:function:: calibrate_beam_shift(self) .. py:function:: acquire_tracking_images(self, tracking_path=None, custom_param=None) this function for continuous tracking need both the tilt step and the tracking step, because it calculate the ratio between them to grab the images. the tilt step of the final acquisition determine the velocity of the stage. for the stepwise is not important, because the velocity parameter doesn't exist. due to the fact that tilt step and exposure determine the velocity of the stage, to be consistent it's better to use the same exposure and tilt step for the final data acquisition, moreover don't have a lot of mining expose for a long time because the image will be shitty! .. py:function:: process_tracking_images(self, tracking_images, track_angles, method, visualization=False) .. py:function:: reset_tracking_images(self) .. py:function:: display_crystal_tracking(self, method) .. py:function:: generate_tracking_file(self, method, text='tracking.txt', custom_param=None) .. py:function:: load_tracking_file(self) .. py:function:: initialize_beam_position(self) .. py:function:: start_experiment(self) .. py:function:: save_tracking_images(self, buffer, saving_dir) .. py:function:: stop_experiment(self) .. py:function:: write_report_experiment(self, path, add_val=None) .. py:function:: write_pets_file(self, path, pets_default_values) pets2 file writer to run it after the acquisition .. py:function:: write_eadt_file(self, path, eadt_default_values) eadt file writer to run it after the acquisition, to finish .. py:function:: raster_scanning_userbeamshift(self, list_target=None) i don't know where put it soo will stay here for now .. py:function:: read_tracking_file(self, text) .. py:function:: write_tracking_file(self, text, start_angle, target_angle, tilt_step, rotation_speed, experiment_type, tracking_step, tracking_positions=None) .. py:function:: retrieve_parameters_for_acquisition(self, mode='acquisition') .. py:function:: set_parameters_gui(self, values) .. py:function:: rotation_speed_value(self, mode='acquisition') "FPS_function": ["678.62", "-0.943"], using this parameter of the self.cam_table, this calibration is an exponential fit of the FPS real vs exposure time(ms) (i.e 1/FPS theor). the value here come out in deg/s because compatible with fei .. py:function:: calculate_wavelength(self, voltage, from_list=False) based on https://virtuelle-experimente.de/en/elektronenbeugung/wellenlaenge/de-broglie-relativistisch.php constant took from google search, results match the relativistic wavelength in the JEOL website: https://www.jeol.com/words/emterms/20121023.071258.php#gsc.tab=0 input: voltage in kV, from_list = True if you want a table .. py:function:: load_camera_table(self) .. py:function:: image_pixelsize(self) if you are in real space return pixelsize in nm, else in A-1 (Aperpixel) .. py:function:: beam_shift_vs_image_calibration(self) .. py:function:: load_initial_parameters_experiment(self) .. py:function:: draw_circle_beam_shift(event, x, y, flags, param) .. py:function:: to_json(self, o, level=0) "from https://stackoverflow.com/questions/10097477/python-json-array-newlines?rq=3 .. py:function:: write_cam_table(self) .. py:function:: list_pix_to_beamshift_stem(self, list_target_p=None) the calibration in stem mode is handled differently wrt tem mode. here TIA is already providing the conversion between the beamshift function and the pixels in the haadf detector. .. py:function:: stem_mode_imaging(self) .. py:function:: evaluate_timings(self) .. py:function:: tracking_precision_run(self, tracking_dict) .. py:function:: evaluate_tracking_precision(self, saving, iteration, initial_tracking, second_tracking, input_param=None, output=None) sergi method to evaluate the tracking performances between 2 consecutive tracking acquisition. if iteration 1 this means we are comparing initial_scan vs 1_scan, iter 2 is 1_scan vs 2_scan and so on. .. py:function:: overall_tracking_precision(self, saving=None, output=None, output_method=None) .. py:function:: re_evaluate_tracking_precision(self) .. py:function:: re_evaluate_crystal_tracking_path(self) .. py:function:: semi_manual_stepwise(self, exp_angle, exposure, binning, processing, img_buffer, root) .. py:function:: display_image1(self, exposure, binning, processing) .. py:function:: display_image2(self) .. py:function:: display_image3(self, i, exp_angle) .. py:function:: calculate_storage_capacity(data_type=np.uint16, available_memory_gb=16) Calculate the maximum number of images that can be stored in memory for predefined resolutions and data type. Parameters: - data_type (data-type): Data type of the images, e.g., np.uint16, np.uint8. - available_memory_gb (float): Amount of memory available for storage in GB. Returns: - results (dict): Dictionary with pixels^2 as keys and a list [max_images storable, memory_per_image_mb] as values. .. py:function:: get_available_memory_gb(self) .. py:function:: automatic_eucentric_height(self) automatic fine eucentric height from D.N. Mastronarde / Journal of Structural Biology 152 (2005) 36–51 collect eight images -24 to 24 deg. image shift in y is L.S. fitted to: y=(y0 + ys)*cos(alpha)-z0*sin(alpha)-y0 to determine both z0, the Z-height, and y0, the offset between tilt and optical axes, where ys is the image shift of the specimen at zero tilt. It will work only for modest Z-height disparities (up to 10 um) and may restart after adjusting Z-height if image shifts become too large. .. py:function:: backlash_data_acquisition(self) script to perform the experiment of the 10/01/2025 for backlash characterization of the TEM goniometer .. py:function:: calculate_shift_with_opencv(self, template, image, ref_center, method=cv2.TM_CCOEFF_NORMED) Calculate the shift between a template and an image using OpenCV's matchTemplate. .. py:function:: process_images_in_folder(self, image_folder, output_folder) .. py:function:: re_evaluate_backlash_data(self) .. py:function:: backlash_correction_single_axis(self, tracking_initial_pos=None, speed=1) this function check for the 3 var for backlash correction x,y,z in the extra space. if one is ticked the backlash correction is performed for that axis, and iterate for the others. the correction is made at 0 deg alpha .. py:function:: backlash_correction_alpha(self, exp_type, start_angle, final_angle, rotation_speed=0.7, rotation_speed_cred=0.3) backlash correction can work in different ways as a function of the input parameters. 1) if stepwise is used, the correction is made by steps. instead in continuous the step is made in a single continuous step. 2) type can be chosen between 'normal' and 'high precision', this flag is chosen by a checkbox in the gui. if not ticked, the normal mode is chosen, else high precision is selected and a fake rotation its added before the acquisition to increase the reproducibility of the goniometer. .. py:function:: backlash_stage_acquisition(self) script to perform the experiment of the 29/01/2025 for backlash characterization of the TEM goniometer. the main difference wrt backlash_data_acquisition function is that here the coordinates of the stage are used instead of reference images from detectors. .. py:function:: evaluate_average_displacement_track_precision() aaaa .. py:function:: eucentric_height_z_scan(self) .. py:function:: acquire_z_scan_tem_mode(self) .. py:function:: linear_interpolation_tracking_path(self, tracking_points, tracking_timings, num_points=5) Linearly interpolates between consecutive tracking points and timestamps. :param tracking_points: List of (angle, x, y). :type tracking_points: list of tuples :param tracking_timings: List of timestamps, same length as tracking_points. :type tracking_timings: list of float :param num_points: Number of interpolated points between each pair. :type num_points: int :returns: Interpolated (angle, x, y) points including originals. interpolated_timings (list of float): Corresponding interpolated timestamps. :rtype: interpolated_path (list of tuples) .. py:function:: re_evaluate_manual_tracking_precision(self) .. py:function:: fit_rigid_body_model_single_dataset(self)