# Path: cotede/utils/utils.py
# def cotederc(subdir=None):
#     """Directory with custom configuration for CoTeDe
# 
#     To keep the local environment tight, CoTeDe expects to find all local files,
#     like pre-set QC procedures, in one single place. This function returns the
#     path to that directory.
# 
#     Parameters
#     ----------
#     subdir : str, optional
#         Sub-directory inside the base custom directory.
# 
#     Returns
#     -------
#     str
#         A path to the local custom files.
# 
#         The default path is a directory at the user's home like::
# 
#             ~/.config/cotederc/
# 
#     Note
#     ----
#     That default path can be modified by defining the environment variable
#     COTEDE_DIR. On bash that could be done like::
# 
#         export COTEDE_DIR='/my/other/awesome/path/'
# 
#     Note
#     ----
#     For windows users the path is automatically adjusted to reflect its
#     syntax.
# 
#     Example
#     -------
#     A sub-directory for configuration files, named 'cfg', can be determined by::
# 
#     >>> cotederc('cfg')
#     """
#     path = os.getenv("COTEDE_DIR", os.path.join("~", ".config", "cotederc"))
#     path = os.path.expanduser(path)
#     if subdir is not None:
#         path = os.path.join(path, subdir)
#     return path


import numpy as np
import os.path
    import pandas as pd
from numpy import datetime64, timedelta64
from cotede.utils import cotederc
    from supportdata import download_file
    attrs = np.load(filename, allow_pickle=True)["attrs"]
    attrs = {a[0]: a[1] for a in attrs}

    varnames = np.load(filename, allow_pickle=True)["varnames"]
    values = np.load(filename, allow_pickle=True)["data"]
    data = {k: v for k, v in zip(varnames, values)}

    class CoTeDeDataModel(object):
        def __init__(self, attrs, data):
            self.attrs = attrs
            self.data = data
        def __getitem__(self, key):
            return self.data[key]
        def keys(self):
            return self.data.keys()

    output = CoTeDeDataModel(attrs, data)

    return output


def load_water_level(as_frame=False):
    """
    """
    DATA_URL = "https://raw.githubusercontent.com/castelao/CoTeDe/master/sampledata/NOS_8764227.npz"
    DATA_HASH = "7ec673d82e0e361acfc4075fe914dc7d"

    filename = os.path.join(cotederc("sampledata"), "NOS_8764227.npz")
    if not os.path.exists(filename):
        assert SUPPORTDATA_AVAILABLE, "Require package supportdata to download samples"

# Path: cotede/utils/utils.py
# def cotederc(subdir=None):
#     """Directory with custom configuration for CoTeDe
# 
#     To keep the local environment tight, CoTeDe expects to find all local files,
#     like pre-set QC procedures, in one single place. This function returns the
#     path to that directory.
# 
#     Parameters
#     ----------
#     subdir : str, optional
#         Sub-directory inside the base custom directory.
# 
#     Returns
#     -------
#     str
#         A path to the local custom files.
# 
#         The default path is a directory at the user's home like::
# 
#             ~/.config/cotederc/
# 
#     Note
#     ----
#     That default path can be modified by defining the environment variable
#     COTEDE_DIR. On bash that could be done like::
# 
#         export COTEDE_DIR='/my/other/awesome/path/'
# 
#     Note
#     ----
#     For windows users the path is automatically adjusted to reflect its
#     syntax.
# 
#     Example
#     -------
#     A sub-directory for configuration files, named 'cfg', can be determined by::
# 
#     >>> cotederc('cfg')
#     """
#     path = os.getenv("COTEDE_DIR", os.path.join("~", ".config", "cotederc"))
#     path = os.path.expanduser(path)
#     if subdir is not None:
#         path = os.path.join(path, subdir)
#     return path


# Path: cotede/datasets.py
import numpy as np
import os.path
    import pandas as pd
from numpy import datetime64, timedelta64
from cotede.utils import cotederc
    from supportdata import download_file

    attrs = np.load(filename, allow_pickle=True)["attrs"]
    attrs = {a[0]: a[1] for a in attrs}

    varnames = np.load(filename, allow_pickle=True)["varnames"]
    values = np.load(filename, allow_pickle=True)["data"]
    data = {k: v for k, v in zip(varnames, values)}

    class CoTeDeDataModel(object):
        def __init__(self, attrs, data):
            self.attrs = attrs
            self.data = data
        def __getitem__(self, key):
            return self.data[key]
        def keys(self):
            return self.data.keys()

    output = CoTeDeDataModel(attrs, data)

    return output


def load_water_level(as_frame=False):
    """
    """
    DATA_URL = "https://raw.githubusercontent.com/castelao/CoTeDe/master/sampledata/NOS_8764227.npz"
    DATA_HASH = "7ec673d82e0e361acfc4075fe914dc7d"

    filename = os.path.join(cotederc("sampledata"), "NOS_8764227.npz")
    if not os.path.exists(filename):
        assert SUPPORTDATA_AVAILABLE, "Require package supportdata to download samples"

        download_file(cotederc("sampledata"), DATA_URL, md5hash=DATA_HASH)