# 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
        MY_SATELLITES = options.satellites
    if options.years:
        MY_YEARS = options.years
    years_string = "_".join(MY_YEARS)    
    satellites_string = "_".join(MY_SATELLITES) 
    # get cases
    CASES = []
    month_list = ["*"]
    day_list = ["*"]
    if "MONTH" in SETTINGS.keys() and len(SETTINGS["MONTHS"]) > 0:
        month_list = ["{:02d}".format(int(ind)) for ind in SETTINGS["MONTHS"]]
    if options.months:
        month_list = ["{:02d}".format(int(ind)) for ind in options.months]
        
    if "DAY" in SETTINGS.keys() and len(SETTINGS["DAYS"]) > 0:
        day_list = ["{:02d}".format(int(ind)) for ind in SETTINGS["DAYS"]]
    for sat in MY_SATELLITES:
        for year in MY_YEARS:
            for month in month_list:
                for day in day_list:
                    CASES.append({'satname': sat,
                                  'month': month,
                                  'year': year,
                                  'day': day})

    if len(modes_dnt_list) == 0:
        logger.warning("No modes selected!")
        parser.print_help()
    # For each mode calcualte the statistics
    for process_mode_dnt in modes_dnt_list:

# 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

        MY_SATELLITES = options.satellites
    if options.years:
        MY_YEARS = options.years
    years_string = "_".join(MY_YEARS)    
    satellites_string = "_".join(MY_SATELLITES) 
    # get cases
    CASES = []
    month_list = ["*"]
    day_list = ["*"]
    if "MONTH" in SETTINGS.keys() and len(SETTINGS["MONTHS"]) > 0:
        month_list = ["{:02d}".format(int(ind)) for ind in SETTINGS["MONTHS"]]
    if options.months:
        month_list = ["{:02d}".format(int(ind)) for ind in options.months]
        
    if "DAY" in SETTINGS.keys() and len(SETTINGS["DAYS"]) > 0:
        day_list = ["{:02d}".format(int(ind)) for ind in SETTINGS["DAYS"]]
    for sat in MY_SATELLITES:
        for year in MY_YEARS:
            for month in month_list:
                for day in day_list:
                    CASES.append({'satname': sat,
                                  'month': month,
                                  'year': year,
                                  'day': day})

    if len(modes_dnt_list) == 0:
        logger.warning("No modes selected!")
        parser.print_help()
    # For each mode calcualte the statistics
    for process_mode_dnt in modes_dnt_list:

        print(RESOLUTION)