#!/usr/bin/env python # *-----------------------------------------------------------------------* # | | # | Copyright (c) 2022 by Paul Scherrer Institute (http://www.psi.ch) | # | Based on Zac great first implementation | # | Author Thierry Zamofing (thierry.zamofing@psi.ch) | # *-----------------------------------------------------------------------* ''' coordinate systems, optical center, xray axis, pixel sizes etc. ''' class gepmetry: def __init__(self): pass def find_optical_center(p): # p is an array of # at zoom out: (p1x,p1y),(p2x,p2y),(p3x,p3y),... # at zoom in : (p1x,p1y),(p2x,p2y),(p3x,p3y),... # # the pixel positions are given in chip pixel coordinates (0/0= top/right) # and ignore roi and binning # the returned (cx,cy) is the pixel koordinate that does not change with zoom # this coordinate represents also the origin of other coordinates pass def zoom2pixsz(zoom): # this returns the pixel size at a given zoom level # the returned value is a 2x2 matrix: # [pxx pxy] # [pyx pyy] which is interpolated out of a lookup table # # [pxx pxy] [nx] # [pyx pyy]*[ny] results in a vector in meter of a vector [nx,ny] pixels in x and y direction pass def set_zoom2pixsz(): #tx: 2d-vector in m when moving px pixel in x direction #ty: 2d-vector in m when moving py pixel in y direction # the _lut_z2p is dictionaty a lookuptable # zoom {1,200,400,600,800,1000} #[pxx pxy] #[pyx pyy] self._lut_z2p=_lut_z2p={ 'zoom': np.array((1,200,400,600,800,1000),dtype=np.float32), 'pixsz': np.array( #((pxx,pxy),(pyx,pyy)), # zoom n (( 1,0),(0, 1)), # zoom 1 (( 2,0),(0, 2)), # zoom 200 (( 4,0),(0, 4)), # zoom 400 (( 6,0),(0, 6)), # zoom 600 (( 8,0),(0, 8)), # zoom 800 ((10,0),(0,10)), # zoom 1000 dtype=np.float32)} def autofocus(): # cam camera object # mot motor object # rng region (min max relative to current position) to seek # n number of images to take in region # roi region of interrest to calculate sharpness # mode mode to calculate sharpness (sum/max-min/hist? of edge detection in roi) pass def pix2pos(p,zoom=None): # returns the position m(x,y) in meter relative to the optical center at a given zoom level of the pixel p(x,y) # if zoom=None, the last zoom value is used pass def pos2pix(p,zoom=None): # returns the pixel p(x,y) of the position m(x,y) in meter relative to the optical center at a given zoom level # if zoom=None, the last zoom value is used pass def optctr2xray(): # returns the vector m(x,y) of the optical center to the xray pass