def simulated_setup_from_image( filepath: str, **kwargs) -> typing.Dict[str, microscope.abc.Device]: """Create simulated devices given an image file. To use with the `device-server`:: DEVICES = [ device(simulated_setup_from_image, 'localhost', 8000, conf={'filepath': path_to_image_file}), ] """ image = np.array(PIL.Image.open(filepath)) if len(image.shape) < 3: raise ValueError("not an RGB image") stage = SimulatedStage({ "x": microscope.AxisLimits(0, image.shape[0]), "y": microscope.AxisLimits(0, image.shape[1]), "z": microscope.AxisLimits(-50, 50), }) filterwheel = SimulatedFilterWheel(positions=image.shape[2]) camera = StageAwareCamera(image, stage, filterwheel) return { "camera": camera, "filterwheel": filterwheel, "stage": stage, }
def limits(self) -> microscope.AxisLimits: min_limit = self._dev_conn.get_limit_min(self._axis) max_limit = self._dev_conn.get_limit_max(self._axis) return microscope.AxisLimits(lower=min_limit, upper=max_limit)
def limits(self) -> microscope.AxisLimits: lower = self.stage._axis_get("TMN?", self.axis) upper = self.stage._axis_get("TMX?", self.axis) return microscope.AxisLimits(lower, upper)