imod.msw.MetaSwapModel.dump#

MetaSwapModel.dump(directory: str | Path, modelname: str | None = None, validate: bool = True, mdal_compliant: bool = False, crs: str | None = None, engine: Literal['netcdf4', 'zarr', 'zarr.zip'] = 'netcdf4')[source]#

Dump model packages to netCDF files and create a toml file with paths to these files. The MetaSWAP model can be reloaded from the dumped files using the from_file() method.

Parameters:
  • directory (Path or str) – Directory to dump model in. A subdirectory with the name of the model will be created in this directory, and the files will be dumped there.

  • modelname (str, optional) – Name of the model. This will be used as the name of the subdirectory where the files are dumped, and in the name of the toml file. If not provided, it defaults to the value of self._model_name.

  • validate (bool, optional) – Whether to perform validation before dumping the model. If True, the model will be validated using the validation functionality in iMOD. If validation errors are found, a ValidationError is raised and the model is not dumped. Default is True.

  • mdal_compliant (bool, optional) – Whether to write the files in a format compliant with the MDAL specification. This can be used to make the files compatible with software that supports MDAL, such as QGIS. Default is False.

  • crs (str, optional) – Coordinate reference system to use in the dumped files. This should be a string in a format recognized by the pyproj library, for example “EPSG:28992”. If not provided, no CRS information is included in the files.

  • engine (EngineType, optional) –

    File engine used to write packages.

    engine : str, optional

    File engine used to write packages. Options are 'netcdf4', 'zarr', and 'zarr.zip'. NetCDF4 is readable by many other softwares, for example QGIS. Zarr is optimized for big data, cloud storage and parallel access. The 'zarr.zip' option is an experimental option which creates a zipped zarr store in a single file, which is easier to copy and automatically compresses data as well. Default is 'netcdf4'.

Returns:

Path to the created toml file which contains the paths to the dumped package files. The package files are dumped in the same directory as the toml file.

Return type:

Path

Example

>>> tmp_path = tmpdir_factory.mktemp(name)
>>> toml_path = msw_model.dump(tmp_path, name, engine=engine, validate=False)
>>> back = MetaSwapModel.from_file(tmp_path, name)