예제 #1
0
    def get_embedding(self):
        self.valid_data = None
        if self.data is None:
            return None

        lat_data = self.get_column(self.attr_lat, filter_valid=False)
        lon_data = self.get_column(self.attr_lon, filter_valid=False)
        if lat_data is None or lon_data is None:
            return None

        self.Warning.missing_coords.clear()
        self.Information.missing_coords.clear()
        self.valid_data = np.isfinite(lat_data) & np.isfinite(lon_data)
        if self.valid_data is not None and not np.all(self.valid_data):
            msg = self.Information if np.any(self.valid_data) else self.Warning
            msg.missing_coords(self.attr_lat.name, self.attr_lon.name)

        in_range = (-MAX_LONGITUDE <= lon_data) & (lon_data <= MAX_LONGITUDE) &\
                   (-MAX_LATITUDE <= lat_data) & (lat_data <= MAX_LATITUDE)
        in_range = ~np.bitwise_xor(in_range, self.valid_data)
        self.Warning.out_of_range.clear()
        if in_range.sum() != len(lon_data):
            self.Warning.out_of_range()
        if in_range.sum() == 0:
            return None
        self.valid_data &= in_range

        x, y = deg2norm(lon_data, lat_data)
        # invert y to increase from bottom to top
        y = 1 - y
        return np.vstack((x, y)).T
예제 #2
0
    def test_deg_mapping(self):
        lon = np.array([-200, -180, 0, 180, 200])
        lat = np.array([-90, -85.0511, 0, 85.0511, 90])

        x, y = deg2norm(lon, lat)
        np.testing.assert_almost_equal(np.array([0, 0, 0.5, 1, 1]), x,
                                       decimal=3)
        np.testing.assert_almost_equal(np.array([1, 1, 0.5, 0, 0]), y,
                                       decimal=3)
예제 #3
0
 def deg2canvas(x, y):
     x, y = deg2norm(x, y)
     y = 1 - y
     return x, y