Convert atime (a float) to DT.datetime
    This is the inverse of datetime2yeardec.
    assert dt2t(t2dt(atime)) == atime

    http://stackoverflow.com/questions/19305991/convert-fractional-years-to-a-real-date-in-python
    Authored by "unutbu" http://stackoverflow.com/users/190597/unutbu

    In Python, go from decimal year (YYYY.YYY) to datetime,
    and from datetime to decimal year.

def yeardec2datetime(atime: float) -> datetime.datetime:
    """
    Convert atime (a float) to DT.datetime
    This is the inverse of datetime2yeardec.
    assert dt2t(t2dt(atime)) == atime

    http://stackoverflow.com/questions/19305991/convert-fractional-years-to-a-real-date-in-python
    Authored by "unutbu" http://stackoverflow.com/users/190597/unutbu

    In Python, go from decimal year (YYYY.YYY) to datetime,
    and from datetime to decimal year.
    """
# %%
    if isinstance(atime, (float, int)):  # typically a float

        year = int(atime)
        remainder = atime - year
        boy = datetime.datetime(year, 1, 1)
        eoy = datetime.datetime(year + 1, 1, 1)
        seconds = remainder * (eoy - boy).total_seconds()

        T = boy + datetime.timedelta(seconds=seconds)
        assert isinstance(T, datetime.datetime)
    elif isinstance(atime[0], float):
        return np.asarray([yeardec2datetime(t) for t in atime])
    else:
        raise TypeError('expecting float, not {}'.format(type(atime)))

    return T