How to use the pyinterp.Binning2D function in pyinterp

To help you get started, we’ve selected a few pyinterp examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github CNES / pangeo-pyinterp / tests / test_binning.py View on Github external
def init(self, dtype):
        ds = xr.load_dataset(self.GRID)

        x_axis = pyinterp.Axis(np.arange(-180, 180, 5), is_circle=True)
        y_axis = pyinterp.Axis(np.arange(-90, 95, 5))
        binning = pyinterp.Binning2D(x_axis,
                                     y_axis,
                                     pyinterp.geodetic.System(),
                                     dtype=dtype)
        self.assertEqual(x_axis, binning.x)
        self.assertEqual(y_axis, binning.y)
        self.assertIsInstance(str(binning), str)

        lon, lat = np.meshgrid(ds.lon, ds.lat)
        binning.push(lon, lat, ds.mss, simple=True)
        simple_mean = binning.variable('mean')
        self.assertIsInstance(simple_mean, np.ndarray)

        binning.clear()
        binning.push(lon, lat, ds.mss, simple=False)
        linear_mean = binning.variable('mean')
        self.assertIsInstance(simple_mean, np.ndarray)