# Path: src/pys5p/s5p_xarray.py
# def data_to_xr(data, *, dims=None, name=None, long_name=None, units=None):
#     """
#     Create xarray::DataArray from a dataset
# 
#     Parameters
#     ----------
#     data :  array-like
#        Data to be stored in the xarray
#     dims :  list of strings
#        Names for the dataset dimensions
#     name : str
#        A string that names the instance
#     units :  str
#        Units of the data, default: '1'
#     long_name : str
#        Long name describing the data, default: empty string
# 
#     Returns
#     -------
#     xarray.DataArray
#     """
#     coords = __set_coords(data, None, dims)
#     attrs = {}
#     attrs['units'] = '1' if units is None else units
#     attrs['long_name'] = '' if long_name is None else long_name
# 
#     return xr.DataArray(data, name=name, attrs=attrs, coords=coords)


from collections import OrderedDict
from copy import deepcopy
from datetime import datetime
from ..s5p_xarray import data_to_xr
import matplotlib as mpl
import numpy as np
import xarray as xr

def data_for_trend2d(data_in, dims=None, delta_time=None):
    """
    Prepare data to display the averaged column/row as function of time

    Parameters
    ----------
    data :  numpy.ndarray or xarray.DataArray
       Object holding measurement data and attributes
    dims :  list of strings
       Names for the dataset dimensions
       Required when data is a numpy array (otherwise ignored)
    delta_time : int, optional
       Expected resolution of the time-axis.
       Defined in whole seconds or number of orbit revolutions.
    missing_data: 'NaN' or 'previous'
       Default: NaN

    Returns
    -------
    xarray.DataArray
    """
    try:
        check_data2d('data', data_in)
    except Exception as exc:
        raise RuntimeError('invalid input-data provided') from exc

    if isinstance(data_in, np.ndarray):
        if dims is None:
            raise KeyError('a list with dimensions names should be provided')

# Path: src/pys5p/s5p_xarray.py
# def data_to_xr(data, *, dims=None, name=None, long_name=None, units=None):
#     """
#     Create xarray::DataArray from a dataset
# 
#     Parameters
#     ----------
#     data :  array-like
#        Data to be stored in the xarray
#     dims :  list of strings
#        Names for the dataset dimensions
#     name : str
#        A string that names the instance
#     units :  str
#        Units of the data, default: '1'
#     long_name : str
#        Long name describing the data, default: empty string
# 
#     Returns
#     -------
#     xarray.DataArray
#     """
#     coords = __set_coords(data, None, dims)
#     attrs = {}
#     attrs['units'] = '1' if units is None else units
#     attrs['long_name'] = '' if long_name is None else long_name
# 
#     return xr.DataArray(data, name=name, attrs=attrs, coords=coords)


# Path: src/pys5p/lib/plotlib.py
from collections import OrderedDict
from copy import deepcopy
from datetime import datetime
from ..s5p_xarray import data_to_xr
import matplotlib as mpl
import numpy as np
import xarray as xr


def data_for_trend2d(data_in, dims=None, delta_time=None):
    """
    Prepare data to display the averaged column/row as function of time

    Parameters
    ----------
    data :  numpy.ndarray or xarray.DataArray
       Object holding measurement data and attributes
    dims :  list of strings
       Names for the dataset dimensions
       Required when data is a numpy array (otherwise ignored)
    delta_time : int, optional
       Expected resolution of the time-axis.
       Defined in whole seconds or number of orbit revolutions.
    missing_data: 'NaN' or 'previous'
       Default: NaN

    Returns
    -------
    xarray.DataArray
    """
    try:
        check_data2d('data', data_in)
    except Exception as exc:
        raise RuntimeError('invalid input-data provided') from exc

    if isinstance(data_in, np.ndarray):
        if dims is None:
            raise KeyError('a list with dimensions names should be provided')

        msm = data_to_xr(data_in, dims=dims)