xarray_lmfit.save_fit#

xarray_lmfit.save_fit(result_ds, path, **kwargs)#

Save fit results to a netCDF file.

This function processes a dataset containing fit results obtained from xarray.DataArray.xlm.modelfit() or xarray.Dataset.xlm.modelfit() and saves it to a netCDF file.

Serialization of lmfit.model.ModelResult objects are handled just like lmfit.model.save_modelresult(), and shares the same limitations.

Parameters:
  • result_ds – An xarray Dataset containing the fit results.

    Any lmfit.model.ModelResult objects in the dataset will be serialized before saving.

  • path – Path to which to save the fit result dataset.

  • **kwargs – Additional keyword arguments that are passed to xarray.Dataset.to_netcdf().

Note

Storing fit results to a file for an extended period of time is not recommended, as the serialization format does not guarantee compatibility between different versions of python or packages. For more information, see the lmfit documentation.

See also

lmfit.model.save_modelresult()

Corresponding lmfit function that can save a single lmfit.model.ModelResult.

load_fit

Function to load the saved fit results.