add init_seq_func to focussingSequence function. Add 'start_idx' key to sequenc control dictionary (see getFocusSequencePars). Rewrite aps

This commit is contained in:
2024-10-11 17:06:08 +03:00
parent 2113f87eed
commit b7750ee029
4 changed files with 89 additions and 24 deletions

View File

@@ -84,7 +84,8 @@ def getFocusSequencePars(**user_kwds):
"focus_start": None,
"focus_stop": None,
"focus_step": None,
"root_filename": "focus.fit",
"root_filename": "focus.fits",
"start_idx": 1, # start index of files in sequence
"acq_per_value": 1, # number of acquisitions per focus value
"exp_time": 10, # exposure time in seconds
"set_to_best": True, # set focus to the best value
@@ -283,6 +284,7 @@ def computeFocus(
def focussingSequence(
focus_range,
init_seq_func,
set_focus_func,
get_image_func,
max_wks=None,
@@ -295,6 +297,9 @@ def focussingSequence(
focus_range: [start, stop] (7 points)
or [start, stop, step]
init_seq_func: a function with signature:
init_seq_func(seq_kwds),
where seq_kwds - sequence control dictionary (see getFocusSequencePars function)
set_focus_func: a function of signature:
set_focus_func(foc_val)
get_image_func: a function of signature:
@@ -373,6 +378,8 @@ def focussingSequence(
seq_kwds = getFocusSequencePars(**kwds)
init_seq_func(seq_kwds)
if seq_kwds["acq_per_value"] > 1:
focus_value = (
np.array([focus_value] * seq_kwds["acq_per_value"]).transpose().flatten()
@@ -380,18 +387,19 @@ def focussingSequence(
rname = pt.Path(seq_kwds["root_filename"]).absolute()
dir = rname.parent
fname = rname.stem
file_ext = rname.suffix
if file_ext == "":
file_ext = ".fit"
# dir = rname.parent
# fname = rname.stem
# file_ext = rname.suffix
# if file_ext == "":
# file_ext = ".fit"
futures = []
flux_rad = []
executor = ProcessPoolExecutor(max_workers=max_wks)
i_foc = 1
i_foc = seq_kwds["start_idx"]
ret_code = 0
for foc_val in focus_value:
print(log_ident, file=log_output, end="")
@@ -410,8 +418,10 @@ def focussingSequence(
else:
print("OK", file=log_output, flush=True)
filename = "{}_{:04d}{}".format(fname, i_foc, file_ext)
full_filename = str(pt.Path.joinpath(dir, pt.Path(filename)))
# filename = "{}_{:04d}{}".format(fname, i_foc, file_ext)
# full_filename = str(pt.Path.joinpath(dir, pt.Path(filename)))
full_filename = str(rname.with_stem("{}_{:04d}", rname.stem, i_foc))
print(log_ident, file=log_output, end="")
print(
@@ -603,9 +613,9 @@ def getFocussingSequenceCmdlinePars(parser):
parser.add_argument(
"--foc-file",
help="Rootname of output focussing images. Default is 'focus.fit'.",
help="Rootname of output focussing images. Default is 'focus.fits'.",
type=str,
default="focus.fit",
default="focus.fits",
)
parser.add_argument(
@@ -725,7 +735,7 @@ def parsFocussingSequenceCmdlinePars(parser_args, parser_msg=[]):
parser_msg.append("Invalid '--foc_file' argument! Use of defaul value!")
kwds["root_filename"] = (
parser_args.foc_file if parser_args.foc_file != "" else "focus.fit"
parser_args.foc_file if parser_args.foc_file != "" else "focus.fits"
)
if parser_args.repeat <= 0: