ClimoAccessor.enforce_global¶
- ClimoAccessor.enforce_global(longitude=True, latitude=True, vertical=False, zero=None)[source]¶
Add a circularly overlapping longitude coordinate, latitude coordinates for the north and south poles, and pressure coordinates for the mean sea-level and “zero” pressure levels. This ensures plots data coverage over the whole atmosphere and improves the accuracy of budget term calculations.
- Parameters
longitude (bool, optional) – Whether to enforce circular longitudes. Default is
True
.latitude (bool, optional) – Whether to enforce latitude coverage from pole-to-pole. Default is
True
.vertical (bool, optional) – Whether to enforce pressure level coverage from 0 hectoPascals to 1013.25 hectoPascals (mean sea-level pressure). Default is
False
.zero (bool or list of str, optional) – If this is a
DataArray
accessor, should be boolean indicating whether data at the pole coordinates should be zeroed (as should be the case for wind variables and extensive properties like eddy fluxes). If this is aDataset
accessor, should be list of variables that should be zeroed.
Examples
>>> import numpy as np >>> import xarray as xr >>> import climopy as climo >>> ds = xr.Dataset( ... coords={ ... 'lon': np.arange(0, 360, 30), ... 'lat': np.arange(-85, 86, 10), ... 'lev': ('lev', np.arange(100, 1000, 100), {'units': 'hPa'}), ... } ... ) >>> ds <xarray.Dataset> Dimensions: (lat: 18, lev: 9, lon: 12) Coordinates: * lon (lon) int64 0 30 60 90 120 150 180 210 240 270 300 330 * lat (lat) int64 -85 -75 -65 -55 -45 -35 -25 ... 25 35 45 55 65 75 85 * lev (lev) int64 100 200 300 400 500 600 700 800 900 Data variables: *empty* >>> ds = ds.climo.standardize_coords() >>> ds = ds.climo.enforce_global(vertical=True) >>> ds = ds.climo.add_cell_measures() >>> ds <xarray.Dataset> Dimensions: (lat: 20, lev: 11, lon: 13) Coordinates: * lon (lon) float64 -2.03e+04 0.0 30.0 60.0 ... 270.0 300.0 330.0 * lat (lat) float64 -90.0 -85.0 -75.0 -65.0 ... 65.0 75.0 85.0 90.0 * lev (lev) float64 0.0 100.0 200.0 300.0 ... 800.0 900.0 1.013e+03 cell_width (lat, lon) float64 6.91e-11 6.92e-11 ... 2.043e-13 1.021e-13 cell_depth (lat) float64 278.0 834.0 1.112e+03 ... 1.112e+03 834.0 278.0 cell_height (lev) float64 509.9 1.02e+03 1.02e+03 ... 1.087e+03 577.4 Data variables: *empty* Attributes: cell_measures: width: cell_width depth: cell_depth height: cell_height