# Path: data_cube_utilities/dc_utilities.py
# def get_range(platform, collection, level):
# def convert_range(dataset, from_platform, from_collection, from_level,
#                   to_platform, to_collection, to_level):
#     def convert_data_var(data_arr, data_var_name):
# def reverse_array_dict(dictionary):
# def list_prod(lst):
# def check_for_float(array):
# def create_cfmask_clean_mask(cfmask):
# def create_default_clean_mask(dataset_in):
# def get_spatial_ref(crs):
# def perform_timeseries_analysis(dataset_in, band_name, intermediate_product=None, no_data=-9999, operation="mean"):
# def clear_attrs(dataset):
# def create_bit_mask(data_array, valid_bits, no_data=-9999):
# def add_timestamp_data_to_xr(dataset):
# def write_geotiff_from_xr(tif_path, data, bands=None, no_data=-9999, crs="EPSG:4326",
#                           x_coord='longitude', y_coord='latitude'):
# def write_png_from_xr(png_path, dataset, bands, png_filled_path=None, fill_color='red', scale=None, low_res=False,
#                       no_data=-9999, crs="EPSG:4326"):
# def write_single_band_png_from_xr(png_path, dataset, band, color_scale=None, fill_color=None, interpolate=True,
#                                   no_data=-9999, crs="EPSG:4326"):
# def _get_transform_from_xr(data, x_coord='longitude', y_coord='latitude'):
# def chunks(l, n):
# def ignore_warnings(func, *args, **kwargs):
#         X = dataset[[data_var_name]].stack(row=('latitude', 'longitude', ...)).to_array().transpose('row', 'variable')
#         X = X.where(~nan_mask_x, drop=True)


import unittest
import numpy as np
import xarray as xr
from datetime import datetime
from data_cube_utilities import dc_utilities
    def test_perform_timeseries_analysis(self):
        pass

    # def test_nan_to_num(self):
    #     dataset = xr.Dataset(
    #         {
    #             'data': (('time', 'latitude', 'longitude'), self.sample_data)
    #         },
    #         coords={'time': self.times,
    #                 'latitude': self.latitudes,
    #                 'longitude': self.longitudes})

    #     dataset_nan = dataset.where(dataset.data > 2)

    #     dc_utilities.nan_to_num(dataset_nan, -9999)

    #     self.assertTrue((dataset_nan.data.values == np.array(
    #         [[[-9999, -9999], [-9999, -9999]], [[-9999, -9999], [-9999, -9999]], [[3, 3], [3, 3]],
    #          [[-9999, -9999], [-9999, -9999]], [[5, 5], [5, 5]]])).all())

    def test_clear_attrs(self):
        dataset = xr.Dataset(
            {
                'data': (('time', 'latitude', 'longitude'), self.sample_data)
            },
            coords={'time': self.times,
                    'latitude': self.latitudes,
                    'longitude': self.longitudes},
            attrs={'temp_attrs': 5})


# Path: data_cube_utilities/dc_utilities.py
# def get_range(platform, collection, level):
# def convert_range(dataset, from_platform, from_collection, from_level,
#                   to_platform, to_collection, to_level):
#     def convert_data_var(data_arr, data_var_name):
# def reverse_array_dict(dictionary):
# def list_prod(lst):
# def check_for_float(array):
# def create_cfmask_clean_mask(cfmask):
# def create_default_clean_mask(dataset_in):
# def get_spatial_ref(crs):
# def perform_timeseries_analysis(dataset_in, band_name, intermediate_product=None, no_data=-9999, operation="mean"):
# def clear_attrs(dataset):
# def create_bit_mask(data_array, valid_bits, no_data=-9999):
# def add_timestamp_data_to_xr(dataset):
# def write_geotiff_from_xr(tif_path, data, bands=None, no_data=-9999, crs="EPSG:4326",
#                           x_coord='longitude', y_coord='latitude'):
# def write_png_from_xr(png_path, dataset, bands, png_filled_path=None, fill_color='red', scale=None, low_res=False,
#                       no_data=-9999, crs="EPSG:4326"):
# def write_single_band_png_from_xr(png_path, dataset, band, color_scale=None, fill_color=None, interpolate=True,
#                                   no_data=-9999, crs="EPSG:4326"):
# def _get_transform_from_xr(data, x_coord='longitude', y_coord='latitude'):
# def chunks(l, n):
# def ignore_warnings(func, *args, **kwargs):
#         X = dataset[[data_var_name]].stack(row=('latitude', 'longitude', ...)).to_array().transpose('row', 'variable')
#         X = X.where(~nan_mask_x, drop=True)


# Path: test/test_dc_utilities.py
import unittest
import numpy as np
import xarray as xr
from datetime import datetime
from data_cube_utilities import dc_utilities

    def test_perform_timeseries_analysis(self):
        pass

    # def test_nan_to_num(self):
    #     dataset = xr.Dataset(
    #         {
    #             'data': (('time', 'latitude', 'longitude'), self.sample_data)
    #         },
    #         coords={'time': self.times,
    #                 'latitude': self.latitudes,
    #                 'longitude': self.longitudes})

    #     dataset_nan = dataset.where(dataset.data > 2)

    #     dc_utilities.nan_to_num(dataset_nan, -9999)

    #     self.assertTrue((dataset_nan.data.values == np.array(
    #         [[[-9999, -9999], [-9999, -9999]], [[-9999, -9999], [-9999, -9999]], [[3, 3], [3, 3]],
    #          [[-9999, -9999], [-9999, -9999]], [[5, 5], [5, 5]]])).all())

    def test_clear_attrs(self):
        dataset = xr.Dataset(
            {
                'data': (('time', 'latitude', 'longitude'), self.sample_data)
            },
            coords={'time': self.times,
                    'latitude': self.latitudes,
                    'longitude': self.longitudes},
            attrs={'temp_attrs': 5})


        dc_utilities.clear_attrs(dataset)