Skip to content

Commit 83904e5

Browse files
mjwillsonWeatherBenchX authors
authored andcommitted
No public description
PiperOrigin-RevId: 869231897
1 parent 7576732 commit 83904e5

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

weatherbenchX/weighting.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ def _is_uniformly_spaced(vector):
5858
return np.all(np.isclose(expected_diff, diff, rtol=1e-4))
5959

6060

61-
def _latitude_cell_bounds(x: np.ndarray) -> np.ndarray:
61+
def latitude_cell_bounds(x: np.ndarray) -> np.ndarray:
62+
"""Bounds for latitude cells, given increasing cell centers in radians."""
6263
assert _is_increasing(x), 'Points must be increasing.'
6364
diff = np.diff(x)
6465

@@ -77,9 +78,9 @@ def _latitude_cell_bounds(x: np.ndarray) -> np.ndarray:
7778
])
7879

7980

80-
def _cell_area_from_latitude(points: np.ndarray) -> np.ndarray:
81+
def cell_area_from_latitude(points: np.ndarray) -> np.ndarray:
8182
"""Calculate the area overlap as a function of latitude."""
82-
bounds = _latitude_cell_bounds(points)
83+
bounds = latitude_cell_bounds(points)
8384
upper = bounds[1:]
8485
lower = bounds[:-1]
8586
# Normalized cell area: integral from lower to upper of cos(latitude).
@@ -119,7 +120,7 @@ def weights(
119120
else:
120121
needs_reversing = False
121122

122-
weights = _cell_area_from_latitude(np.deg2rad(latitude))
123+
weights = cell_area_from_latitude(np.deg2rad(latitude))
123124
if needs_reversing:
124125
weights = weights[::-1]
125126
if self.return_normalized:

0 commit comments

Comments
 (0)