Source code for fibsem.autoscript

import logging

log = logging.getLogger(__name__)


[docs]def initialize(ip_address='10.0.0.1'): """Initialize connection to microscope.""" import autoscript_sdb_microscope_client from autoscript_sdb_microscope_client import SdbMicroscopeClient microscope = SdbMicroscopeClient() microscope.connect(ip_address) microscope.imaging.set_active_view(2) # the ion beam view return microscope
[docs]def patterning_engine(microscope): """Start Autoscript toolkit patterning engine.""" import autoscript_toolkit.drift_correction as dc_toolkit dcp_engine = dc_toolkit.DcPatterningEngine(microscope) return dcp_engine
[docs]def reset_patterning_state(microscope): """Reset patterning state""" from autoscript_sdb_microscope_client.enumerations import BeamType microscope.patterning.clear_patterns() microscope.patterning.set_default_application_file('Si') microscope.patterning.set_default_beam_type(BeamType.ION) microscope.patterning.mode = 'Serial' return microscope
[docs]def create_milling_patterns(microscope, roi_coordinates, settings): """Creates Autoscript milling patterns from a list of coordinates. Parameters ---------- microscope : Autoscript microscope object. roi_coordinates : list of lists [center_x, center_y, roi_width, roi_height, depth, theta] settings : dict User input settings from config yml file. Returns ------- patterns List containing the Autoscript milling patterns. """ import autoscript_core # need this for the ApplicationServerException print('Creating milling ROIs...') microscope = reset_patterning_state(microscope) milling_patterns = [] for coords in roi_coordinates: center_x, center_y, roi_width, roi_height, depth, theta = coords try: pattern = microscope.patterning.create_cleaning_cross_section( center_x, center_y, roi_width, roi_height, depth) pattern.overlap_x = settings['ion_beam_overlap'] pattern.overlap_y = settings['ion_beam_overlap'] pattern.rotation = theta except autoscript_core.common.ApplicationServerException: log.warn('Cannot create autoscript milling pattern because ' 'it is outside of the field of view') microscope = reset_patterning_state(microscope) return [] milling_patterns.append(pattern) return milling_patterns