# 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
        cols = NODATA + np.zeros((len(cols_0), n_neighbours))
        rows[:, 0] = rows_0
        cols[:, 0] = cols_0
        for i in range(1, n_neighbours):
            cols[:, i] = get_sample_from_neighbour_info('nn', target_def.shape,
                                                        cols_matrix,
                                                        valid_in, valid_out,
                                                        indices[:, i])
            rows[:, i] = get_sample_from_neighbour_info('nn', target_def.shape,
                                                        rows_matrix,
                                                        valid_in, valid_out,
                                                        indices[:, i])
            test = (distances[:, 0] - distances[:, i])
            if sum(~np.isnan(test)) > 0 and np.max(test[~np.isnan(test)]) > 0:
                raise ValueError(
                    'We count on the first neighbour beeing the closest')

    rows = np.array(rows)
    cols = np.array(cols)
    # import pdb; pdb.set_trace()
    """ Code used during debugging, leaving it here for now
    if indices.dtype in ['uint32']:
        # With pykdtree installed get_neighbour_info returns indices
        # as type uint32
        # This does not combine well with a nodata value of -9.
        indices = np.array(indices, dtype=np.int64)
    """
    # Make sure all indices are valid
    # import pdb; pdb.set_trace()
    rows[rows >= source_def.shape[0]] = NODATA

# 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

        cols = NODATA + np.zeros((len(cols_0), n_neighbours))
        rows[:, 0] = rows_0
        cols[:, 0] = cols_0
        for i in range(1, n_neighbours):
            cols[:, i] = get_sample_from_neighbour_info('nn', target_def.shape,
                                                        cols_matrix,
                                                        valid_in, valid_out,
                                                        indices[:, i])
            rows[:, i] = get_sample_from_neighbour_info('nn', target_def.shape,
                                                        rows_matrix,
                                                        valid_in, valid_out,
                                                        indices[:, i])
            test = (distances[:, 0] - distances[:, i])
            if sum(~np.isnan(test)) > 0 and np.max(test[~np.isnan(test)]) > 0:
                raise ValueError(
                    'We count on the first neighbour beeing the closest')

    rows = np.array(rows)
    cols = np.array(cols)
    # import pdb; pdb.set_trace()
    """ Code used during debugging, leaving it here for now
    if indices.dtype in ['uint32']:
        # With pykdtree installed get_neighbour_info returns indices
        # as type uint32
        # This does not combine well with a nodata value of -9.
        indices = np.array(indices, dtype=np.int64)
    """
    # Make sure all indices are valid
    # import pdb; pdb.set_trace()
    rows[rows >= source_def.shape[0]] = NODATA

    cols[cols >= source_def.shape[1]] = NODATA