def make_corners(self):
x = self.x_t
y = self.y_t
dx_half = self.dx / 2.0
dy_half = self.dy / 2.0
# Set grid corners, we do these one corner at a time. Start at the
# bottom left and go anti-clockwise. This is the SCRIP convention.
clon = np.empty((self.num_lat_points, self.num_lon_points, 4))
clon[:] = np.NAN
clon[:,:,0] = x - dx_half
clon[:,:,1] = x + dx_half
clon[:,:,2] = x + dx_half
clon[:,:,3] = x - dx_half
assert(not np.isnan(np.sum(clon)))
clat = np.empty((self.num_lat_points, self.num_lon_points, 4))
clat[:] = np.NAN
clat[:,:,0] = y - dy_half
clat[:,:,1] = y - dy_half
clat[:,:,2] = y + dy_half
clat[:,:,3] = y + dy_half
assert(not np.isnan(np.sum(clat)))
# The bottom latitude band should always be Southern extent.
assert(np.all(clat[0, :, 0] == np.min(y) - dy_half))
assert(np.all(clat[0, :, 1] == np.min(y) - dy_half))
# The top latitude band should always be Northern extent.
assert(np.all(clat[-1, :, 2] == np.max(y) + dy_half))
assert(np.all(clat[-1, :, 3] == np.max(y) + dy_half))
self.clon_t = clon
self.clat_t = clat
评论列表
文章目录