Skip to content

Commit

Permalink
implemented rerun_registration option
Browse files Browse the repository at this point in the history
  • Loading branch information
mommermi committed Nov 19, 2018
1 parent a4cfd70 commit 1009346
Showing 1 changed file with 33 additions and 28 deletions.
61 changes: 33 additions & 28 deletions pp_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@


def run_the_pipeline(filenames, man_targetname, man_filtername,
fixed_aprad, source_tolerance, solar):
fixed_aprad, source_tolerance, solar, rerun_registration):
"""
wrapper to run the photometry pipeline
"""
Expand Down Expand Up @@ -190,24 +190,32 @@ def run_the_pipeline(filenames, man_targetname, man_filtername,
snr, source_minarea = obsparam['source_snr'], obsparam['source_minarea']
aprad = obsparam['aprad_default']

print('\n----- run image registration\n')
registration = pp_register.register(filenames, telescope, snr,
source_minarea, aprad,
None, obsparam,
obsparam['source_tolerance'],
display=True,
diagnostics=True)

if len(registration['badfits']) == len(filenames):
summary_message = "<FONT COLOR=\"red\">registration failed</FONT>"
elif len(registration['goodfits']) == len(filenames):
summary_message = "<FONT COLOR=\"green\">all images registered" + \
"</FONT>; "
else:
summary_message = "<FONT COLOR=\"orange\">registration failed for " + \
("%d/%d images</FONT>; " %
(len(registration['badfits']),
len(filenames)))
registration_run_number = 0
while True:

print('\n----- run image registration\n')
registration = pp_register.register(filenames, telescope, snr,
source_minarea, aprad,
None, obsparam,
obsparam['source_tolerance'],
display=True,
diagnostics=True)

if len(registration['badfits']) == len(filenames):
summary_message = "<FONT COLOR=\"red\">registration failed</FONT>"
elif len(registration['goodfits']) == len(filenames):
summary_message = "<FONT COLOR=\"green\">all images registered" + \
"</FONT>; "
break
else:
summary_message = "<FONT COLOR=\"orange\">registration failed for " + \
("%d/%d images</FONT>; " %
(len(registration['badfits']),
len(filenames)))
# break from loop if maximum number of iterations (2) achieved
registration_run_number += 1
if registration_run_number == 2:
break

# add information to summary website, if requested
if _pp_conf.use_diagnostics_summary:
Expand All @@ -216,13 +224,6 @@ def run_the_pipeline(filenames, man_targetname, man_filtername,
# in case not all image were registered successfully
filenames = registration['goodfits']

# # stop here if filtername == None
# if filtername == None:
# logging.info('Nothing else to do for this filter (%s)' %
# filtername)
# print('Nothing else to do for this filter (%s)' % filtername)
# return None

# stop here if registration failed for all images
if len(filenames) == 0:
logging.info('Nothing else to do for this image set')
Expand Down Expand Up @@ -348,6 +349,9 @@ def run_the_pipeline(filenames, man_targetname, man_filtername,
parser.add_argument('-solar',
help='restrict to solar-color stars',
action="store_true", default=False)
parser.add_argument('-rerun_registration',
help='rerun registration step if not successful for all images',
action="store_true", default=False)
parser.add_argument('images', help='images to process or \'all\'',
nargs='+')

Expand All @@ -358,6 +362,7 @@ def run_the_pipeline(filenames, man_targetname, man_filtername,
fixed_aprad = float(args.fixed_aprad)
source_tolerance = args.source_tolerance
solar = args.solar
rerun_registration = args.rerun_registration
filenames = sorted(args.images)

# if filenames = ['all'], walk through directories and run pipeline
Expand Down Expand Up @@ -391,13 +396,13 @@ def run_the_pipeline(filenames, man_targetname, man_filtername,
os.chdir(root)

run_the_pipeline(filenames, man_targetname, man_filtername,
fixed_aprad, source_tolerance, solar)
fixed_aprad, source_tolerance, solar, rerun_registration)
os.chdir(_masterroot_directory)
else:
print('\n NOTHING TO DO IN %s' % root)

else:
# call run_the_pipeline only on filenames
run_the_pipeline(filenames, man_targetname, man_filtername,
fixed_aprad, source_tolerance, solar)
fixed_aprad, source_tolerance, solar, rerun_registration)
pass

0 comments on commit 1009346

Please sign in to comment.