diff --git a/toargridding/grids.py b/toargridding/grids.py index ae8abd93aecd2a91c115886a62538a909981ae0e..cb140672f97a3c4c60cd9819b2952d401792fbf9 100644 --- a/toargridding/grids.py +++ b/toargridding/grids.py @@ -53,21 +53,27 @@ class RegularGrid(GridDefinition): # TODO make sure only sensible resolutions self.lat_resolution = lat_resolution - self.lon_resolution = lon_resolution - n_lat = 180 / self.lat_resolution # TODO confirm - n_lon = 360 / self.lon_resolution - print(n_lat, n_lon) + self.lat_min = -90 + self.lat_max = 90 + self.lat_span = self.lat_max - self.lat_min + self.lat_n = int(self.lat_span / self.lat_resolution) + self.lat = np.linspace(self.lat_min, self.lat_max, self.lat_n + 1) - self.lon = np.linspace(-180, 180, int(n_lat) + 1) - self.lat = np.linspace(-90, 90, int(n_lon) + 1) + self.lon_resolution = lon_resolution + self.lon_min = -180 + self.lon_max = 180 + self.lon_span = self.lon_max - self.lon_min + self.lon_n = int(self.lon_span / self.lon_resolution) + self.lon = np.linspace(self.lon_min, self.lon_max, self.lon_n + 1) self._as_xy_index = np.dstack( np.meshgrid(range(self.lat.size), range(self.lon.size)) ).reshape(-1, 2) - self._as_i_index = np.arange(self.lon.size * self.lat.size).reshape( - (self.lon.size, self.lat.size) + self._as_i_index = ( + np.arange(self.lon.size * self.lat.size) + .reshape((self.lon.size, self.lat.size)) + .T ) - print(self._as_i_index.shape) def as_xarray(self, timeseries_per_statistic, metadata): datasets = dict()