# Path: data_cube_utilities/dc_utilities.py
# def create_default_clean_mask(dataset_in):
#     """
#     Creates a data mask that masks nothing.
#     
#     Parameters
#     ----------
#     dataset_in: xarray.Dataset
#         dataset retrieved from the Data Cube.
#     
#     Raises
#     ------
#     ValueError
#         if dataset_in is an empty xarray.Dataset.
#     """
#     data = None
#     if isinstance(dataset_in, xr.Dataset):
#         data_vars = list(dataset_in.data_vars)
#         if len(data_vars) != 0:
#             data = dataset_in[data_vars[0]].data
#     elif isinstance(dataset_in, xr.DataArray):
#         data = dataset_in.data
#     clean_mask = None
#     if isinstance(data, dask.array.core.Array):
#         clean_mask = dask.array.ones_like(data, dtype='uint8')
#     else:
#         if data is None:
#             clean_mask = np.ones(dataset_in.shape, dtype=np.bool)
#         else:
#             clean_mask = np.ones_like(data, dtype=np.bool)
#     return clean_mask.astype(np.bool)


import numpy as np
import xarray as xr
import dask
    import hdmedians as hd
from functools import partial
from xarray.ufuncs import isnan as xr_nan
from collections import OrderedDict
from . import dc_utilities as utilities
from .dc_utilities import create_default_clean_mask


def create_min_ndvi_mosaic(dataset_in, clean_mask=None, no_data=-9999, dtype=None, intermediate_product=None, **kwargs):
    """
    Method for calculating the pixel value for the min ndvi value.

    Parameters
    ----------
    dataset_in: xarray.Dataset
        A dataset retrieved from the Data Cube; should contain:
        coordinates: time, latitude, longitude
        variables: variables to be mosaicked (e.g. red, green, and blue bands)
    clean_mask: numpy.ndarray
        An ndarray of the same shape as `dataset_in` - specifying which values to mask out.
        If no clean mask is specified, then all values are kept during compositing.
    no_data: int or float
        The no data value.
    dtype: str or numpy.dtype
        A string denoting a Python datatype name (e.g. int, float) or a NumPy dtype (e.g.
        numpy.int16, numpy.float32) to convert the data to.

    Returns
    -------
    dataset_out: xarray.Dataset
        Compositited data with the format:
        coordinates: latitude, longitude
        variables: same as dataset_in
    """
    # Default to masking nothing.
    if clean_mask is None:

# Path: data_cube_utilities/dc_utilities.py
# def create_default_clean_mask(dataset_in):
#     """
#     Creates a data mask that masks nothing.
#     
#     Parameters
#     ----------
#     dataset_in: xarray.Dataset
#         dataset retrieved from the Data Cube.
#     
#     Raises
#     ------
#     ValueError
#         if dataset_in is an empty xarray.Dataset.
#     """
#     data = None
#     if isinstance(dataset_in, xr.Dataset):
#         data_vars = list(dataset_in.data_vars)
#         if len(data_vars) != 0:
#             data = dataset_in[data_vars[0]].data
#     elif isinstance(dataset_in, xr.DataArray):
#         data = dataset_in.data
#     clean_mask = None
#     if isinstance(data, dask.array.core.Array):
#         clean_mask = dask.array.ones_like(data, dtype='uint8')
#     else:
#         if data is None:
#             clean_mask = np.ones(dataset_in.shape, dtype=np.bool)
#         else:
#             clean_mask = np.ones_like(data, dtype=np.bool)
#     return clean_mask.astype(np.bool)


# Path: data_cube_utilities/dc_mosaic.py
import numpy as np
import xarray as xr
import dask
    import hdmedians as hd
from functools import partial
from xarray.ufuncs import isnan as xr_nan
from collections import OrderedDict
from . import dc_utilities as utilities
from .dc_utilities import create_default_clean_mask



def create_min_ndvi_mosaic(dataset_in, clean_mask=None, no_data=-9999, dtype=None, intermediate_product=None, **kwargs):
    """
    Method for calculating the pixel value for the min ndvi value.

    Parameters
    ----------
    dataset_in: xarray.Dataset
        A dataset retrieved from the Data Cube; should contain:
        coordinates: time, latitude, longitude
        variables: variables to be mosaicked (e.g. red, green, and blue bands)
    clean_mask: numpy.ndarray
        An ndarray of the same shape as `dataset_in` - specifying which values to mask out.
        If no clean mask is specified, then all values are kept during compositing.
    no_data: int or float
        The no data value.
    dtype: str or numpy.dtype
        A string denoting a Python datatype name (e.g. int, float) or a NumPy dtype (e.g.
        numpy.int16, numpy.float32) to convert the data to.

    Returns
    -------
    dataset_out: xarray.Dataset
        Compositited data with the format:
        coordinates: latitude, longitude
        variables: same as dataset_in
    """
    # Default to masking nothing.
    if clean_mask is None:

        clean_mask = create_default_clean_mask(dataset_in)