uxarray.UxDataArray#
- class uxarray.UxDataArray(*args, uxgrid=None, **kwargs)#
Grid informed
xarray.DataArraywith an attachedGridaccessor and grid-specific functionality.- Parameters:
uxgrid (uxarray.Grid, optional) – The Grid object that makes this array aware of the unstructured grid topology it belongs to. If None, it needs to be an instance of uxarray.Grid.
*args – Arguments for the
xarray.DataArrayclass**kwargs – Keyword arguments for the
xarray.DataArrayclass
Notes
See xarray.DataArray for further information about DataArrays.
Grid-Aware Accessor Methods#
The following methods return specialized accessors that preserve grid information:
groupby: Groups data by dimension/coordinategroupby_bins: Groups data by binsresample: Resamples timeseries datarolling: Rolling window operationscoarsen: Coarsens data by integer factorsweighted: Weighted operationsrolling_exp: Exponentially weighted rolling (requires numbagg)cumulative: Cumulative operations
All these methods work identically to xarray but maintain the uxgrid attribute throughout operations.
- __init__(*args, uxgrid=None, **kwargs)#
Methods
__init__(*args[, uxgrid])all([dim, keep_attrs])Reduce this DataArray's data by applying
allalong some dimension(s).any([dim, keep_attrs])Reduce this DataArray's data by applying
anyalong some dimension(s).argmax([dim, axis, keep_attrs, skipna])Index or indices of the maximum of the DataArray over one or more dimensions.
argmin([dim, axis, keep_attrs, skipna])Index or indices of the minimum of the DataArray over one or more dimensions.
argsort([axis, kind, order])Returns the indices that would sort this array.
as_numpy()Coerces wrapped data and coordinates into numpy arrays, returning a DataArray.
assign_attrs(*args, **kwargs)Assign new attrs to this object.
assign_coords([coords])Assign new coordinates to this object.
astype(dtype, *[, order, casting, subok, ...])Copy of the xarray object, with data cast to a specified type.
azimuthal_average(center_coord, ...[, ...])Compute averages along circles of constant great-circle distance from a point.
azimuthal_mean(center_coord, outer_radius, ...)Compute averages along circles of constant great-circle distance from a point.
bfill(dim[, limit])Fill NaN values by propagating values backward
broadcast_equals(other)Two DataArrays are broadcast equal if they are equal after broadcasting them against each other such that they have the same dimensions.
broadcast_like(other, *[, exclude])Broadcast this DataArray against another Dataset or DataArray.
chunk([chunks, name_prefix, token, lock, ...])Coerce this array's data into a dask arrays with the given chunks.
clip([min, max, keep_attrs])Return an array whose values are limited to
[min, max].close()Release any resources linked to this object.
coarsen([dim, boundary, side, coord_func])Coarsen object for DataArrays.
combine_first(other)Combine two DataArray objects, with union of coordinates.
compute(**kwargs)Trigger loading data into memory and return a new dataarray.
conj()Complex-conjugate all elements.
conjugate(*args, **kwargs)a.conj()
convert_calendar(calendar[, dim, align_on, ...])Convert the DataArray to another calendar.
copy([deep, data])Returns a copy of this array.
count([dim, keep_attrs])Reduce this DataArray's data by applying
countalong some dimension(s).cumprod([dim, skipna, keep_attrs])Reduce this DataArray's data by applying
cumprodalong some dimension(s).cumsum([dim, skipna, keep_attrs])Reduce this DataArray's data by applying
cumsumalong some dimension(s).cumulative(dim[, min_periods])Accumulating object for DataArrays.
cumulative_integrate([coord, datetime_unit])Integrate cumulatively along the given coordinate using the trapezoidal rule.
curl(other, **kwargs)Computes the curl of a vector field.
curvefit(coords, func[, reduce_dims, ...])Curve fitting optimization for arbitrary functions.
diff(dim[, n, label])Calculate the n-th order discrete difference along given axis.
difference([destination])Computes the absolute difference of a data variable.
differentiate(coord[, edge_order, datetime_unit])Differentiate the array with the second order accurate central differences.
divergence(other, **kwargs)Computes the divergence of the vector field defined by this UxDataArray and other.
dot(other[, dim])Perform dot product of two DataArrays along their shared dims.
drop([labels, dim, errors])Backward compatible method based on drop_vars and drop_sel
drop_attrs(*[, deep])Removes all attributes from the DataArray.
drop_duplicates(dim, *[, keep])Returns a new DataArray with duplicate dimension values removed.
drop_encoding()Return a new DataArray without encoding on the array or any attached coords.
drop_indexes(coord_names, *[, errors])Drop the indexes assigned to the given coordinates.
drop_isel([indexers])Drop index positions from this DataArray.
drop_sel([labels, errors])Drop index labels from this DataArray.
drop_vars(names, *[, errors])Returns an array with dropped variables.
dropna(dim, *[, how, thresh])Returns a new array with dropped labels for missing values along the provided dimension.
equals(other)True if two DataArrays have the same dimensions, coordinates and values; otherwise False.
expand_dims([dim, axis, ...])Return a new object with an additional axis (or axes) inserted at the corresponding position in the array shape.
ffill(dim[, limit])Fill NaN values by propagating values forward
fillna(value)Fill missing values in this object.
from_dict(d)Convert a dictionary into an xarray.DataArray
from_healpix(da[, pixels_only, face_dim])Loads a data array represented in the HEALPix format into a
ux.UxDataArray, paired with aGridcontaining information about the HEALPix definition.from_iris(cube)Convert an iris.cube.Cube into an xarray.DataArray
from_series(series[, sparse])Convert a pandas.Series into an xarray.DataArray.
from_xarray(da, uxgrid[, ugrid_dims])Converts a
xarray.DataArrayinto auxarray.UxDatasetpaired with a user-definedGridget_axis_num(dim)Return axis number(s) corresponding to dimension(s) in this array.
get_dual()Compute the dual mesh for a data array, returns a new data array object.
get_index(key)Get an index for a dimension, with fall-back to a default RangeIndex
gradient(**kwargs)Computes the gradient of a data variable.
groupby([group, squeeze, ...])Returns a DataArrayGroupBy object for performing grouped operations.
groupby_bins(group, bins[, right, labels, ...])Returns a DataArrayGroupBy object for performing grouped operations.
head([indexers])Return a new DataArray whose data is given by the the first n values along the specified dimension(s).
identical(other)Like equals, but also checks the array name, attributes, attributes on all coordinates, and indexes.
idxmax([dim, skipna, fill_value, keep_attrs])Return the coordinate label of the maximum value along a dimension.
idxmin([dim, skipna, fill_value, keep_attrs])Return the coordinate label of the minimum value along a dimension.
integrate([quadrature_rule, order])Computes the integral of a data variable.
interp([coords, method, assume_sorted, kwargs])Interpolate a DataArray onto new coordinates.
interp_calendar(target[, dim])Interpolates the DataArray to another calendar based on decimal year measure.
interp_like(other[, method, assume_sorted, ...])Interpolate this object onto the coordinates of another object, filling out of range values with NaN.
interpolate_na([dim, method, limit, ...])Fill in NaNs by interpolating according to different methods.
isel([indexers, drop, missing_dims, ...])Return a new DataArray whose data is given by selecting indexes along the specified dimension(s).
isin(test_elements)Tests each value in the array for whether it is in test elements.
isnull([keep_attrs])Test each value in the array for whether it is a missing value.
item(*args)Copy an element of an array to a standard Python scalar and return it.
load(**kwargs)Trigger loading data into memory and return this dataarray.
load_async(**kwargs)Trigger and await asynchronous loading of data into memory and return this dataarray.
map_blocks(func[, args, kwargs, template])Apply a function to each block of this DataArray.
max([dim, skipna, keep_attrs])Reduce this DataArray's data by applying
maxalong some dimension(s).mean([dim, skipna, keep_attrs])Reduce this DataArray's data by applying
meanalong some dimension(s).median([dim, skipna, keep_attrs])Reduce this DataArray's data by applying
medianalong some dimension(s).min([dim, skipna, keep_attrs])Reduce this DataArray's data by applying
minalong some dimension(s).notnull([keep_attrs])Test each value in the array for whether it is not a missing value.
pad([pad_width, mode, stat_length, ...])Pad this array along one or more dimensions.
persist(**kwargs)Trigger computation in constituent dask arrays
pipe(func, *args, **kwargs)Apply
func(self, *args, **kwargs)polyfit(dim, deg[, skipna, rcond, w, full, cov])Least squares polynomial fit.
prod([dim, skipna, min_count, keep_attrs])Reduce this DataArray's data by applying
prodalong some dimension(s).quantile(q[, dim, method, keep_attrs, ...])Compute the qth quantile of the data along the specified dimension.
query([queries, parser, engine, missing_dims])Return a new data array indexed along the specified dimension(s), where the indexers are given as strings containing Python expressions to be evaluated against the values in the array.
rank(dim, *[, pct, keep_attrs])Ranks the data.
reduce(func[, dim, axis, keep_attrs, keepdims])Reduce this array by applying func along some dimension(s).
reindex([indexers, method, tolerance, copy, ...])Conform this object onto the indexes of another object, filling in missing values with
fill_value.reindex_like(other, *[, method, tolerance, ...])Conform this object onto the indexes of another object, for indexes which the objects share.
rename([new_name_or_name_dict])Returns a new DataArray with renamed coordinates, dimensions or a new name.
reorder_levels([dim_order])Rearrange index levels using input order.
resample([indexer, skipna, closed, label, ...])Returns a Resample object for performing resampling operations.
reset_coords([names, drop])Given names of coordinates, reset them to become variables.
reset_encoding()reset_index(dims_or_levels[, drop])Reset the specified index(es) or multi-index level(s).
roll([shifts, roll_coords])Roll this array by an offset along one or more dimensions.
rolling([dim, min_periods, center])Rolling window object for DataArrays.
rolling_exp([window, window_type])Exponentially-weighted moving window.
round(*args, **kwargs)searchsorted(v[, side, sorter])Find indices where elements of v should be inserted in a to maintain order.
sel([indexers, method, tolerance, drop])Return a new DataArray whose data is given by selecting index labels along the specified dimension(s).
set_close(close)Register the function that releases any resources linked to this object.
set_index([indexes, append])Set DataArray (multi-)indexes using one or more existing coordinates.
set_xindex(coord_names[, index_cls])Set a new, Xarray-compatible index from one or more existing coordinate(s).
shift([shifts, fill_value])Shift this DataArray by an offset along one or more dimensions.
sortby(variables[, ascending])Sort object by labels or values (along an axis).
squeeze([dim, drop, axis])Return a new object with squeezed data.
stack([dim, create_index, index_cls])Stack any number of existing dimensions into a single new dimension.
std([dim, skipna, ddof, keep_attrs])Reduce this DataArray's data by applying
stdalong some dimension(s).sum([dim, skipna, min_count, keep_attrs])Reduce this DataArray's data by applying
sumalong some dimension(s).swap_dims([dims_dict])Returns a new DataArray with swapped dimensions.
tail([indexers])Return a new DataArray whose data is given by the the last n values along the specified dimension(s).
thin([indexers])Return a new DataArray whose data is given by each n value along the specified dimension(s).
to_dask_dataframe([dim_order, set_index])Convert this array into a dask.dataframe.DataFrame.
to_dataframe([name, dim_order])Convert this array and its coordinates into a tidy pandas.DataFrame.
to_dataset([dim, name, promote_attrs])Convert a
UxDataArrayto aUxDataset.to_dict([data, encoding])Convert this xarray.DataArray into a dictionary following xarray naming conventions.
to_geodataframe([periodic_elements, ...])Constructs a
GeoDataFrameconsisting of polygons representing the faces of the currentGridwith a face-centered data variable mapped to them.to_index()Convert this variable to a pandas.Index.
to_iris()Convert this array into an iris.cube.Cube
to_masked_array([copy])Convert this array into a numpy.ma.MaskedArray
to_netcdf([path, mode, format, group, ...])Write DataArray contents to a netCDF file.
to_numpy()Coerces wrapped data to numpy and returns a numpy.ndarray.
to_pandas()Convert this array into a pandas object with the same shape.
to_polycollection([periodic_elements, ...])Constructs a
matplotlib.collections.PolyCollection`consisting of polygons representing the faces of the currentUxDataArraywith a face-centered data variable mapped to them.to_raster(ax, *[, pixel_ratio, ...])Rasterizes a data variable stored on the faces of an unstructured grid onto the pixels of the provided Cartopy GeoAxes.
to_series()Convert this array into a pandas.Series.
to_unstacked_dataset(dim[, level])Unstack DataArray expanding to Dataset along a given level of a stacked coordinate.
to_zarr([store, chunk_store, mode, ...])Write DataArray contents to a Zarr store
topological_all([destination])Performs a topological all aggregation.
topological_any([destination])Performs a topological any aggregation.
topological_max([destination])Performs a topological max aggregation.
topological_mean(destination, **kwargs)Performs a topological mean aggregation.
topological_median([destination])Performs a topological median aggregation.
topological_min([destination])Performs a topological min aggregation.
topological_prod([destination])Performs a topological prod aggregation.
topological_std([destination])Performs a topological std aggregation.
topological_sum([destination])Performs a topological sum aggregation.
topological_var([destination])Performs a topological var aggregation.
transpose(*dim[, transpose_coords, missing_dims])Return a new DataArray object with transposed dimensions.
unify_chunks()Unify chunk size along all chunked dimensions of this DataArray.
unstack([dim, fill_value, sparse])Unstack existing dimensions corresponding to MultiIndexes into multiple new dimensions.
var([dim, skipna, ddof, keep_attrs])Reduce this DataArray's data by applying
varalong some dimension(s).weighted(weights)Weighted DataArray operations.
weighted_mean([weights])Computes a weighted mean.
where(cond[, other, drop])Filter elements from this object according to a condition.
zonal_average([lat, conservative])Alias of zonal_mean; prefer zonal_mean for primary API.
zonal_mean([lat, conservative])Compute non-conservative or conservative averages of a face-centered variable along lines of constant latitude or latitude bands.
Attributes
TattrsDictionary storing arbitrary metadata with this array.
chunksTuple of block lengths for this dataarray's data, in order of dimensions, or None if the underlying data is not a dask array.
chunksizesMapping from dimension names to block lengths for this dataarray's data.
coordsMapping of
DataArrayobjects corresponding to coordinate variables.dataThe DataArray's data as an array.
data_mappingReturns which unstructured grid a data variable is mapped to.
dimsTuple of dimension names associated with this array.
dtalias of
CombinedDatetimelikeAccessor[DataArray]dtypeData-type of the array’s elements.
encodingDictionary of format-specific settings for how this array should be serialized.
imagThe imaginary part of the array.
indexesMapping of pandas.Index objects used for label based indexing.
locAttribute for location based indexing like pandas.
nameThe name of this array.
nbytesTotal bytes consumed by the elements of this DataArray's data.
ndimNumber of array dimensions.
realThe real part of the array.
shapeTuple of array dimensions.
sizeNumber of elements in the array.
sizesOrdered mapping from dimension names to lengths.
stralias of
StringAccessor[DataArray]Linked
Gridrepresenting to the unstructured grid the data resides on.valuesThe array's data converted to numpy.ndarray.
variableLow level interface to the Variable object for this DataArray.
xindexesMapping of
Indexobjects used for label based indexing.