# Path: pyteltools/geom/Shapefile.py
# def get_shape_type(input_filename):
# def get_lines(input_filename, shape_type):
# def get_open_polylines(input_filename):
# def get_polygons(input_filename):
# def get_all_fields(input_filename):
# def get_attribute_names(input_filename):
# def get_numeric_attribute_names(input_filename):
# def get_points(input_filename, indices=None, with_z=False):
# def write_shp_points_z(output_filename, z_name, points):
# def write_shp_lines(output_filename, shape_type, lines, attribute_name):
# 
# Path: pyteltools/slf/Serafin.py
# class Serafin:
#     """!
#     @brief A Serafin object corresponds to a single Serafin in file IO stream
# 
#     # Attributes:
#     - language <str>: language for variables ('fr' or 'en')
#     - mode <str>: file open mode
#     - file <_io.BufferedReader>: input Serafin stream
#     - filename <str>: path to file
#     - file_size <int>: size of file
#     """
#     def __init__(self, filename, mode, language):
#         self.language = language
#         self.mode = mode
# 
#         self.file = None  # will be opened when called using `with` statement
#         self.filename = filename
#         self.file_size = None
# 
#     def __enter__(self):
#         self.file = open(self.filename, self.mode)
#         return self
# 
#     def __exit__(self, exc_type, exc_val, exc_tb):
#         self.file.close()
#         return False
# 
# Path: pyteltools/utils/cli_base.py
# LINE_WIDTH = 80
# class CustomFormatter(argparse.ArgumentDefaultsHelpFormatter, argparse.RawDescriptionHelpFormatter):
# class PyTelToolsArgParse(argparse.ArgumentParser):
#     def __init__(self, add_args=[], description=None, *args, **kwargs):
#     def add_known_argument(self, arg_id):
#     def _add_auto_arguments(self):
#     def _title_group(label):
#     def add_argument_group(self, name, *args, **kwargs):
#     def add_group_general(self, add_args=[]):
#     def parse_args(self, *args, **kwargs):


import numpy as np
import sys
from shapefile import ShapefileException
from shapely.geometry import Point
from pyteltools.conf import settings
from pyteltools.geom import Shapefile
from pyteltools.slf import Serafin
from pyteltools.utils.cli_base import logger, PyTelToolsArgParse
#!/usr/bin/env python
"""
Compute the max or min over some variables for a serie of files (which may contain several frames).
This operation can be performed only on some zones defined by polygon(s).
In this case the values in the area not covered by the polygons are set to the first file and first frame.
The output file contains a single frame with the variables.

This tool has some limitations:
- vectors are not considered as such
- meshes have to be similar
"""



def slf_max_over_files(args):
    if args.vars is None:

# Path: pyteltools/geom/Shapefile.py
# def get_shape_type(input_filename):
# def get_lines(input_filename, shape_type):
# def get_open_polylines(input_filename):
# def get_polygons(input_filename):
# def get_all_fields(input_filename):
# def get_attribute_names(input_filename):
# def get_numeric_attribute_names(input_filename):
# def get_points(input_filename, indices=None, with_z=False):
# def write_shp_points_z(output_filename, z_name, points):
# def write_shp_lines(output_filename, shape_type, lines, attribute_name):
# 
# Path: pyteltools/slf/Serafin.py
# class Serafin:
#     """!
#     @brief A Serafin object corresponds to a single Serafin in file IO stream
# 
#     # Attributes:
#     - language <str>: language for variables ('fr' or 'en')
#     - mode <str>: file open mode
#     - file <_io.BufferedReader>: input Serafin stream
#     - filename <str>: path to file
#     - file_size <int>: size of file
#     """
#     def __init__(self, filename, mode, language):
#         self.language = language
#         self.mode = mode
# 
#         self.file = None  # will be opened when called using `with` statement
#         self.filename = filename
#         self.file_size = None
# 
#     def __enter__(self):
#         self.file = open(self.filename, self.mode)
#         return self
# 
#     def __exit__(self, exc_type, exc_val, exc_tb):
#         self.file.close()
#         return False
# 
# Path: pyteltools/utils/cli_base.py
# LINE_WIDTH = 80
# class CustomFormatter(argparse.ArgumentDefaultsHelpFormatter, argparse.RawDescriptionHelpFormatter):
# class PyTelToolsArgParse(argparse.ArgumentParser):
#     def __init__(self, add_args=[], description=None, *args, **kwargs):
#     def add_known_argument(self, arg_id):
#     def _add_auto_arguments(self):
#     def _title_group(label):
#     def add_argument_group(self, name, *args, **kwargs):
#     def add_group_general(self, add_args=[]):
#     def parse_args(self, *args, **kwargs):


# Path: cli/slf_max_over_files.py
import numpy as np
import sys
from shapefile import ShapefileException
from shapely.geometry import Point
from pyteltools.conf import settings
from pyteltools.geom import Shapefile
from pyteltools.slf import Serafin
from pyteltools.utils.cli_base import logger, PyTelToolsArgParse

#!/usr/bin/env python
"""
Compute the max or min over some variables for a serie of files (which may contain several frames).
This operation can be performed only on some zones defined by polygon(s).
In this case the values in the area not covered by the polygons are set to the first file and first frame.
The output file contains a single frame with the variables.

This tool has some limitations:
- vectors are not considered as such
- meshes have to be similar
"""



def slf_max_over_files(args):
    if args.vars is None:

        with Serafin.Read(args.in_slfs[0], args.lang) as resin: