uxarray.UxDataArray.zonal_mean#
- UxDataArray.zonal_mean(lat=(-90, 90, 10), conservative=False, **kwargs)#
Compute non-conservative or conservative averages of a face-centered variable along lines of constant latitude or latitude bands.
A zonal mean in UXarray operates differently depending on the
conservativeflag:Non-conservative: Calculates the mean by sampling face values at specific latitude lines and weighting each contribution by the length of the line where each face intersects that latitude.
Conservative: Preserves integral quantities by calculating the mean by sampling face values within latitude bands and weighting contributions by their area overlap with latitude bands.
- Parameters:
lat (tuple, float, or array-like, default=(-90, 90, 10)) –
- Latitude specification:
tuple (start, end, step): For non-conservative, computes means at intervals of step.
For conservative, creates band edges via np.arange(start, end+step, step). - float: Single latitude for non-conservative averaging - array-like: For non-conservative, latitudes to sample. For conservative, band edges.
conservative (bool, default=False) – If True, performs conservative (area-weighted) zonal averaging over latitude bands. If False, performs non-conservative (intersection-weighted) averaging at latitude lines.
- Returns:
Contains zonal means with a new ‘latitudes’ dimension and corresponding coordinates. Name will be original_name + ‘_zonal_mean’ or ‘zonal_mean’ if unnamed.
- Return type:
Examples
# Non-conservative averaging from -90° to 90° at 10° intervals by default >>> uxds[“var”].zonal_mean()
# Single latitude (non-conservative) over 30° latitude >>> uxds[“var”].zonal_mean(lat=30.0)
# Conservative averaging over latitude bands >>> uxds[“var”].zonal_mean(lat=(-60, 60, 10), conservative=True)
# Conservative with explicit band edges >>> uxds[“var”].zonal_mean(lat=[-90, -30, 0, 30, 90], conservative=True)
Notes
Only supported for face-centered data variables.
Conservative averaging preserves integral quantities and is recommended for physical analysis. Non-conservative averaging samples at latitude lines.