Ejemplo n.º 1
0
 def testlonlat2cell_hist(self):
     """
     setup grid with unequal cell size along lat and lon
     and test if the correct number of points lay in each cell
     """
     cells = lonlat2cell(
         self.lons, self.lats, cellsize_lon=15, cellsize_lat=30)
     hist, bin_edges = np.histogram(
         cells.flatten(), bins=len(np.unique(cells)))
     nptest.assert_allclose(hist, np.zeros_like(hist) + 72)
Ejemplo n.º 2
0
    def setUp(self):
        lat, lon = np.arange(180) - 90, np.arange(360) - 180
        self.lats, self.lons = np.meshgrid(lat, lon)
        self.lats, self.lons = self.lats.flatten(), self.lons.flatten()
        self.cells = grids.lonlat2cell(self.lons, self.lats)
        self.subset = np.sort(np.random.choice(np.arange(self.lats.size), size=500, replace=False))
        self.basic = grids.BasicGrid(self.lons, self.lats, subset=self.subset, shape=(360, 180))
        self.basic_irregular = grids.BasicGrid(self.lons, self.lats, subset=self.subset)
        self.cellgrid = grids.CellGrid(self.lons, self.lats, self.cells, subset=self.subset)

        self.testfilename = os.path.join(curpath(), "data", "test.nc")
        if not os.path.exists(os.path.join(curpath(), "data")):
            os.mkdir(os.path.join(curpath(), "data"))