linopy.model.Model.to_netcdf

linopy.model.Model.to_netcdf#

Model.to_netcdf(*args, **kwargs)#

Write out the model to a netcdf file.

Parameters:
  • m (linopy.Model) – Model to write out.

  • *args – Arguments passed to xarray.Dataset.to_netcdf.

  • **kwargs (TYPE) – Keyword arguments passed to xarray.Dataset.to_netcdf.

Notes

The SOS reformulation lifecycle token lives only on the in-memory Model and is not persisted. If the model has an active SOS reformulation at serialization time, the netcdf contains the reformulated MILP form (aux binaries and cardinality constraints) and a UserWarning is emitted to flag that the deserialized copy will not be able to undo the reformulation.

Model.solve(remote=...) invokes to_netcdf internally on the reformulated model and suppresses this warning.