Skip to content

Commit

Permalink
Snakecase get{Image,Camera}Dimensions
Browse files Browse the repository at this point in the history
  • Loading branch information
stefsmeets committed Jun 23, 2023
1 parent 4a3cb19 commit 827aff7
Show file tree
Hide file tree
Showing 16 changed files with 31 additions and 31 deletions.
2 changes: 1 addition & 1 deletion src/instamatic/TEMController/TEMController.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
2 changes: 1 addition & 1 deletion src/instamatic/calibrate/calibrate_beamshift.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion src/instamatic/calibrate/calibrate_stagematrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion src/instamatic/camera/camera_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 3 additions & 3 deletions src/instamatic/camera/camera_emmenu.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions src/instamatic/camera/camera_gatan.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()}")

Expand Down Expand Up @@ -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)
Expand Down
8 changes: 4 additions & 4 deletions src/instamatic/camera/camera_gatan2.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 3 additions & 3 deletions src/instamatic/camera/camera_merlin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 3 additions & 3 deletions src/instamatic/camera/camera_serval.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
8 changes: 4 additions & 4 deletions src/instamatic/camera/camera_simu.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions src/instamatic/camera/camera_timepix.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion src/instamatic/experiments/autocred/experiment.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/instamatic/experiments/cred_tvips/experiment.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/instamatic/experiments/serialed/experiment.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion src/instamatic/gridmontage.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion tests/test_camera.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 827aff7

Please sign in to comment.