def generate_output_filename(basename, time, ext='nc'):
    """generate filename from basename, ext and end time inferred from data time vector (basename_yyyymmddHHMM.ext)

    Args:
        basename: the first part of the filename without the date
        time: :class:`xarray.DataArray` time vector of the data in :class:`numpy.datetime64` format. Assume to be sorted
        ext (optional): filename extension. Defaults to 'nc'. Empty not permitted.
    """
    return '{}{}.{}'.format(basename, time[-1].dt.strftime('%Y%m%d%H%M').data, ext)