# Path: atrain_match/config.py
# def str2bool(v):
# RESOLUTION = int(os.environ.get('ATRAIN_RESOLUTION', 5))
# AREA_CONFIG_FILE = os.environ.get('AREA_CONFIG_FILE', './areas.def')
# AREA_CONFIG_FILE_PLOTS_ON_AREA = os.environ.get('AREA_CONFIG_FILE_PLOTS_ON_AREA', './region_config_test.cfg')
# ATRAIN_MATCH_CONFIG_PATH = os.environ.get('ATRAINMATCH_CONFIG_DIR', './etc')
# ATRAIN_MATCH_CONFIG_FILE = os.environ.get('ATRAINMATCH_CONFIG_FILE', 'atrain_match.cfg')
# INSTRUMENT = {'npp': 'viirs',
#               'noaa18': 'avhrr',
#               'meteosat8': 'seviri',
#               'meteosat9': 'seviri',
#               'meteosat10': 'seviri',
#               'meteosat11': 'seviri',
#               'fy3d': 'mersi2',
#               'noaa20': 'viirs',
#               'sga1': 'metimage',
#               'epsga1': 'metimage',
#               'metopsga1': 'metimage',
#               'eos1': 'modis',
#               'eos2': 'modis'}
# ALLOWED_MODES = []
# MODES_NO_DNT = ['BASIC']
# PROCESS_SURFACES = [
#     "ICE_COVER_SEA", "ICE_FREE_SEA", "SNOW_COVER_LAND", "SNOW_FREE_LAND",
#     "COASTAL_ZONE",
#     "TROPIC_ZONE", "TROPIC_ZONE_SNOW_FREE_LAND", "TROPIC_ZONE_ICE_FREE_SEA",
#     "SUB_TROPIC_ZONE",
#     "SUB_TROPIC_ZONE_SNOW_FREE_LAND", "SUB_TROPIC_ZONE_ICE_FREE_SEA",
#     "HIGH-LATITUDES",
#     "HIGH-LATITUDES_SNOW_FREE_LAND", "HIGH-LATITUDES_ICE_FREE_SEA",
#     "HIGH-LATITUDES_SNOW_COVER_LAND", "HIGH-LATITUDES_ICE_COVER_SEA",
#     "POLAR", "POLAR_SNOW_FREE_LAND", "POLAR_ICE_FREE_SEA",
#     "POLAR_SNOW_COVER_LAND", "POLAR_ICE_COVER_SEA"]
# COMPRESS_LVL = 6  # : Compresssion level for generated matched files (h5)
# NODATA = -9
# CLOUDSAT_CLOUDY_THR = 30.0
# CALIPSO_FILE_LENGTH = 60*60  # s calipso files are shorter 60 minutes
# CLOUDSAT_FILE_LENGTH = 120*60  # s cloudsat files are shorter 120 minutes
# ISS_FILE_LENGTH = 60*60  # s iss files are shorter 60 minutes
# AMSR_FILE_LENGTH = 60*60  # AMSR-Es  files are shorter 60 minutes
# SYNOP_FILE_LENGTH = 24*60  # s Our synop data comes in 1 day files
# MORA_FILE_LENGTH = 24*60  # s Our MORA data comes in 1 day files
# PPS_FORMAT_2012_OR_EARLIER = False
# SURFACES = PROCESS_SURFACES
# DNT_FLAG = ['ALL', 'DAY', 'NIGHT', 'TWILIGHT']


from atrain_match.config import (RESOLUTION, _validation_results_dir, SURFACES)
    from atrain_match.statistics import orrb_CFC_stat
        from atrain_match.statistics import orrb_CTH_stat
        from atrain_match.statistics import orrb_CTY_stat
        from atrain_match.statistics import orrb_CPH_stat
        from atrain_match.statistics import orrb_LWP_stat
    from glob import glob
    from atrain_match.utils.runutils import read_config_info
import logging
    import os
    import argparse
    parser.add_argument('--years', '-y', metavar='YYYY', type=str,
                        nargs='*', required=False,
                        help='List of year to combine, '
                        'overrides YEARS in atrain_match.cfg')
    parser.add_argument('--months', '-m', metavar='mm', type=str,
                        nargs='*', required=False,
                        help='List of year to combine, '
                        'overrides YEARS in atrain_match.cfg')      
    (options) = parser.parse_args()

    AM_PATHS, SETTINGS = read_config_info()

    # Find all wanted modes (dnt)
    modes_list = []
    if options.nodnt:
        New_DNT_FLAG = ['']
    else:
        New_DNT_FLAG = ['', '_DAY', '_NIGHT', '_TWILIGHT']
    if options.basic:
        modes_list.append('BASIC')
    if options.standard:
        modes_list.append('STANDARD')
    if options.satz:
        for mode in ['SATZ_LOW', 'SATZ_70', 'SATZ_HIGH', 'SATZ_0_20', 'SATZ_20_40', 'SATZ_40_60', 'SATZ_60_80', 'SATZ_80_100',]:
            modes_list.append(mode)
    if options.odticfilter:  # I prefer this one! /KG
        print('Will calculate statistic for mode OPTICAL_DEPTH_THIN_IS_CLEAR')
        modes_list.append('OPTICAL_DEPTH_THIN_IS_CLEAR')
    if options.surface_new_way:
        print('Will calculate statistic for the different surfaces')

