def _decimal_year(times):
    """Convert a datetime DataArray to decimal years according to its calendar.

    The decimal year of a timestamp is its year plus its sub-year component
    converted to the fraction of its year.
    Ex: '2000-03-01 12:00' is 2000.1653 in a standard calendar,
      2000.16301 in a "noleap" or 2000.16806 in a "360_day".
    """
    if times.dtype == "O":
        function = _decimal_year_cftime
        kwargs = {"date_class": get_date_type(times.dt.calendar, True)}
    else:
        function = _decimal_year_numpy
        kwargs = {"dtype": times.dtype}
    from xarray.computation.apply_ufunc import apply_ufunc

    return apply_ufunc(
        function,
        times,
        times.dt.year,
        times.dt.days_in_year,
        kwargs=kwargs,
        vectorize=True,
        dask="parallelized",
        output_dtypes=[np.float64],
    )
Convert a datetime DataArray to decimal years according to its calendar.

    The decimal year of a timestamp is its year plus its sub-year component
    converted to the fraction of its year.
    Ex: '2000-03-01 12:00' is 2000.1653 in a standard calendar,
      2000.16301 in a "noleap" or 2000.16806 in a "360_day".
    
xarray/coding/calendar_ops.py