Skip to content

Methods for grid data§

The methods in this page are accessible to a data object if:

<data_obj>.attrs['pic_data_type'] == 'grid'#(1)!
  1. <data_obj> may be either ozzy.DataArray or ozzy.Dataset

coords_from_extent §

coords_from_extent(mapping)

Add coordinates to DataArray | Dataset based on axis extents.

For each axis name and extent tuple in the mapping, get the axis values and assign them to a new coordinate in the data object.

Parameters:

Name Type Description Default

mapping §

dict[str, tuple[float, float]]

Dictionary mapping axis names to (min, max) extents

required

Returns:

Name Type Description
obj Same type as self._obj

Object with added coordinate values

Examples:

Example 1
import ozzy as oz
da = oz.DataArray(np.zeros((4,3)), dims=['x', 'y'], pic_data_type='grid')
mapping = {'x': (0, 1), 'y': (-1, 2)}
da = da.ozzy.coords_from_extent(mapping)

get_bin_edges §

get_bin_edges(t_var='t')

Get bin edges along each spatial axis.

Calculates bin edges from coordinate values. This is useful for binning operations (see example below).

Parameters:

Name Type Description Default

t_var §

str

Name of time dimension

't'

Returns:

Type Description
list[ndarray]

List of bin edges for each spatial axis

Examples:

Using numpy.histogramdd
import numpy as np
bin_edges = axes_ds.ozzy.get_bin_edges('t')
dist, edges = np.histogramdd(part_coords, bins=bin_edges, weights=ds_i[w_var])

get_space_dims §

get_space_dims(t_var='t')

Get names of spatial dimensions.

Returns coordinate names that are not the time dimension.

Parameters:

Name Type Description Default

t_var §

str

Name of time dimension

't'

Returns:

Type Description
list[str]

Spatial coordinate names

Examples:

Example 1
import ozzy as oz
ds = oz.Dataset(...)
spatial_dims = ds.ozzy.get_space_dims('t')
print(spatial_dims)