Skip to content
Snippets Groups Projects
Commit da3ec6cf authored by Simon Grasse's avatar Simon Grasse
Browse files

fix wrong grid distances

parent ebd4443d
Branches
Tags
1 merge request!11Creation of first beta release version
...@@ -53,21 +53,27 @@ class RegularGrid(GridDefinition): ...@@ -53,21 +53,27 @@ class RegularGrid(GridDefinition):
# TODO make sure only sensible resolutions # TODO make sure only sensible resolutions
self.lat_resolution = lat_resolution self.lat_resolution = lat_resolution
self.lon_resolution = lon_resolution self.lat_min = -90
n_lat = 180 / self.lat_resolution # TODO confirm self.lat_max = 90
n_lon = 360 / self.lon_resolution self.lat_span = self.lat_max - self.lat_min
print(n_lat, n_lon) 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.lon_resolution = lon_resolution
self.lat = np.linspace(-90, 90, int(n_lon) + 1) 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( self._as_xy_index = np.dstack(
np.meshgrid(range(self.lat.size), range(self.lon.size)) np.meshgrid(range(self.lat.size), range(self.lon.size))
).reshape(-1, 2) ).reshape(-1, 2)
self._as_i_index = np.arange(self.lon.size * self.lat.size).reshape( self._as_i_index = (
(self.lon.size, self.lat.size) 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): def as_xarray(self, timeseries_per_statistic, metadata):
datasets = dict() datasets = dict()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment