diff --git a/pintxarray/__init__.py b/pintxarray/__init__.py index 3e169c94..067a6a00 100644 --- a/pintxarray/__init__.py +++ b/pintxarray/__init__.py @@ -1 +1,2 @@ from .accessors import PintDataArrayAccessor, PintDatasetAccessor +from .indexing import QuantityIndex diff --git a/pintxarray/accessors.py b/pintxarray/accessors.py index 414efcda..e242f8c5 100644 --- a/pintxarray/accessors.py +++ b/pintxarray/accessors.py @@ -16,6 +16,7 @@ if not IS_NEP18_ACTIVE: raise ImportError("NUMPY_EXPERIMENTAL_ARRAY_FUNCTION is not enabled") +# TODO do we need this? xarray chooses it's own labels anyway try: mpl = import_module("matplotlib") has_mpl = True diff --git a/pintxarray/indexing.py b/pintxarray/indexing.py new file mode 100644 index 00000000..4edae7ba --- /dev/null +++ b/pintxarray/indexing.py @@ -0,0 +1,29 @@ +import pandas as pd +from pandas.core.base import IndexOpsMixin + +from pint import Quantity, Unit + + +# TODO does pandas supply some kind of abstract base class for indexer objects? +class QuantityIndex(IndexOpsMixin): + def __init__(self, index=pd.Index, units=None, unit_registry=None, + decode_cf=False): + self._index = index + self._units = units + + @property + def units(self): + ... + + @property + def magnitude(self): + ... + + def dequantify(self): + ... + + def to(self, units): + ... + + def to_base_units(self): + ...