# 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
        # get result files for all cases
        for truth_sat in SETTINGS["COMPILE_STATISTICS_TRUTH"]:
            logger.info("PROCESS MODE %s, truth: %s", process_mode_dnt, truth_sat.upper())
            print("Gathering statistics from all validation results files in the "
                  "following directories:")
            results_files = []
            for case in CASES:
                indata_dir = AM_PATHS['result_dir'].format(
                    val_dir=_validation_results_dir,
                    satellite=case['satname'],
                    resolution=str(RESOLUTION),
                    month=case['month'],
                    year=case['year'],
                    day=case['day'],
                    mode=process_mode_dnt,
                    truth_sat=truth_sat,
                    min_opt_depth="")
                indata_dir = indata_dir.replace("_%H", "*")
                indata_file = AM_PATHS['result_file'].format(
                    resolution=str(RESOLUTION),
                    basename="*",
                    truth_sat=truth_sat)
                print("-> " + indata_dir)
                results_files.extend(glob("%s/*%skm*%s*.dat" % (indata_dir, RESOLUTION, truth_sat.lower())))
                results_files = list(set(results_files))
            if len(results_files) < 1:
                logger.info("PROCESS MODE %s have no results files", process_mode_dnt)
                continue
            # compile and write results
            compiled_dir = AM_PATHS['compiled_stats_dir'].format(

# 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

        # get result files for all cases
        for truth_sat in SETTINGS["COMPILE_STATISTICS_TRUTH"]:
            logger.info("PROCESS MODE %s, truth: %s", process_mode_dnt, truth_sat.upper())
            print("Gathering statistics from all validation results files in the "
                  "following directories:")
            results_files = []
            for case in CASES:
                indata_dir = AM_PATHS['result_dir'].format(
                    val_dir=_validation_results_dir,
                    satellite=case['satname'],
                    resolution=str(RESOLUTION),
                    month=case['month'],
                    year=case['year'],
                    day=case['day'],
                    mode=process_mode_dnt,
                    truth_sat=truth_sat,
                    min_opt_depth="")
                indata_dir = indata_dir.replace("_%H", "*")
                indata_file = AM_PATHS['result_file'].format(
                    resolution=str(RESOLUTION),
                    basename="*",
                    truth_sat=truth_sat)
                print("-> " + indata_dir)
                results_files.extend(glob("%s/*%skm*%s*.dat" % (indata_dir, RESOLUTION, truth_sat.lower())))
                results_files = list(set(results_files))
            if len(results_files) < 1:
                logger.info("PROCESS MODE %s have no results files", process_mode_dnt)
                continue
            # compile and write results
            compiled_dir = AM_PATHS['compiled_stats_dir'].format(

                val_dir=_validation_results_dir,