# Path: atrain_match/config.py
# def str2bool(v):
# RESOLUTION = int(os.environ.get('ATRAIN_RESOLUTION', 5))
# AREA_CONFIG_FILE = os.environ.get('AREA_CONFIG_FILE', './areas.def')
# AREA_CONFIG_FILE_PLOTS_ON_AREA = os.environ.get('AREA_CONFIG_FILE_PLOTS_ON_AREA', './region_config_test.cfg')
# ATRAIN_MATCH_CONFIG_PATH = os.environ.get('ATRAINMATCH_CONFIG_DIR', './etc')
# ATRAIN_MATCH_CONFIG_FILE = os.environ.get('ATRAINMATCH_CONFIG_FILE', 'atrain_match.cfg')
# INSTRUMENT = {'npp': 'viirs',
#               'noaa18': 'avhrr',
#               'meteosat8': 'seviri',
#               'meteosat9': 'seviri',
#               'meteosat10': 'seviri',
#               'meteosat11': 'seviri',
#               'fy3d': 'mersi2',
#               'noaa20': 'viirs',
#               'sga1': 'metimage',
#               'epsga1': 'metimage',
#               'metopsga1': 'metimage',
#               'eos1': 'modis',
#               'eos2': 'modis'}
# ALLOWED_MODES = []
# MODES_NO_DNT = ['BASIC']
# PROCESS_SURFACES = [
#     "ICE_COVER_SEA", "ICE_FREE_SEA", "SNOW_COVER_LAND", "SNOW_FREE_LAND",
#     "COASTAL_ZONE",
#     "TROPIC_ZONE", "TROPIC_ZONE_SNOW_FREE_LAND", "TROPIC_ZONE_ICE_FREE_SEA",
#     "SUB_TROPIC_ZONE",
#     "SUB_TROPIC_ZONE_SNOW_FREE_LAND", "SUB_TROPIC_ZONE_ICE_FREE_SEA",
#     "HIGH-LATITUDES",
#     "HIGH-LATITUDES_SNOW_FREE_LAND", "HIGH-LATITUDES_ICE_FREE_SEA",
#     "HIGH-LATITUDES_SNOW_COVER_LAND", "HIGH-LATITUDES_ICE_COVER_SEA",
#     "POLAR", "POLAR_SNOW_FREE_LAND", "POLAR_ICE_FREE_SEA",
#     "POLAR_SNOW_COVER_LAND", "POLAR_ICE_COVER_SEA"]
# COMPRESS_LVL = 6  # : Compresssion level for generated matched files (h5)
# NODATA = -9
# CLOUDSAT_CLOUDY_THR = 30.0
# CALIPSO_FILE_LENGTH = 60*60  # s calipso files are shorter 60 minutes
# CLOUDSAT_FILE_LENGTH = 120*60  # s cloudsat files are shorter 120 minutes
# ISS_FILE_LENGTH = 60*60  # s iss files are shorter 60 minutes
# AMSR_FILE_LENGTH = 60*60  # AMSR-Es  files are shorter 60 minutes
# SYNOP_FILE_LENGTH = 24*60  # s Our synop data comes in 1 day files
# MORA_FILE_LENGTH = 24*60  # s Our MORA data comes in 1 day files
# PPS_FORMAT_2012_OR_EARLIER = False
# SURFACES = PROCESS_SURFACES
# DNT_FLAG = ['ALL', 'DAY', 'NIGHT', 'TWILIGHT']


# Path: atrain_match/compile_stats.py
from atrain_match.config import (RESOLUTION, _validation_results_dir, SURFACES)
    from atrain_match.statistics import orrb_CFC_stat
        from atrain_match.statistics import orrb_CTH_stat
        from atrain_match.statistics import orrb_CTY_stat
        from atrain_match.statistics import orrb_CPH_stat
        from atrain_match.statistics import orrb_LWP_stat
    from glob import glob
    from atrain_match.utils.runutils import read_config_info
import logging
    import os
    import argparse

    parser.add_argument('--years', '-y', metavar='YYYY', type=str,
                        nargs='*', required=False,
                        help='List of year to combine, '
                        'overrides YEARS in atrain_match.cfg')
    parser.add_argument('--months', '-m', metavar='mm', type=str,
                        nargs='*', required=False,
                        help='List of year to combine, '
                        'overrides YEARS in atrain_match.cfg')      
    (options) = parser.parse_args()

    AM_PATHS, SETTINGS = read_config_info()

    # Find all wanted modes (dnt)
    modes_list = []
    if options.nodnt:
        New_DNT_FLAG = ['']
    else:
        New_DNT_FLAG = ['', '_DAY', '_NIGHT', '_TWILIGHT']
    if options.basic:
        modes_list.append('BASIC')
    if options.standard:
        modes_list.append('STANDARD')
    if options.satz:
        for mode in ['SATZ_LOW', 'SATZ_70', 'SATZ_HIGH', 'SATZ_0_20', 'SATZ_20_40', 'SATZ_40_60', 'SATZ_60_80', 'SATZ_80_100',]:
            modes_list.append(mode)
    if options.odticfilter:  # I prefer this one! /KG
        print('Will calculate statistic for mode OPTICAL_DEPTH_THIN_IS_CLEAR')
        modes_list.append('OPTICAL_DEPTH_THIN_IS_CLEAR')
    if options.surface_new_way:
        print('Will calculate statistic for the different surfaces')

        for surface in SURFACES: