from pathlib import Path


def _construct_out_filename(fname, group_name):
    """
    Construct a specifically formatted output filename.
    The vrt will be placed adjacent to the HDF5 file, as
    such write access is required.
    """
    basedir = fname.absolute().parent
    basename = fname.with_suffix('.vrt').name.replace(
        'wagl',
        group_name
    )

    out_fname = basedir.joinpath(Path(basename))

    return out_fname