The calculation of centroid lat and lon will depend on whether the coordinates provided are for the edges of the cells, or for the centers of the cells. Right now, it is kind of flawed:
- Center of mass is calculated based on the coordinates being the center. Wrong for ERA5, for example: the longitudes are 0.0, 0.25, etc., based on the lower left corner of each cell. Also wrong for x and y grid points.
- The longitude wrap-around assumes the coordinates are the edge when deciding whether to wrap around.
There probably needs to be a dataset option for whether the coordinates are the center of the grid cells, e.g.:
dataset['coordinates_are_grid_cell_edges'] = True
The calculation of centroid lat and lon will depend on whether the coordinates provided are for the edges of the cells, or for the centers of the cells. Right now, it is kind of flawed:
There probably needs to be a dataset option for whether the coordinates are the center of the grid cells, e.g.:
dataset['coordinates_are_grid_cell_edges'] = True