add_history#

muse.utils.add_history(ds, func_or_local_vars, func=None)#

Record a call in the dataset history and store its keyword inputs as attributes.

When locals() and func are passed, every keyword input (a parameter of func that has a default) is stored on ds.attrs after being coerced to a netCDF/zarr-serializable form (see _attr_safe); required positional parameters such as the data itself are skipped.

Parameters:
  • ds (Dataset | DataArray) – Dataset to update.

  • func_or_local_vars (Callable | str | dict) – Function being recorded in the history. For the full-call record, pass locals() here and func as the third argument.

  • func (Callable | str | None) – Function being recorded with its input values.

Return type:

None