def rename_restart_variables(ds, towards_gchp=True):
    """
    Renames restart variables according to GEOS-Chem Classic and GCHP conventions.

    Args:
        ds: xarray.Dataset
            The input dataset

    Keyword Args (optional):
        towards_gchp: bool
            Whether renaming to (True) or from (False) GCHP format
            Default value: True

    Returns:
        xarray.Dataset
            Input dataset with variables renamed
    """

    if towards_gchp:
        old_str = 'SpeciesRst'
        new_str = 'SPC'
    else:
        old_str = 'SPC'
        new_str = 'SpeciesRst'
    return ds.rename({name: name.replace(old_str, new_str, 1)
                      for name in list(ds.data_vars)
                      if name.startswith(old_str)})