#!/usr/bin/env python
""" runmultihap.py - Module to control processing of multi-visit mosaics
:License: :doc:`/LICENSE`
USAGE:
>>> python drizzlepac/runmultihap [-dl] inputFilename
- The '-d' option will run this task in DEBUG mode producing additional outputs. If not explicitly specified,
the default value is logical "False".
- The '-l' option allows the user to control the level of verboseness in the log statements displayed on the
screen and written to the .log file. Valid options are "critical", "error", "warning", "info", and "debug".
If not explicitly specified, the default value is "info".
Python USAGE:
>>> python
>>> from drizzlepac import runmultihap
>>> runmultihap.perform(inputFilename, debug=False, log_level="info")
"""
# Import standard Python modules
import argparse
import sys
# THIRD-PARTY
from stsci.tools import logutil
from drizzlepac import hapmultisequencer
__taskname__ = "runmultihap"
# Local variables
#
# These lines (or something similar) will be needed in the HAP processing code
#
MSG_DATEFMT = '%Y%j%H%M%S'
SPLUNK_MSG_FORMAT = '%(asctime)s %(levelname)s src=%(name)s- %(message)s'
log = logutil.create_logger(__name__, level=logutil.logging.NOTSET, stream=sys.stdout,
format=SPLUNK_MSG_FORMAT, datefmt=MSG_DATEFMT)
# ----------------------------------------------------------------------------------------------------------------------
# ------------------------------------------------------------------------------------------------------------
def main():
parser = argparse.ArgumentParser(description='Process images, produce mosaics and sourcelists')
parser.add_argument('input_filename',
help='Name of the input csv file containing information about the files to be '
'processed')
parser.add_argument('-c', '--input_custom_pars_file', required=False, default=None, help='filename of a '
'configuration JSON file which has been customized for specialized processing. This '
'file should contain ALL the input parameters necessary for processing. If not '
'specified, default configuration parameter values will be used.')
parser.add_argument('-d', '--diagnostic_mode', required=False, action='store_true',
help='If this option is turned on, additional log messages will be displayed and '
'additional files will be created during the course of the run.')
parser.add_argument('-l', '--log_level', required=False, default='info',
choices=['critical', 'error', 'warning', 'info', 'debug'],
help='The desired level of verboseness in the log statements displayed on the screen '
'and written to the .log file. The level of verboseness from left to right, and '
'includes all log statements with a log_level left of the specified level. '
'Specifying "critical" will only record/display "critical" log statements, and '
'specifying "error" will record/display both "error" and "critical" log '
'statements, and so on.')
parser.add_argument('-s', '--skip_gaia_alignment', required=False, default=True, action='store_true',
help='Skip alignment of all input images to known Gaia/HSC sources in the input '
'image footprint? If this option is turned on, the existing input image '
'alignment solution will be used instead. The default is False.')
user_args = parser.parse_args()
print("Multi-visit processing started for: {}".format(user_args.input_filename))
rv = perform(user_args.input_filename,
diagnostic_mode=user_args.diagnostic_mode,
input_custom_pars_file=user_args.input_custom_pars_file,
log_level=user_args.log_level,
skip_gaia_alignment=user_args.skip_gaia_alignment)
print("Return Value: ", rv)
return rv
# ------------------------------------------------------------------------------------------------------------
if __name__ == '__main__':
main()