#!python
#
#  Copyright 2018 California Institute of Technology
#
#  Licensed under the Apache License, Version 2.0 (the "License");
#  you may not use this file except in compliance with the License.
#  You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
#  Unless required by applicable law or agreed to in writing, software
#  distributed under the License is distributed on an "AS IS" BASIS,
#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#  See the License for the specific language governing permissions and
#  limitations under the License.
#
# ISOFIT: Imaging Spectrometer Optimal FITting
# Author: David R Thompson, david.r.thompson@jpl.nasa.gov
#         Adam Erickson, adam.m.erickson@nasa.gov
#

import argparse
import logging

from isofit.core.isofit import Isofit
from isofit import __version__


def main():

    description = "Spectroscopic Surface & Atmosphere Fitting"

    parser = argparse.ArgumentParser(description=description)
    parser.add_argument('config_file')
    parser.add_argument('--level', default='INFO')
    parser.add_argument('--row_column', default='')
    parser.add_argument('--profile', action='store_true', default=False)
    parser.add_argument('-v', '--version', action='version',
                        version='%(prog)s {version}'.format(version=__version__))
    args = parser.parse_args()

    config = args.config_file
    level = args.level
    row_column = args.row_column
    profile = args.profile

    logging.basicConfig(format='%(message)s', level=level)

    isofit = Isofit(config_file=config, level=level, row_column=row_column, profile=profile)
    
    return isofit.run()


if __name__ == '__main__':

    main()
