class Fit2DGridSearch(KPFTranslatorFunction):
'''# Description
Take two 1D grid search runs (one in X and one in Y) ...
# Parameters
None
'''
@classmethod
def pre_condition(cls, args, logger, cfg):
pass
@classmethod
def perform(cls, args, logger, cfg):
log_file_x = Path(args.get('logfileX'))
fgs_cube_fileX = log_file_x.parent / Path(f'TipTilt{log_file_x.stem}.fits')
log_file_y = Path(args.get('logfileY'))
fgs_cube_fileY = log_file_y.parent / Path(f'TipTilt{log_file_y.stem}.fits')
try:
with open(log_file_x) as FO:
lines = FO.readlines()
for line in lines[:60]:
m_comment = re.search("comment: (.*)", line)
if m_comment is not None:
comment = m_comment.groups()[0].strip('\n')
log.info(f" Log Comment: {comment}")
except:
comment = ''
fit_2D_fiber_center(fgs_cube_fileX,
fgs_cube_fileY,
xcent=args.get('xfit'),
ycent=args.get('yfit'),
targname=comment)
@classmethod
def post_condition(cls, args, logger, cfg):
pass
@classmethod
def add_cmdline_args(cls, parser, cfg=None):
parser.add_argument('logfileX', type=str,
help="The GridSearch log file for the X pixel scan")
parser.add_argument('logfileY', type=str,
help="The GridSearch log file for the Y pixel scan")
parser.add_argument("--xfit", dest="xfit", type=float,
default=335.5,
help="The X pixel position to use as the center when overlaying the model.")
parser.add_argument("--yfit", dest="yfit", type=float,
default=258,
help="The X pixel position to use as the center when overlaying the model.")
return super().add_cmdline_args(parser, cfg)