# Path: arsf_envi_reader/envi_header.py
# ENVI_TO_NUMPY_DTYPE = {'1':  numpy.uint8,
#                        '2':  numpy.int16,
#                        '3':  numpy.int32,
#                        '4':  numpy.float32,
#                        '5':  numpy.float64,
#                        '6':  numpy.complex64,
#                        '9':  numpy.complex128,
#                        '12': numpy.uint16,
#                        '13': numpy.uint32,
#                        '14': numpy.int64,
#                        '15': numpy.uint64}
# def find_hdr_file(rawfilename):
# def read_hdr_file(hdrfilename, keep_case=False):
# def write_envi_header(filename, header_dict):


import argparse
import csv
import os
import sys
from arsf_envi_reader import envi_header
###########################################################
# This file has been created by ARSF Data Analysis Node and
# is licensed under the GPL v3 Licence. A copy of this
# licence is available to download with this file.
###########################################################

from __future__ import print_function

if __name__ == "__main__":

    parser = argparse.ArgumentParser(description='''
                        Get information from ENVI header file and prints to screen.
                        Can optionally save some attributes (e.g., wavelengths) to
                        a CSV file.
                        Created by ARSF-DAN at Plymouth Marine Laboratory.
                        Latest version available from https://github.com/pmlrsg/arsf_tools/.''')
    parser.add_argument("inputfile", nargs=1,type=str,
                            help="Input header")
    parser.add_argument("-o","--outcsv", required=False, type=str,
                            help="Output file to store values for each band to")
    args = parser.parse_args()

    # Check a header file has been provided.
    if os.path.splitext(args.inputfile[0])[-1].lower() != '.hdr':
        print('Must provide header file as input (ending with ".hdr")', file=sys.stderr)
        sys.exit(1)
    if not os.path.isfile(args.inputfile[0]):
        print('Could not open input header ({})'.format(args.inputfile[0]), file=sys.stderr)
        sys.exit(1)


# Path: arsf_envi_reader/envi_header.py
# ENVI_TO_NUMPY_DTYPE = {'1':  numpy.uint8,
#                        '2':  numpy.int16,
#                        '3':  numpy.int32,
#                        '4':  numpy.float32,
#                        '5':  numpy.float64,
#                        '6':  numpy.complex64,
#                        '9':  numpy.complex128,
#                        '12': numpy.uint16,
#                        '13': numpy.uint32,
#                        '14': numpy.int64,
#                        '15': numpy.uint64}
# def find_hdr_file(rawfilename):
# def read_hdr_file(hdrfilename, keep_case=False):
# def write_envi_header(filename, header_dict):


# Path: get_info_from_header.py
import argparse
import csv
import os
import sys
from arsf_envi_reader import envi_header

###########################################################
# This file has been created by ARSF Data Analysis Node and
# is licensed under the GPL v3 Licence. A copy of this
# licence is available to download with this file.
###########################################################

from __future__ import print_function

if __name__ == "__main__":

    parser = argparse.ArgumentParser(description='''
                        Get information from ENVI header file and prints to screen.
                        Can optionally save some attributes (e.g., wavelengths) to
                        a CSV file.
                        Created by ARSF-DAN at Plymouth Marine Laboratory.
                        Latest version available from https://github.com/pmlrsg/arsf_tools/.''')
    parser.add_argument("inputfile", nargs=1,type=str,
                            help="Input header")
    parser.add_argument("-o","--outcsv", required=False, type=str,
                            help="Output file to store values for each band to")
    args = parser.parse_args()

    # Check a header file has been provided.
    if os.path.splitext(args.inputfile[0])[-1].lower() != '.hdr':
        print('Must provide header file as input (ending with ".hdr")', file=sys.stderr)
        sys.exit(1)
    if not os.path.isfile(args.inputfile[0]):
        print('Could not open input header ({})'.format(args.inputfile[0]), file=sys.stderr)
        sys.exit(1)


    header_dict = envi_header.read_hdr_file(args.inputfile[0])