diff --git a/src/instamatic/TEMController/TEMController.py b/src/instamatic/TEMController/TEMController.py index a3cb09b5..1de98d3c 100644 --- a/src/instamatic/TEMController/TEMController.py +++ b/src/instamatic/TEMController/TEMController.py @@ -645,7 +645,7 @@ def get_image(self, # k['ImageRotation'] = config.calibration[mode]['rotation'][mag] h['ImageComment'] = comment h['ImageCameraName'] = self.cam.name - h['ImageCameraDimensions'] = self.cam.getCameraDimensions() + h['ImageCameraDimensions'] = self.cam.get_camera_dimensions() if verbose: print(f'Image acquired - shape: {arr.shape}, size: {arr.nbytes / 1024:.0f} kB') diff --git a/src/instamatic/calibrate/calibrate_beamshift.py b/src/instamatic/calibrate/calibrate_beamshift.py index ac8e41d6..de72e28e 100644 --- a/src/instamatic/calibrate/calibrate_beamshift.py +++ b/src/instamatic/calibrate/calibrate_beamshift.py @@ -105,7 +105,7 @@ def plot(self, to_file=None, outdir=''): def center(self, ctrl): """Return beamshift values to center the beam in the frame.""" - pixel_center = [val / 2.0 for val in ctrl.cam.getImageDimensions()] + pixel_center = [val / 2.0 for val in ctrl.cam.get_image_dimensions()] beamshift = self.pixelcoord_to_beamshift(pixel_center) if ctrl: diff --git a/src/instamatic/calibrate/calibrate_stagematrix.py b/src/instamatic/calibrate/calibrate_stagematrix.py index b6ba80e6..01abc311 100644 --- a/src/instamatic/calibrate/calibrate_stagematrix.py +++ b/src/instamatic/calibrate/calibrate_stagematrix.py @@ -293,7 +293,7 @@ def calibrate_stage(ctrl, print(f'\nCalibrating stagematrix mode=`{mode}` mag={mag}\n') - camera_shape = ctrl.cam.getCameraDimensions() + camera_shape = ctrl.cam.get_camera_dimensions() pixelsize = config.calibration[mode]['pixelsize'][mag] if pixelsize == 1.0 or pixelsize == 0.0: diff --git a/src/instamatic/camera/camera_client.py b/src/instamatic/camera/camera_client.py index e8c02c8a..a327b1f8 100644 --- a/src/instamatic/camera/camera_client.py +++ b/src/instamatic/camera/camera_client.py @@ -83,7 +83,7 @@ def __init__( atexit.register(self.s.close) - xres, yres = self.getImageDimensions() + xres, yres = self.get_image_dimensions() bitdepth = 4 self._imagebufsize = bitdepth * xres * yres + self._bufsize diff --git a/src/instamatic/camera/camera_emmenu.py b/src/instamatic/camera/camera_emmenu.py index d114dbc9..3e6c3302 100644 --- a/src/instamatic/camera/camera_emmenu.py +++ b/src/instamatic/camera/camera_emmenu.py @@ -334,19 +334,19 @@ def getImageDataByIndex(self, img_index: int, drc_index: int = None) -> 'np.arra return np.array(arr) - def getCameraDimensions(self) -> (int, int): + def get_camera_dimensions(self) -> (int, int): """Get the maximum dimensions reported by the camera.""" # cfg = self.getCurrentConfig() # return cfg.DimensionX, cfg.DimensionY return self._cam.RealSizeX, self._cam.RealSizeY # return self._cam.MaximumSizeX, self._cam.MaximumSizeY - def getImageDimensions(self) -> (int, int): + def get_image_dimensions(self) -> (int, int): """Get the dimensions of the image.""" binning = self.get_binning() return int(self._cam.RealSizeX / binning), int(self._cam.RealSizeY / binning) - def getPhysicalPixelsize(self) -> (int, int): + def get_physical_pixelsize(self) -> (int, int): """Returns the physical pixel size of the camera nanometers.""" return self._cam.PixelSizeX, self._cam.PixelSizeY diff --git a/src/instamatic/camera/camera_gatan.py b/src/instamatic/camera/camera_gatan.py index dca43895..fbf4e5c8 100644 --- a/src/instamatic/camera/camera_gatan.py +++ b/src/instamatic/camera/camera_gatan.py @@ -135,7 +135,7 @@ def __init__(self, name: str = 'gatan'): msg = f'Camera {self.getName()} initialized' logger.info(msg) - # dim_x, dim_y = self.getImageDimensions() + # dim_x, dim_y = self.get_image_dimensions() # print(f"Dimensions {dim_x}x{dim_y}") # print(f"Info {self.isCameraInfoAvailable()} | Count {self.getCameraCount()}") @@ -199,7 +199,7 @@ def isCameraInfoAvailable(self) -> bool: """Return the status of the camera.""" return self._isCameraInfoAvailable() - def getCameraDimensions(self) -> (int, int): + def get_camera_dimensions(self) -> (int, int): """Return the dimensions reported by the camera.""" pnWidth = c_int(0) pnHeight = c_int(0) diff --git a/src/instamatic/camera/camera_gatan2.py b/src/instamatic/camera/camera_gatan2.py index 64aa7059..de0ae80e 100644 --- a/src/instamatic/camera/camera_gatan2.py +++ b/src/instamatic/camera/camera_gatan2.py @@ -49,17 +49,17 @@ def getDMVersion(self) -> str: """Get the version number of DM.""" return self.g.GetDMVersion() - def getCameraDimensions(self) -> (int, int): + def get_camera_dimensions(self) -> (int, int): """Get the maximum dimensions reported by the camera.""" raise NotImplementedError - def getImageDimensions(self) -> (int, int): + def get_image_dimensions(self) -> (int, int): """Get the dimensions of the image.""" binning = self.get_binning() - dim_x, dim_y = self.getCameraDimensions() + dim_x, dim_y = self.get_camera_dimensions() return int(dim_x / binning), int(dim_y / binning) - def getPhysicalPixelsize(self) -> (int, int): + def get_physical_pixelsize(self) -> (int, int): """Returns the physical pixel size of the camera nanometers.""" raise NotImplementedError diff --git a/src/instamatic/camera/camera_merlin.py b/src/instamatic/camera/camera_merlin.py index f8aa4de1..e5070aae 100644 --- a/src/instamatic/camera/camera_merlin.py +++ b/src/instamatic/camera/camera_merlin.py @@ -342,17 +342,17 @@ def isCameraInfoAvailable(self) -> bool: """Check if the camera is available.""" return True - def getImageDimensions(self) -> (int, int): + def get_image_dimensions(self) -> (int, int): """Get the binned dimensions reported by the camera.""" binning = self.get_binning() - dim_x, dim_y = self.getCameraDimensions() + dim_x, dim_y = self.get_camera_dimensions() dim_x = int(dim_x / binning) dim_y = int(dim_y / binning) return dim_x, dim_y - def getCameraDimensions(self) -> (int, int): + def get_camera_dimensions(self) -> (int, int): """Get the dimensions reported by the camera.""" return self.dimensions diff --git a/src/instamatic/camera/camera_serval.py b/src/instamatic/camera/camera_serval.py index 09952090..a0f9c212 100644 --- a/src/instamatic/camera/camera_serval.py +++ b/src/instamatic/camera/camera_serval.py @@ -98,17 +98,17 @@ def getMovie(self, n_frames, exposure=None, binsize=None, **kwargs): return arr - def getImageDimensions(self) -> (int, int): + def get_image_dimensions(self) -> (int, int): """Get the binned dimensions reported by the camera.""" binning = self.get_binning() - dim_x, dim_y = self.getCameraDimensions() + dim_x, dim_y = self.get_camera_dimensions() dim_x = int(dim_x / binning) dim_y = int(dim_y / binning) return dim_x, dim_y - def getCameraDimensions(self) -> (int, int): + def get_camera_dimensions(self) -> (int, int): """Get the dimensions reported by the camera.""" return self.dimensions diff --git a/src/instamatic/camera/camera_simu.py b/src/instamatic/camera/camera_simu.py index 52af4002..084a8a17 100644 --- a/src/instamatic/camera/camera_simu.py +++ b/src/instamatic/camera/camera_simu.py @@ -62,7 +62,7 @@ def get_image(self, exposure=None, binsize=None, **kwargs) -> np.ndarray: if not binsize: binsize = self.default_binsize - dim_x, dim_y = self.getCameraDimensions() + dim_x, dim_y = self.get_camera_dimensions() dim_x = int(dim_x / binsize) dim_y = int(dim_y / binsize) @@ -100,17 +100,17 @@ def isCameraInfoAvailable(self) -> bool: """Check if the camera is available.""" return True - def getImageDimensions(self) -> (int, int): + def get_image_dimensions(self) -> (int, int): """Get the binned dimensions reported by the camera.""" binning = self.get_binning() - dim_x, dim_y = self.getCameraDimensions() + dim_x, dim_y = self.get_camera_dimensions() dim_x = int(dim_x / binning) dim_y = int(dim_y / binning) return dim_x, dim_y - def getCameraDimensions(self) -> (int, int): + def get_camera_dimensions(self) -> (int, int): """Get the dimensions reported by the camera.""" return self.dimensions diff --git a/src/instamatic/camera/camera_timepix.py b/src/instamatic/camera/camera_timepix.py index 013ba52f..b41fe502 100644 --- a/src/instamatic/camera/camera_timepix.py +++ b/src/instamatic/camera/camera_timepix.py @@ -293,7 +293,7 @@ def get_image(self, exposure): def getName(self): return 'timepix' - def getCameraDimensions(self) -> (int, int): + def get_camera_dimensions(self) -> (int, int): return self.dimensions def load_defaults(self): @@ -332,7 +332,7 @@ def initialize(config, name='pytimepix'): cam.readPixelsCfg(pixelsCfg) cam.readRealDacs(realDacs) - print(f'Camera {cam.getName()} initialized (resolution: {cam.getCameraDimensions()})') + print(f'Camera {cam.getName()} initialized (resolution: {cam.get_camera_dimensions()})') return cam diff --git a/src/instamatic/experiments/autocred/experiment.py b/src/instamatic/experiments/autocred/experiment.py index 72bef4dd..745b3ff9 100644 --- a/src/instamatic/experiments/autocred/experiment.py +++ b/src/instamatic/experiments/autocred/experiment.py @@ -992,7 +992,7 @@ def update_referencepoint_bs(self, bs, br): def raster_scan(self): from instamatic.experiments.serialed.experiment import get_offsets_in_scan_area pixelsize_mag1 = config.calibration['mag1']['pixelsize'][self.magnification] / 1000 # nm -> um - xdim, ydim = self.ctrl.getCameraDimensions() + xdim, ydim = self.ctrl.cam.get_camera_dimensions() box_x, box_y = self.pixelsize_mag1 * xdim, self.pixelsize_mag1 * ydim # Make negative to reflect config change 2019-07-03 to make omega more in line with other software diff --git a/src/instamatic/experiments/cred_tvips/experiment.py b/src/instamatic/experiments/cred_tvips/experiment.py index 7a95e0d2..3482c696 100644 --- a/src/instamatic/experiments/cred_tvips/experiment.py +++ b/src/instamatic/experiments/cred_tvips/experiment.py @@ -464,8 +464,8 @@ def log_end_status(self): physical_pixelsize = config.camera.physical_pixelsize # mm binning = self.emmenu.get_binning() - image_dimensions_x, image_dimensions_y = self.emmenu.getImageDimensions() - camera_dimensions_x, camera_dimensions_y = self.emmenu.getCameraDimensions() + image_dimensions_x, image_dimensions_y = self.emmenu.get_image_dimensions() + camera_dimensions_x, camera_dimensions_y = self.emmenu.get_camera_dimensions() pixelsize *= binning physical_pixelsize *= binning diff --git a/src/instamatic/experiments/serialed/experiment.py b/src/instamatic/experiments/serialed/experiment.py index e52b8acb..6ccd3a63 100644 --- a/src/instamatic/experiments/serialed/experiment.py +++ b/src/instamatic/experiments/serialed/experiment.py @@ -213,7 +213,7 @@ def load_calibration(self, **kwargs): self.log.info('Brightness=%s', self.ctrl.brightness) self.pixelsize_mag1 = config.calibration['mag1']['pixelsize'][self.magnification] / 1000 # nm -> um - xdim, ydim = self.ctrl.cam.getCameraDimensions() + xdim, ydim = self.ctrl.cam.get_camera_dimensions() self.image_dimensions = self.pixelsize_mag1 * xdim, self.pixelsize_mag1 * ydim self.log.info('Image dimensions %s', self.image_dimensions) diff --git a/src/instamatic/gridmontage.py b/src/instamatic/gridmontage.py index 44569001..9fe40937 100644 --- a/src/instamatic/gridmontage.py +++ b/src/instamatic/gridmontage.py @@ -59,7 +59,7 @@ def setup(self, if not binning: binning = self.ctrl.cam.get_binning() - res_x, res_y = self.ctrl.cam.getImageDimensions() + res_x, res_y = self.ctrl.cam.get_image_dimensions() overlap_x = int(res_x * overlap) overlap_y = int(res_y * overlap) diff --git a/tests/test_camera.py b/tests/test_camera.py index e0bf6c0a..e3fde796 100644 --- a/tests/test_camera.py +++ b/tests/test_camera.py @@ -19,6 +19,6 @@ def test_get_image(ctrl): def test_functions(ctrl): - dims = ctrl.cam.getImageDimensions() + dims = ctrl.cam.get_image_dimensions() assert isinstance(dims, tuple) assert len(dims) == 2