Add focussing_app function (focus_app.py) to standardize end-user applications, Rewrite focussing applications

This commit is contained in:
2024-10-11 15:41:07 +03:00
parent 281beba65a
commit 2113f87eed
6 changed files with 289 additions and 2 deletions

60
focus_seq_FLI.py Executable file
View File

@@ -0,0 +1,60 @@
#!/usr/bin/python
#
# Get sequence of focussing images and
# compute the best focus value
#
# This variant of the script uses Eddy Emelianov's
# 'fli_control' executable
#
from OBSUTILS import focussing_app
import sys
import argparse as ap
import subprocess as sp
import numpy as np
import pathlib as pl
# --- FLI-hardware related (ROBOTEL variant)
def set_focus(foc_val):
cmd = ["fli_control", "-g", str(int(foc_val))]
ret = sp.run(cmd, stdout=sp.PIPE, stderr=sp.PIPE)
return ret.returncode
def get_image(filename, exp_time):
#
# Eddy's 'fli_control' related stub:
# filename is expected in form 'rootname_DDDD.ext'
# convert it to 'rootname'
#
fname = str(filename).split("_")
fname = fname[0]
cmd = [
"fli_control",
"-r",
"/tmp/10micron.fitsheader",
"-x",
"{:d}".format(np.round(exp_time * 1000)), # to microseconds
fname,
]
ret = sp.run(cmd, stdout=sp.PIPE, stderr=sp.PIPE)
return ret.returncode
if __name__ == "__main__":
parser = ap.ArgumentParser(
prog="{}".format(pl.Path(sys.argv[0]).name),
description="FLI CCD and focuser hardware: focussing sequence implementation. It is assumed that 'fli_control' software is installed in the OS.",
)
ret = focussing_app(parser, set_focus, get_image)
sys.exit(ret)