def get_out_varname(var, cat, cfg, **kw_format):
    """
    Create a variable name.
    It uses the format given in the configuration file
    and combines it with the species and categories. 
    """
    varname_format = getattr(cfg, 'varname_format', '{species}_{category}')

    var = cfg.in2out_species.get(var, var)
    cat = cfg.in2out_category.get(cat, cat)

    return varname_format.format(species=var, category=cat, **kw_format)