# Path: atrain_match/config.py
# RESOLUTION = int(os.environ.get('ATRAIN_RESOLUTION', 5))
# 
# NODATA = -9


import numpy as np
import logging
from atrain_match.config import RESOLUTION, NODATA
    from pyresample.geometry import SwathDefinition
    from pyresample.kd_tree import get_neighbour_info
    from pyresample.kd_tree import get_sample_from_neighbour_info
# along with atrain_match.  If not, see <http://www.gnu.org/licenses/>.
"""Match TRUTH and IMAGER data."""

# from __future__ import with_statement
logger = logging.getLogger(__name__)


class MatchMapper(object):
    """
    Map arrays from one swath to another.

    Note that MatchMapper always works with an extra dimension: neighbour

    """

    def __init__(self, rows, cols, pixel_mask, time_diff=None,
                 time_threshold=None):
        self._rows = np.array(rows).astype(np.int)
        self._cols = np.array(cols).astype(np.int)
        self._pixel_mask = pixel_mask
        self._time_diff = time_diff
        self.time_threshold = time_threshold

    def __call__(self, array):
        """Maps *array* to target swath."""
        return np.ma.array(array[self.rows, self.cols], mask=self.mask)

    @property
    def rows(self):
        # self._rows = np.array(self._rows, dtype=np.int64)

# Path: atrain_match/config.py
# RESOLUTION = int(os.environ.get('ATRAIN_RESOLUTION', 5))
# 
# NODATA = -9


# Path: atrain_match/utils/match.py
import numpy as np
import logging
from atrain_match.config import RESOLUTION, NODATA
    from pyresample.geometry import SwathDefinition
    from pyresample.kd_tree import get_neighbour_info
    from pyresample.kd_tree import get_sample_from_neighbour_info

# along with atrain_match.  If not, see <http://www.gnu.org/licenses/>.
"""Match TRUTH and IMAGER data."""

# from __future__ import with_statement
logger = logging.getLogger(__name__)


class MatchMapper(object):
    """
    Map arrays from one swath to another.

    Note that MatchMapper always works with an extra dimension: neighbour

    """

    def __init__(self, rows, cols, pixel_mask, time_diff=None,
                 time_threshold=None):
        self._rows = np.array(rows).astype(np.int)
        self._cols = np.array(cols).astype(np.int)
        self._pixel_mask = pixel_mask
        self._time_diff = time_diff
        self.time_threshold = time_threshold

    def __call__(self, array):
        """Maps *array* to target swath."""
        return np.ma.array(array[self.rows, self.cols], mask=self.mask)

    @property
    def rows(self):
        # self._rows = np.array(self._rows, dtype=np.int64)

        return np.ma.array(self._rows, mask=self.mask, fill_value=NODATA,