# Path: pyresample/test/utils.py
# def create_test_latitude(start, stop, shape, twist_factor=0.0, dtype=np.float32):
#     """Get basic sample of latitude data."""
#     num_cols = 1 if len(shape) < 2 else shape[1]
#     lat_col = np.linspace(start, stop, num=shape[0]).astype(dtype).reshape((shape[0], 1))
#     twist_array = np.arange(num_cols) * twist_factor
#     lat_array = np.repeat(lat_col, num_cols, axis=1)
#     lat_array += twist_array
#     return lat_array
# 
# def create_test_longitude(start, stop, shape, twist_factor=0.0, dtype=np.float32):
#     """Get basic sample of longitude data."""
#     if start > 0 > stop:
#         # cross anti-meridian
#         stop += 360.0
# 
#     num_cols = 1 if len(shape) < 2 else shape[1]
#     lon_row = np.linspace(start, stop, num=num_cols).astype(dtype)
#     twist_array = np.arange(shape[0]).reshape((shape[0], 1)) * twist_factor
#     lon_array = np.repeat([lon_row], shape[0], axis=0)
#     lon_array += twist_array
# 
#     if stop > 360.0:
#         lon_array[lon_array > 360.0] -= 360
#     return lon_array


import logging
import unittest
import numpy as np
from pyresample.test.utils import create_test_latitude, create_test_longitude
        from pyresample.ewa import _ll2cr
        from pyresample.ewa import _ll2cr
        from pyresample.ewa import _ll2cr
        from pyresample.ewa import _ll2cr
        from pyresample.ewa import _ll2cr
        from pyresample.ewa import _ll2cr
        from pyresample.ewa import ll2cr
        from pyresample.geometry import AreaDefinition, SwathDefinition
        from pyresample.utils import proj4_str_to_dict
        points_in_grid = _ll2cr.ll2cr_static(lon_arr, lat_arr, fill_in, proj_str,
                                             cw, ch, w, h, ox, oy)
        self.assertEqual(points_in_grid, 0, "none of these test points should fall in this grid")


class TestLL2CRDynamic(unittest.TestCase):
    """Test ll2cr when given partial area definition information."""

    def test_latlong_basic1(self):
        lon_arr = create_test_longitude(-95.0, -75.0, (50, 100), dtype=np.float64)
        lat_arr = create_test_latitude(15.0, 30.0, (50, 100), dtype=np.float64)
        grid_info = dynamic_wgs84.copy()
        fill_in = np.nan
        proj_str = grid_info["proj4_definition"]
        cw = grid_info["cell_width"]
        ch = grid_info["cell_height"]
        ox = grid_info["origin_x"]
        oy = grid_info["origin_y"]
        w = grid_info["width"]
        h = grid_info["height"]
        points_in_grid, lon_res, lat_res, ox, oy, w, h = _ll2cr.ll2cr_dynamic(lon_arr, lat_arr, fill_in, proj_str,
                                                                              cw, ch, w, h, ox, oy)
        self.assertEqual(points_in_grid, lon_arr.size, "all points should be contained in a dynamic grid")
        self.assertIs(lon_arr, lon_res)
        self.assertIs(lat_arr, lat_res)
        self.assertEqual(lon_arr[0, 0], 0, "ll2cr returned the wrong result for a dynamic latlong grid")
        self.assertEqual(lat_arr[-1, 0], 0, "ll2cr returned the wrong result for a dynamic latlong grid")

    def test_latlong_basic2(self):
        lon_arr = create_test_longitude(-95.0, -75.0, (50, 100), twist_factor=0.6, dtype=np.float64)

# Path: pyresample/test/utils.py
# def create_test_latitude(start, stop, shape, twist_factor=0.0, dtype=np.float32):
#     """Get basic sample of latitude data."""
#     num_cols = 1 if len(shape) < 2 else shape[1]
#     lat_col = np.linspace(start, stop, num=shape[0]).astype(dtype).reshape((shape[0], 1))
#     twist_array = np.arange(num_cols) * twist_factor
#     lat_array = np.repeat(lat_col, num_cols, axis=1)
#     lat_array += twist_array
#     return lat_array
# 
# def create_test_longitude(start, stop, shape, twist_factor=0.0, dtype=np.float32):
#     """Get basic sample of longitude data."""
#     if start > 0 > stop:
#         # cross anti-meridian
#         stop += 360.0
# 
#     num_cols = 1 if len(shape) < 2 else shape[1]
#     lon_row = np.linspace(start, stop, num=num_cols).astype(dtype)
#     twist_array = np.arange(shape[0]).reshape((shape[0], 1)) * twist_factor
#     lon_array = np.repeat([lon_row], shape[0], axis=0)
#     lon_array += twist_array
# 
#     if stop > 360.0:
#         lon_array[lon_array > 360.0] -= 360
#     return lon_array


# Path: pyresample/test/test_ewa_ll2cr.py
import logging
import unittest
import numpy as np
from pyresample.test.utils import create_test_latitude, create_test_longitude
        from pyresample.ewa import _ll2cr
        from pyresample.ewa import _ll2cr
        from pyresample.ewa import _ll2cr
        from pyresample.ewa import _ll2cr
        from pyresample.ewa import _ll2cr
        from pyresample.ewa import _ll2cr
        from pyresample.ewa import ll2cr
        from pyresample.geometry import AreaDefinition, SwathDefinition
        from pyresample.utils import proj4_str_to_dict

        points_in_grid = _ll2cr.ll2cr_static(lon_arr, lat_arr, fill_in, proj_str,
                                             cw, ch, w, h, ox, oy)
        self.assertEqual(points_in_grid, 0, "none of these test points should fall in this grid")


class TestLL2CRDynamic(unittest.TestCase):
    """Test ll2cr when given partial area definition information."""

    def test_latlong_basic1(self):
        lon_arr = create_test_longitude(-95.0, -75.0, (50, 100), dtype=np.float64)
        lat_arr = create_test_latitude(15.0, 30.0, (50, 100), dtype=np.float64)
        grid_info = dynamic_wgs84.copy()
        fill_in = np.nan
        proj_str = grid_info["proj4_definition"]
        cw = grid_info["cell_width"]
        ch = grid_info["cell_height"]
        ox = grid_info["origin_x"]
        oy = grid_info["origin_y"]
        w = grid_info["width"]
        h = grid_info["height"]
        points_in_grid, lon_res, lat_res, ox, oy, w, h = _ll2cr.ll2cr_dynamic(lon_arr, lat_arr, fill_in, proj_str,
                                                                              cw, ch, w, h, ox, oy)
        self.assertEqual(points_in_grid, lon_arr.size, "all points should be contained in a dynamic grid")
        self.assertIs(lon_arr, lon_res)
        self.assertIs(lat_arr, lat_res)
        self.assertEqual(lon_arr[0, 0], 0, "ll2cr returned the wrong result for a dynamic latlong grid")
        self.assertEqual(lat_arr[-1, 0], 0, "ll2cr returned the wrong result for a dynamic latlong grid")

    def test_latlong_basic2(self):
        lon_arr = create_test_longitude(-95.0, -75.0, (50, 100), twist_factor=0.6, dtype=np.float64)

        lat_arr = create_test_latitude(15.0, 30.0, (50, 100), twist_factor=-0.1, dtype=np.float64)