def find_time_dim(da):
    """Find the time dimension in an xr.DataArray.

    Args:
        da: An xr.DataArray
    Returns:
        time_dim: Either 'time' or 'historical_time', depending on which is
            present in da.
    """
    if 'time' in da.coords:
        time_dim = 'time'
    elif 'historical_time' in da.coords:
        time_dim = 'historical_time'
    else:
        time_dim = None
    return time_dim