agrifoodpy.array_accessor ========================= .. py:module:: agrifoodpy.array_accessor Classes ------- .. autoapisummary:: agrifoodpy.array_accessor.XarrayAccessorBase Module Contents --------------- .. py:class:: XarrayAccessorBase(xarray_obj) Bases: :py:obj:`object` Common logic for for both data structures (DataArray and Dataset). http://xarray.pydata.org/en/stable/internals.html#extending-xarray .. py:method:: add_items(items, copy_from=None) Extends the item list of an input xarray object according to the defined input item list :param items: list of item names to be added to the data :type items: list, int, string :param copy_from: If provided, this is the list of items already on the array to copy data from. :type copy_from: list, int, string, optional :returns: **out** -- Xarray object with new items added. :rtype: xarray.Dataset, xarray.DataArray .. py:method:: add_regions(regions, copy_from=None) Extends the region list of an input xarray object according to the defined input region list :param regions: list of region names to be added to the data :type regions: list, int, string :param copy_from: If provided, this is the list of regions already on the object to copy data from. :type copy_from: list, int, string :param labels: Dictionary containing the new label for the regions matched to its corresponding label coordinate. :type labels: dict :returns: **out** -- Xarray object with new regions added. :rtype: xarray.Dataset, xarray.DataArray .. py:method:: add_years(years, projection='empty') Extends the year range of an xarray object according to the defined maximum year :param years: list of years to be added to the data :type years: list, int :param projection: Projection mode. If "constant", the last year of the input array is copied to every new year. If "empty", values are initialized and set to zero. If a float array is given, these are used to populate the new year using a scaling of the last year of the array :type projection: string or array_like :returns: **out** -- Xarray object with new years added. :rtype: xarray.Dataset, xarray.DataArray .. py:method:: group_sum(coordinate, new_name=None) Sums quantities over items of a equal group labels and, optionally, renames the groups label coordinate. :param fbs: Input xarray object :type fbs: xarray.Dataset :param coordinate: Coordinate name to group elements and sum over :type coordinate: string :param new_name: New name for the collapsed coordinate :type new_name: string, optional :returns: **fbs** -- Xarray object with new coordinate base. :rtype: xarray.Dataset, xarray.DataArray