59 lines
1.3 KiB
Python
Executable File
59 lines
1.3 KiB
Python
Executable File
#!/usr/bin/python
|
|
|
|
#
|
|
# Compute the best focus value from sequence of FITS images
|
|
#
|
|
|
|
|
|
import OBSUTILS as obsutil
|
|
import argparse as ap
|
|
import sys
|
|
|
|
if __name__ == "__main__":
|
|
parser = ap.ArgumentParser(prog=sys.argv[0])
|
|
|
|
parser.add_argument(
|
|
"files", help="Acquired FITS image filenames of focussing sequence", nargs="*"
|
|
)
|
|
|
|
parser.add_argument(
|
|
"-v", "--verbose", help="Verbose output", action="store_true", default=False
|
|
)
|
|
|
|
parser = obsutil.getFocusCalcCmdlinePars(parser)
|
|
|
|
args = parser.parse_args()
|
|
|
|
log = []
|
|
foc_kwds = obsutil.parsFocusCalcCmdlinePars(args, log)
|
|
|
|
if args.verbose:
|
|
if len(log):
|
|
for log_str in log:
|
|
print(log_str)
|
|
|
|
if args.verbose:
|
|
print("START FOCUS MEASUREMENT: \n")
|
|
|
|
if args.verbose:
|
|
result = obsutil.computeFocus(args.files, log_output=sys.stdout, **foc_kwds)
|
|
else:
|
|
result = obsutil.computeFocus(args.files, log_output=None, **foc_kwds)
|
|
|
|
# if args.verbose:
|
|
# for log_str in result["log"]:
|
|
# print("\t", log_str)
|
|
|
|
if result["ret_code"] != 0:
|
|
if args.verbose:
|
|
print("\nFAIL!")
|
|
sys.exit(result["ret_code"])
|
|
|
|
if args.verbose:
|
|
print("\nALL DONE")
|
|
|
|
if not args.verbose:
|
|
print("best focus value is {:g}".format(result["focus_value"]))
|
|
|
|
sys.exit(0)
|