add init_seq_func to focussingSequence function. Add 'start_idx' key to sequenc control dictionary (see getFocusSequencePars). Rewrite aps
This commit is contained in:
39
focus_app.py
39
focus_app.py
@@ -6,9 +6,10 @@
|
||||
import OBSUTILS as obsutil
|
||||
import sys
|
||||
import numpy as np
|
||||
import pathlib as pl
|
||||
|
||||
|
||||
def focussing_app(parser, set_focus, get_image):
|
||||
def focussing_app(parser, init_seq_func, set_focus_func, get_image_func):
|
||||
"""
|
||||
Focussing sequence standard application skeleton
|
||||
|
||||
@@ -109,13 +110,29 @@ def focussing_app(parser, set_focus, get_image):
|
||||
if args.guess: # rough focus estimation
|
||||
if args.verbose:
|
||||
print("\trough focus estimation ...")
|
||||
|
||||
# add '_rough' suffixes
|
||||
seq_rough_kwds = seq_kwds.copy()
|
||||
if seq_rough_kwds["focus_curve_filename"] is not None:
|
||||
pt = pl.Path(seq_rough_kwds["focus_curve_filename"])
|
||||
seq_rough_kwds["focus_curve_filename"] = str(
|
||||
pt.with_stem(pt.stem + "_rough")
|
||||
)
|
||||
|
||||
if seq_rough_kwds["result_data_filename"] is not None:
|
||||
pt = pl.Path(seq_rough_kwds["result_data_filename"])
|
||||
seq_rough_kwds["result_data_filename"] = str(
|
||||
pt.with_stem(pt.stem + "_rough")
|
||||
)
|
||||
|
||||
result = obsutil.focussingSequence(
|
||||
[focus_start, focus_stop],
|
||||
set_focus,
|
||||
get_image,
|
||||
init_seq_func,
|
||||
set_focus_func,
|
||||
get_image_func,
|
||||
None,
|
||||
sys.stdout,
|
||||
**seq_kwds
|
||||
**seq_rough_kwds
|
||||
)
|
||||
|
||||
if result["ret_code"] != 0:
|
||||
@@ -130,7 +147,7 @@ def focussing_app(parser, set_focus, get_image):
|
||||
|
||||
if args.verbose:
|
||||
print(
|
||||
"\testimate guess focus position in range [{:g},{:g}]".format(
|
||||
"\testimate guess focus position in range of [{:g},{:g}]".format(
|
||||
focus_start, focus_stop
|
||||
)
|
||||
)
|
||||
@@ -138,8 +155,9 @@ def focussing_app(parser, set_focus, get_image):
|
||||
if np.isfinite(args.focus_step):
|
||||
result = obsutil.focussingSequence(
|
||||
[focus_start, focus_stop, focus_step],
|
||||
set_focus,
|
||||
get_image,
|
||||
init_seq_func,
|
||||
set_focus_func,
|
||||
get_image_func,
|
||||
None,
|
||||
sys.stdout,
|
||||
**seq_kwds
|
||||
@@ -147,8 +165,9 @@ def focussing_app(parser, set_focus, get_image):
|
||||
else:
|
||||
result = obsutil.focussingSequence(
|
||||
[focus_start, focus_stop],
|
||||
set_focus,
|
||||
get_image,
|
||||
init_seq_func,
|
||||
set_focus_func,
|
||||
get_image_func,
|
||||
None,
|
||||
sys.stdout,
|
||||
**seq_kwds
|
||||
@@ -160,7 +179,7 @@ def focussing_app(parser, set_focus, get_image):
|
||||
if not args.do_not_set:
|
||||
if args.verbose:
|
||||
print("\n\tSet focus to the best value ...", end="")
|
||||
set_focus(result["focus_value"])
|
||||
set_focus_func(result["focus_value"])
|
||||
print("\tOK")
|
||||
|
||||
if args.verbose:
|
||||
|
||||
Reference in New Issue
Block a user