# Path: atrain_match/libs/extract_imager_along_track.py
# def get_data_from_array(array, matched):
#     if array is None:
#         return None
#     return np.array([array[matched['row'][idx], matched['col'][idx]]
#                      for idx in range(matched['row'].shape[0])])
# 
# Path: atrain_match/config.py
# NODATA = -9


from atrain_match.libs.extract_imager_along_track import get_data_from_array
from atrain_match.config import NODATA
    from atrain_match.libs.truth_imager_match import find_main_cloudproduct_file
    from pyhdf.SD import SD, SDC
import numpy as np
import os
import h5py
import logging
        self.temperature = None
        self.pressure = None
        self.cloud_emissivity = None
        self.cloud_phase = None
        self.lwp = None
        self.multilayer = None
        self.optical_depth = None

def add_modis_06(ca_matchup, AM_PATHS, cross):

    mfile = find_modis_lvl2_file(AM_PATHS, cross)
    if mfile.endswith('.h5'):
        modis_06 = read_modis_h5(mfile)
    else:
        modis_06 = read_modis_hdf(mfile)
    ca_matchup_truth_sat = getattr(ca_matchup, ca_matchup.truth_sat)
    row_matched = ca_matchup_truth_sat.imager_linnum
    col_matched = ca_matchup_truth_sat.imager_pixnum

    index = {'row': row_matched,
             'col': col_matched}
    index_5km = {'row': np.floor(row_matched/5).astype(np.int),
                 'col': np.floor(col_matched/5).astype(np.int)}

    ca_matchup.modis_lvl2.height = get_data_from_array(modis_06.height, index)
    ca_matchup.modis_lvl2.temperature = get_data_from_array(modis_06.temperature, index)
    ca_matchup.modis_lvl2.pressure = get_data_from_array(modis_06.pressure, index)
    ca_matchup.modis_lvl2.lwp = get_data_from_array(modis_06.lwp, index)
    ca_matchup.modis_lvl2.cloud_emissivity = get_data_from_array(modis_06.cloud_emissivity, index)
    ca_matchup.modis_lvl2.multilayer = get_data_from_array(modis_06.multilayer, index)

# Path: atrain_match/libs/extract_imager_along_track.py
# def get_data_from_array(array, matched):
#     if array is None:
#         return None
#     return np.array([array[matched['row'][idx], matched['col'][idx]]
#                      for idx in range(matched['row'].shape[0])])
# 
# Path: atrain_match/config.py
# NODATA = -9


# Path: atrain_match/cloudproducts/read_modis_products.py
from atrain_match.libs.extract_imager_along_track import get_data_from_array
from atrain_match.config import NODATA
    from atrain_match.libs.truth_imager_match import find_main_cloudproduct_file
    from pyhdf.SD import SD, SDC
import numpy as np
import os
import h5py
import logging

        self.temperature = None
        self.pressure = None
        self.cloud_emissivity = None
        self.cloud_phase = None
        self.lwp = None
        self.multilayer = None
        self.optical_depth = None

def add_modis_06(ca_matchup, AM_PATHS, cross):

    mfile = find_modis_lvl2_file(AM_PATHS, cross)
    if mfile.endswith('.h5'):
        modis_06 = read_modis_h5(mfile)
    else:
        modis_06 = read_modis_hdf(mfile)
    ca_matchup_truth_sat = getattr(ca_matchup, ca_matchup.truth_sat)
    row_matched = ca_matchup_truth_sat.imager_linnum
    col_matched = ca_matchup_truth_sat.imager_pixnum

    index = {'row': row_matched,
             'col': col_matched}
    index_5km = {'row': np.floor(row_matched/5).astype(np.int),
                 'col': np.floor(col_matched/5).astype(np.int)}

    ca_matchup.modis_lvl2.height = get_data_from_array(modis_06.height, index)
    ca_matchup.modis_lvl2.temperature = get_data_from_array(modis_06.temperature, index)
    ca_matchup.modis_lvl2.pressure = get_data_from_array(modis_06.pressure, index)
    ca_matchup.modis_lvl2.lwp = get_data_from_array(modis_06.lwp, index)
    ca_matchup.modis_lvl2.cloud_emissivity = get_data_from_array(modis_06.cloud_emissivity, index)
    ca_matchup.modis_lvl2.multilayer = get_data_from_array(modis_06.multilayer, index)

    ca_matchup.modis_lvl2.optical_depth = get_data_from_array(modis_06.optical_depth, index)