fixes during real tests
This commit is contained in:
@@ -20,7 +20,7 @@ import subprocess as sp
|
|||||||
|
|
||||||
|
|
||||||
def set_focus(foc_val):
|
def set_focus(foc_val):
|
||||||
cmd = ["fli_control", "-g", str(foc_val)]
|
cmd = ["fli_control", "-g", str(int(foc_val))]
|
||||||
ret = sp.run(cmd, stdout=sp.PIPE, stderr=sp.PIPE)
|
ret = sp.run(cmd, stdout=sp.PIPE, stderr=sp.PIPE)
|
||||||
return ret.returncode
|
return ret.returncode
|
||||||
|
|
||||||
@@ -32,7 +32,7 @@ def get_image(filename, exp_time):
|
|||||||
# convert it to 'rootname'
|
# convert it to 'rootname'
|
||||||
#
|
#
|
||||||
|
|
||||||
fname = filename.split("_")
|
fname = str(filename).split("_")
|
||||||
fname = fname[0]
|
fname = fname[0]
|
||||||
|
|
||||||
cmd = [
|
cmd = [
|
||||||
@@ -137,6 +137,8 @@ if __name__ == "__main__":
|
|||||||
print("START FOCUSSING SEQUENCE ...")
|
print("START FOCUSSING SEQUENCE ...")
|
||||||
|
|
||||||
if args.guess: # rough focus estimation
|
if args.guess: # rough focus estimation
|
||||||
|
if args.verbose:
|
||||||
|
print("\trough focus estimation ...")
|
||||||
result = obsutil.focussingSequence(
|
result = obsutil.focussingSequence(
|
||||||
[focus_start, focus_stop],
|
[focus_start, focus_stop],
|
||||||
set_focus,
|
set_focus,
|
||||||
@@ -156,6 +158,10 @@ if __name__ == "__main__":
|
|||||||
focus_start = result["focus_value"] - r
|
focus_start = result["focus_value"] - r
|
||||||
focus_stop = result["focus_value"] + r
|
focus_stop = result["focus_value"] + r
|
||||||
|
|
||||||
|
if args.verbose:
|
||||||
|
print("\testimate guess focus position in range [{:g},{:g}]".format(focus_start, focus_stop))
|
||||||
|
|
||||||
|
|
||||||
if np.isfinite(args.focus_step):
|
if np.isfinite(args.focus_step):
|
||||||
result = obsutil.focussingSequence(
|
result = obsutil.focussingSequence(
|
||||||
[focus_start, focus_stop, focus_step],
|
[focus_start, focus_stop, focus_step],
|
||||||
@@ -178,7 +184,7 @@ if __name__ == "__main__":
|
|||||||
if args.verbose:
|
if args.verbose:
|
||||||
print("\tThe best focus value: {:g}".format(result["focus_value"]))
|
print("\tThe best focus value: {:g}".format(result["focus_value"]))
|
||||||
|
|
||||||
if not args.do_no_set:
|
if not args.do_not_set:
|
||||||
if args.verbose:
|
if args.verbose:
|
||||||
print("\n\tSet focus to the best value ...", end="")
|
print("\n\tSet focus to the best value ...", end="")
|
||||||
set_focus(result["focus_value"])
|
set_focus(result["focus_value"])
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ def getFocusSequencePars(**user_kwds):
|
|||||||
"focus_start": None,
|
"focus_start": None,
|
||||||
"focus_stop": None,
|
"focus_stop": None,
|
||||||
"focus_step": None,
|
"focus_step": None,
|
||||||
"root_filename": "focus.fits",
|
"root_filename": "focus.fit",
|
||||||
"acq_per_value": 1, # number of acquisitions per focus value
|
"acq_per_value": 1, # number of acquisitions per focus value
|
||||||
"exp_time": 10, # exposure time in seconds
|
"exp_time": 10, # exposure time in seconds
|
||||||
"set_to_best": True, # set focus to the best value
|
"set_to_best": True, # set focus to the best value
|
||||||
@@ -251,7 +251,7 @@ def computeFocus(
|
|||||||
if len(futures):
|
if len(futures):
|
||||||
print("", file=log_output)
|
print("", file=log_output)
|
||||||
print(log_ident, file=log_output, end="")
|
print(log_ident, file=log_output, end="")
|
||||||
print("waiting for the end of calculations ...\t", file=log_output, end="")
|
print("waiting for the end of calculations ...\t", file=log_output, end="", flush=True)
|
||||||
|
|
||||||
for i in range(len(futures)):
|
for i in range(len(futures)):
|
||||||
flux_rad.append(futures[i].result())
|
flux_rad.append(futures[i].result())
|
||||||
@@ -353,7 +353,7 @@ def focussingSequence(
|
|||||||
ret_val["ret_code"] = -1
|
ret_val["ret_code"] = -1
|
||||||
return ret_val
|
return ret_val
|
||||||
|
|
||||||
N = (focus_range[1] - focus_range[0]) / focus_range[2] + 1
|
N = int((focus_range[1] - focus_range[0]) / focus_range[2] + 1)
|
||||||
|
|
||||||
if N < 3:
|
if N < 3:
|
||||||
ret_val["ret_code"] = -1
|
ret_val["ret_code"] = -1
|
||||||
@@ -379,18 +379,18 @@ def focussingSequence(
|
|||||||
fname = rname.stem
|
fname = rname.stem
|
||||||
file_ext = rname.suffix
|
file_ext = rname.suffix
|
||||||
if file_ext == "":
|
if file_ext == "":
|
||||||
file_ext = ".fits"
|
file_ext = ".fit"
|
||||||
|
|
||||||
futures = []
|
futures = []
|
||||||
flux_rad = []
|
flux_rad = []
|
||||||
|
|
||||||
executor = ProcessPoolExecutor(max_workers=max_wks)
|
executor = ProcessPoolExecutor(max_workers=max_wks)
|
||||||
|
|
||||||
i_foc = 0
|
i_foc = 1
|
||||||
ret_code = 0
|
ret_code = 0
|
||||||
for foc_val in focus_value:
|
for foc_val in focus_value:
|
||||||
print(log_ident, file=log_output, end="")
|
print(log_ident, file=log_output, end="")
|
||||||
print("set focus value to {:g} ...\t".format(foc_val), file=log_output, end="")
|
print("set focus value to {:g} ...\t".format(foc_val), file=log_output, end="", flush=True)
|
||||||
|
|
||||||
ret_code = set_focus_func(foc_val)
|
ret_code = set_focus_func(foc_val)
|
||||||
if ret_code:
|
if ret_code:
|
||||||
@@ -401,10 +401,10 @@ def focussingSequence(
|
|||||||
print("OK", file=log_output)
|
print("OK", file=log_output)
|
||||||
|
|
||||||
filename = "{}_{:04d}{}".format(fname, i_foc, file_ext)
|
filename = "{}_{:04d}{}".format(fname, i_foc, file_ext)
|
||||||
full_filename = pt.Path.joinpath(dir, pt.Path(filename))
|
full_filename = str(pt.Path.joinpath(dir, pt.Path(filename)))
|
||||||
|
|
||||||
print(log_ident, file=log_output, end="")
|
print(log_ident, file=log_output, end="")
|
||||||
print("get image '{}' ...\t".format(full_filename), file=log_output, end="")
|
print("get image '{}' ...\t".format(full_filename), file=log_output, end="", flush=True)
|
||||||
|
|
||||||
ret_code = get_image_func(full_filename, seq_kwds["exp_time"])
|
ret_code = get_image_func(full_filename, seq_kwds["exp_time"])
|
||||||
if ret_code:
|
if ret_code:
|
||||||
@@ -414,7 +414,8 @@ def focussingSequence(
|
|||||||
else:
|
else:
|
||||||
print("OK", file=log_output)
|
print("OK", file=log_output)
|
||||||
|
|
||||||
futures.append(executor.submit(amt.compute_mean_flux_radius, fname, **seq_kwds))
|
futures.append(executor.submit(amt.compute_mean_flux_radius, full_filename, **seq_kwds))
|
||||||
|
i_foc += 1
|
||||||
|
|
||||||
print("", file=log_output)
|
print("", file=log_output)
|
||||||
print(log_ident, file=log_output, end="")
|
print(log_ident, file=log_output, end="")
|
||||||
@@ -580,9 +581,9 @@ def getFocussingSequenceCmdlinePars(parser):
|
|||||||
|
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--foc-file",
|
"--foc-file",
|
||||||
help="Rootname of output focussing images. Default is 'focus.fits'.",
|
help="Rootname of output focussing images. Default is 'focus.fit'.",
|
||||||
type=str,
|
type=str,
|
||||||
default="focus.fits",
|
default="focus.fit",
|
||||||
)
|
)
|
||||||
|
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
@@ -702,7 +703,7 @@ def parsFocussingSequenceCmdlinePars(parser_args, parser_msg=[]):
|
|||||||
parser_msg.append("Invalid '--foc_file' argument! Use of defaul value!")
|
parser_msg.append("Invalid '--foc_file' argument! Use of defaul value!")
|
||||||
|
|
||||||
kwds["root_filename"] = (
|
kwds["root_filename"] = (
|
||||||
parser_args.foc_file if parser_args.foc_file != "" else "focus.fits"
|
parser_args.foc_file if parser_args.foc_file != "" else "focus.fit"
|
||||||
)
|
)
|
||||||
|
|
||||||
if parser_args.repeat <= 0:
|
if parser_args.repeat <= 0:
|
||||||
|
|||||||
Reference in New Issue
Block a user