# Path: arsf_envi_reader/numpy_bin_reader.py
# HAVE_ARSF_BINARYREADER = False
#     HAVE_ARSF_BINARYREADER = True
# class _BinaryReader(collections.Iterator):
# class BilReader(_BinaryReader):
# class BsqReader(_BinaryReader):
#     def __init__(self, input_file):
#     def __next__(self): pass
#     def read_line(self, line_number):
#     def read_band(self, band_number):
#     def read_pixel(self, sample_number, line_number):
#     def next(self):
#     def get_hdr_dict(self):
#     def get_num_samples(self):
#     def get_num_lines(self):
#     def get_num_bands(self):
#     def have_arsf_binaryreader(self):
#     def check_interleave(self, interleave):
#     def check_size(binary_file):
#     def __del__(self):
#     def __next__(self):
#     def read_line(self, line_number):
#     def read_band(self, band_number):
#     def read_pixel(self, sample_number, line_number):
#     def __next__(self):
#     def read_line(self, line_number):
#     def read_band(self, band_number):
#     def read_pixel(self, sample_number, line_number):
# 
# 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
from scipy import signal
from arsf_envi_reader import numpy_bin_reader
from arsf_envi_reader import envi_header
#!/usr/bin/env python
"""
Apply Savitzky-Golay filter to an ENVI BIL file

Uses scipy

http://docs.scipy.org/doc/scipy/reference/generated/scipy.signal.savgol_filter.html

And arsf_envi_reader (available from: https://github.com/pmlrsg/arsf_tools)

Dan Clewley
16/06/2016

"""

from __future__ import print_function


POLY_ORDER = 3
WINDOW_SIZE = 7

if __name__ == "__main__":
    parser = argparse.ArgumentParser()
    parser.add_argument("inputimage", nargs=1,
                        type=str, help="Input image")
    parser.add_argument("outputimage", nargs=1,
                        type=str, help="Output image")
    args = parser.parse_args()

    # Open input file

# Path: arsf_envi_reader/numpy_bin_reader.py
# HAVE_ARSF_BINARYREADER = False
#     HAVE_ARSF_BINARYREADER = True
# class _BinaryReader(collections.Iterator):
# class BilReader(_BinaryReader):
# class BsqReader(_BinaryReader):
#     def __init__(self, input_file):
#     def __next__(self): pass
#     def read_line(self, line_number):
#     def read_band(self, band_number):
#     def read_pixel(self, sample_number, line_number):
#     def next(self):
#     def get_hdr_dict(self):
#     def get_num_samples(self):
#     def get_num_lines(self):
#     def get_num_bands(self):
#     def have_arsf_binaryreader(self):
#     def check_interleave(self, interleave):
#     def check_size(binary_file):
#     def __del__(self):
#     def __next__(self):
#     def read_line(self, line_number):
#     def read_band(self, band_number):
#     def read_pixel(self, sample_number, line_number):
#     def __next__(self):
#     def read_line(self, line_number):
#     def read_band(self, band_number):
#     def read_pixel(self, sample_number, line_number):
# 
# 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: apply_savgol_filter.py
import argparse
from scipy import signal
from arsf_envi_reader import numpy_bin_reader
from arsf_envi_reader import envi_header

#!/usr/bin/env python
"""
Apply Savitzky-Golay filter to an ENVI BIL file

Uses scipy

http://docs.scipy.org/doc/scipy/reference/generated/scipy.signal.savgol_filter.html

And arsf_envi_reader (available from: https://github.com/pmlrsg/arsf_tools)

Dan Clewley
16/06/2016

"""

from __future__ import print_function


POLY_ORDER = 3
WINDOW_SIZE = 7

if __name__ == "__main__":
    parser = argparse.ArgumentParser()
    parser.add_argument("inputimage", nargs=1,
                        type=str, help="Input image")
    parser.add_argument("outputimage", nargs=1,
                        type=str, help="Output image")
    args = parser.parse_args()

    # Open input file

    in_data = numpy_bin_reader.BilReader(args.inputimage[0])