fixing coordTrf stuff, enhance logginh
This commit is contained in:
62
swissmx.py
62
swissmx.py
@@ -33,6 +33,17 @@ class col:
|
||||
b='\033[1m' # bold
|
||||
u='\033[4m' # underline
|
||||
|
||||
def listLoggers():
|
||||
rootlogger=logging.getLogger()
|
||||
print(rootlogger)
|
||||
for h in rootlogger.handlers:
|
||||
print(' %s'%h)
|
||||
|
||||
for nm, lgr in logging.Logger.manager.loggerDict.items():
|
||||
print('+ [%-20s] %s '%(nm, lgr))
|
||||
if not isinstance(lgr, logging.PlaceHolder):
|
||||
for h in lgr.handlers:
|
||||
print(' %s'%h)
|
||||
|
||||
class logHandler(logging.StreamHandler):
|
||||
def __init__(self):
|
||||
@@ -67,17 +78,17 @@ class logHandler(logging.StreamHandler):
|
||||
logging.basicConfig(level=logging.INFO, format='%(levelname)s:%(module)s:%(lineno)d:%(funcName)s:%(message)s',
|
||||
handlers=[logHandler()])
|
||||
|
||||
logging.getLogger('PyQt5.uic').setLevel(logging.INFO)
|
||||
logging.getLogger('requests').setLevel(logging.INFO)
|
||||
logging.getLogger('urllib3').setLevel(logging.INFO)
|
||||
logging.getLogger('paramiko').setLevel(logging.INFO)
|
||||
logging.getLogger('matplotlib').setLevel(logging.INFO)
|
||||
logging.getLogger('PIL').setLevel(logging.INFO)
|
||||
logging.getLogger('illumination').setLevel(logging.INFO)
|
||||
logging.getLogger('zoom').setLevel(logging.INFO)
|
||||
logging.getLogger('pbtools.misc.pp_comm').setLevel(logging.INFO)
|
||||
#logging.getLogger('PyQt5.uic').setLevel(logging.INFO)
|
||||
#logging.getLogger('requests').setLevel(logging.INFO)
|
||||
#logging.getLogger('urllib3').setLevel(logging.INFO)
|
||||
#logging.getLogger('paramiko').setLevel(logging.INFO)
|
||||
#logging.getLogger('matplotlib').setLevel(logging.INFO)
|
||||
#logging.getLogger('PIL').setLevel(logging.INFO)
|
||||
#logging.getLogger('illumination').setLevel(logging.INFO)
|
||||
#logging.getLogger('zoom').setLevel(logging.INFO)
|
||||
#logging.getLogger('pbtools.misc.pp_comm').setLevel(logging.INFO)
|
||||
_log = logging.getLogger("swissmx")
|
||||
#_log.setLevel(logging.INFO)
|
||||
|
||||
class col:
|
||||
d = '\033[0m' #default
|
||||
r = '\033[31m' #red
|
||||
@@ -2348,7 +2359,7 @@ Author Thierry Zamofing (thierry.zamofing@psi.ch)
|
||||
# X has inverted sign !
|
||||
# Z is in um -> therefore the offset must be multiplied with 1000 ! Z motor has opposite sign !
|
||||
#cz=f'{+p[0]:+.18g}X{-p[1]:+.18g}Y{-p[2]*1000:+.18g}'
|
||||
t=p*np.array((-1,-1,-1000))
|
||||
t=p*np.array((1,1,1000))
|
||||
cz=f'{t[0]:+.18g}X{t[1]:+.18g}Y{t[2]:+.18g}'
|
||||
else:
|
||||
trf=kwargs['trf'] # grid-coord -> motor-um
|
||||
@@ -2371,10 +2382,21 @@ Author Thierry Zamofing (thierry.zamofing@psi.ch)
|
||||
else:
|
||||
fx=f'{trf[0,0]:+.18g}X{trf[1,0]:+.18g}Y{trf[2,0]:+.18g}'
|
||||
fy=f'{trf[0,1]:+.18g}X{trf[1,1]:+.18g}Y{trf[2,1]:+.18g}'
|
||||
|
||||
_log.debug(f'pts_trf[0,:]={kwargs["pts_trf"][0, :]}')
|
||||
_log.debug(f'points[0,:]={kwargs["points"][0, :]}')
|
||||
_log.debug(f'trf=\n{trf}')
|
||||
if _log.level==logging.DEBUG:
|
||||
try: t
|
||||
except NameError: t=(np.nan,np.nan,np.nan)
|
||||
fn='/tmp/coord.log'
|
||||
_log.debug(f'write all coordinates to {fn}')
|
||||
if code_gen==0:
|
||||
xy1=np.hstack((kwargs["pts_trf"],np.ones((kwargs["pts_trf"].shape[0],1))))
|
||||
else:
|
||||
xy1=np.hstack((kwargs["points"],np.ones((kwargs["points"].shape[0],1))))
|
||||
pcz=np.matrix(((t[0],t[1],t[2])))*xy1.T
|
||||
x_y_fx_fy_cz=np.vstack((kwargs["points"].T, kwargs["pts_trf"].T, pcz)).A
|
||||
with open('/tmp/coord.log','w') as fh:
|
||||
fh.write(' x y fx fy cz\n')
|
||||
for i in range(x_y_fx_fy_cz.shape[1]):
|
||||
fh.write('%9.7g %9.7g %9.7g %9.7g %9.7g\n'%tuple(x_y_fx_fy_cz[:,i]))
|
||||
|
||||
sp.setup_coord_trf(fx, fy, cz) # reset to shape path system
|
||||
|
||||
@@ -2650,9 +2672,19 @@ if __name__=="__main__":
|
||||
#exampleCmd=('', '-m0xf -v0')
|
||||
epilog=__doc__ #+'\nExamples:'+''.join(map(lambda s:cmd+s, exampleCmd))+'\n'
|
||||
parser=argparse.ArgumentParser(epilog=epilog, formatter_class=argparse.RawDescriptionHelpFormatter)
|
||||
parser.add_argument('-l', '--log', type=int, help='debug(1)|info(2)|warn(3)|error(4) default=%(default)d', default=2)
|
||||
parser.add_argument("--sim", "-s", type=lambda x: int(x,0), help="simulate devices (see bitmasks) default=0x%(default)x", default=0)
|
||||
args = parser.parse_args()
|
||||
_log.info('Arguments:{}'.format(args.__dict__))
|
||||
if args.log!=2:
|
||||
for l in ('app_config', 'app_utils', 'backlight', 'camera', 'epics_widgets',
|
||||
'geometry', 'illumination', 'ModuleFixTarget', 'MXMotion',
|
||||
'pbtools', 'psi_device', 'pyqtUsrObj', 'shapepath', 'swissmx', 'zoom',):
|
||||
try:
|
||||
logging.getLogger(l).setLevel(args.log*10)
|
||||
except BaseException as e:
|
||||
_log.error(f'failed set log level ({l}): {e}')
|
||||
if args.log<2: listLoggers()
|
||||
|
||||
from PyQt5.QtWidgets import QApplication
|
||||
|
||||
|
||||
Reference in New Issue
Block a user