uxarray.grid.geometry._populate_bounds

uxarray.grid.geometry._populate_bounds#

uxarray.grid.geometry._populate_bounds(grid, is_latlonface=False, is_face_GCA_list=None, return_array=False)#

Populates the bounds of the grid based on the geometry of its faces, taking into account special conditions such as faces crossing the antimeridian or containing pole points. This method updates the grid’s internal representation to include accurate bounds for each face, returned as a DataArray with detailed attributes.

Parameters:
  • is_latlonface (bool, optional) – A global flag that indicates if faces are latlon faces. If True, all faces are treated as latlon faces, meaning that all edges are either longitude or constant latitude lines. If False, all edges are considered as Great Circle Arcs (GCA). Default is False.

  • is_face_GCA_list (list or np.ndarray, optional) – A list or an array of boolean values for each face, indicating whether each edge in that face is a GCA. The shape of the list or array should be (n_faces, n_edges), with each sub-list or sub-array like [True, False, True, False] indicating the nature of each edge (GCA or constant latitude line) in a face. This parameter allows for mixed face types within the grid by specifying the edge type at the face level. If None, all edges are considered as GCA. This parameter, if provided, will overwrite the is_latlonface attribute for specific faces. Default is None.

Returns:

A DataArray containing the latitude and longitude bounds for each face in the grid, expressed in radians. The array has dimensions [“n_face”, “Two”, “Two”], where “Two” is a literal dimension name indicating two bounds (min and max) for each of latitude and longitude. The DataArray includes attributes detailing its purpose and the mapping of latitude intervals to face indices.

Attributes include: - cf_role: Describes the role of the DataArray, here indicating face latitude bounds. - _FillValue: The fill value used in the array, indicating uninitialized or missing data. - long_name: A descriptive name for the DataArray. - start_index: The starting index for face indices in the grid. - latitude_intervalsIndex: An IntervalIndex indicating the latitude intervals. - latitude_intervals_name_map: A DataFrame mapping the latitude intervals to face indices.

Return type:

xr.DataArray

Example

Consider a scenario where you have four faces on a grid, each defined by vertices in longitude and latitude degrees:

face_1 = [[10.0, 60.0], [10.0, 10.0], [50.0, 10.0], [50.0, 60.0]] face_2 = [[350, 60.0], [350, 10.0], [50.0, 10.0], [50.0, 60.0]] face_3 = [[210.0, 80.0], [350.0, 60.0], [10.0, 60.0], [30.0, 80.0]] face_4 = [[200.0, 80.0], [350.0, 60.0], [10.0, 60.0], [40.0, 80.0]]

After defining these faces, you can create a grid and populate its bounds by treating all faces as latlon faces:

grid = ux.Grid.from_face_vertices([face_1, face_2, face_3, face_4], latlon=True) bounds_dataarray = grid._populate_bounds(is_latlonface=True)

This will calculate and store the bounds for each face within the grid, adjusting for any special conditions such as crossing the antimeridian, and return them as a DataArray.