# 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

    od_gain = h5file['mod06']['Data Fields']['Cloud_Optical_Thickness'].attrs['scale_factor']
    od_intercept = h5file['mod06']['Data Fields']['Cloud_Optical_Thickness'].attrs['add_offset']
    od_nodata = h5file['mod06']['Data Fields']['Cloud_Optical_Thickness'].attrs['_FillValue']

    hmask = modis_06.height == h_nodata
    tmask = modis_06.temperature == t_nodata
    pmask = modis_06.pressure == p_nodata
    lwpmask = modis_06.lwp == lwp_nodata
    odmask = modis_06.optical_depth == od_nodata

    modis_06.height = modis_06.height.astype(np.float)
    modis_06.pressure = modis_06.pressure.astype(np.float)
    modis_06.temperature = modis_06.temperature.astype(np.float)
    modis_06.lwp = modis_06.lwp.astype(np.float)
    modis_06.optical_depth = modis_06.optical_depth.astype(np.float)
    modis_06.height[~hmask] = modis_06.height[~hmask] * h_gain + h_intercept
    modis_06.pressure[~pmask] = modis_06.pressure[~pmask] * p_gain + p_intercept
    modis_06.temperature[~tmask] = modis_06.temperature[~tmask] * t_gain - t_intercept * t_gain
    modis_06.lwp[~lwpmask] = modis_06.lwp[~lwpmask] * lwp_gain + lwp_intercept
    modis_06.optical_depth[~odmask] = modis_06.optical_depth[~odmask] * od_gain + od_intercept
    modis_06.height[hmask] = ATRAIN_MATCH_NODATA
    modis_06.pressure[pmask] = ATRAIN_MATCH_NODATA
    modis_06.temperature[tmask] = ATRAIN_MATCH_NODATA
    modis_06.lwp[lwpmask] = ATRAIN_MATCH_NODATA
    modis_06.optical_depth[odmask] = ATRAIN_MATCH_NODATA
    h5file.close()
    return modis_06



# 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


    od_gain = h5file['mod06']['Data Fields']['Cloud_Optical_Thickness'].attrs['scale_factor']
    od_intercept = h5file['mod06']['Data Fields']['Cloud_Optical_Thickness'].attrs['add_offset']
    od_nodata = h5file['mod06']['Data Fields']['Cloud_Optical_Thickness'].attrs['_FillValue']

    hmask = modis_06.height == h_nodata
    tmask = modis_06.temperature == t_nodata
    pmask = modis_06.pressure == p_nodata
    lwpmask = modis_06.lwp == lwp_nodata
    odmask = modis_06.optical_depth == od_nodata

    modis_06.height = modis_06.height.astype(np.float)
    modis_06.pressure = modis_06.pressure.astype(np.float)
    modis_06.temperature = modis_06.temperature.astype(np.float)
    modis_06.lwp = modis_06.lwp.astype(np.float)
    modis_06.optical_depth = modis_06.optical_depth.astype(np.float)
    modis_06.height[~hmask] = modis_06.height[~hmask] * h_gain + h_intercept
    modis_06.pressure[~pmask] = modis_06.pressure[~pmask] * p_gain + p_intercept
    modis_06.temperature[~tmask] = modis_06.temperature[~tmask] * t_gain - t_intercept * t_gain
    modis_06.lwp[~lwpmask] = modis_06.lwp[~lwpmask] * lwp_gain + lwp_intercept
    modis_06.optical_depth[~odmask] = modis_06.optical_depth[~odmask] * od_gain + od_intercept
    modis_06.height[hmask] = ATRAIN_MATCH_NODATA
    modis_06.pressure[pmask] = ATRAIN_MATCH_NODATA
    modis_06.temperature[tmask] = ATRAIN_MATCH_NODATA
    modis_06.lwp[lwpmask] = ATRAIN_MATCH_NODATA
    modis_06.optical_depth[odmask] = ATRAIN_MATCH_NODATA
    h5file.close()
    return modis_06



def read_modis_hdf(filename):