postopus.datacontainers.field

class postopus.datacontainers.field.ScalarField(ftype: str, path: Path, systemname: str, calculationmode: str, fields_in_mode: Dict[str, Tuple[str, List[str]] | List[Path] | List[str]])
get(steps: int | List[int] | None = None, source: str = 'auto', ignore_warnings: bool = False) DataArray

Method used to load data for a field. Fields can be loaded for one or multiple simulation steps.

Parameters:
  • steps (Union[int, List[int]]) – Which simulation steps to load. Either a single step, a list of steps.

  • source (str) – Target output format for the field. E. g. “z=0”, “cube”, “vtk”, …

  • ignore_warnings (bool) – Choose whether to ignore warnings that to much memory might be used when loading.

Returns:

Xarray contains the field, and an additional coordinate “step”or “t” (if time dependent) for selecting the simulation steps.

Return type:

xarray.DataArray

Examples

Single iteration:

>>> from pathlib import Path; from postopus import Run
>>> repodir = Path("path_to_repodir")
>>> testdata_dir = repodir / "tests" / "data" / "methane"
>>> run = Run(testdata_dir)
>>> run.default.scf.density.get(steps=1, source="xsf")
>>> <xarray.DataArray...

List of iterations:

>>> run.default.scf.density.get(steps=[1, 2], source="xsf")
>>> <xarray.DataArray...
get_all(source: str = 'auto', ignore_warnings: bool = False) DataArray

Load all available simulation steps (including the converged step)

Also check if enough memory is available.

Parameters:
  • source (str) – Target output format for the field. E. g. “z=0”, “cube”, “vtk”, …

  • ignore_warnings (bool) – Choose whether to ignore warnings that to much memory might be used when loading.

Returns:

Xarray contains the field, and an additional coordinate “step” or “t” (if time dependent) for selecting the simulation steps.

Return type:

xarray.DataArray

Examples

>>> from pathlib import Path; from postopus import Run
>>> repodir = Path("path_to_repodir")
>>> testdata_dir = repodir / "tests" / "data" / "methane"
>>> run = Run(testdata_dir / "benzene")
>>> run.default.scf.density.get_all(source="xsf")
>>> <xarray.DataArray...
get_converged(source: str = 'auto', ignore_warnings: bool = False) DataArray

Get converged scf iteration

Parameters:

source (str) – Target output format for the field. E. g. “z=0”, “cube”, “vtk”, …

Returns:

Xarray contains the field, and an additional coordinate “step” or “t” (if time dependent) for selecting the simulation steps.

Return type:

xarray.DataArray

Examples

>>> from pathlib import Path; from postopus import Run
>>> repodir = Path("path_to_repodir")
>>> testdata_dir = repodir / "tests" / "data" / "methane"
>>> run = Run(testdata_dir)
>>> run.default.scf.density.get_converged(source="xsf")
>>> <xarray.DataArray...
iget(indices: int | List[int] | slice | None = None, source: str = 'auto', ignore_warnings: bool = False)

Method used to load data for a field. Fields can be loaded for one or multiple simulation steps. The selection is done by index.

Parameters:
  • indices (Union[int, List[int], slice]) – Which simulation steps to load, by index. Either a single index, a list of indices or a slice(int, int) object. Negative integers are also allowed.

  • source (str) – Target output format for the field. E. g. “z=0”, “cube”, “vtk”, …

  • ignore_warnings (bool) – Choose whether to ignore warnings that to much memory might be used when loading.

Returns:

Xarray contains the field, and an additional coordinate “step”or “t” (if time dependent) for selecting the simulation steps.

Return type:

xarray.DataArray

Examples

Single iteration:

>>> from pathlib import Path; from postopus import Run
>>> repodir = Path("path_to_repodir")
>>> testdata_dir = repodir / "tests" / "data" / "methane"
>>> run = Run(testdata_dir)
>>> run.default.scf.density.iget(-1, source="xsf")
>>> <xarray.DataArray...

List of iterations:

>>> run.default.scf.density.iget([5, 7], "ncdf")
>>> <xarray.DataArray...  # two iterations

Slice:

>>> run.default.scf.density.iget(slice(0, 3), "ncdf")
>>> <xarray.DataArray...  # three iterations
class postopus.datacontainers.field.VectorField(ftype: str, path: Path, systemname: str, calculationmode: str, fields_in_mode: Dict[str, Tuple[str, List[str]] | List[Path] | List[str]])
get(steps: int | List[int] | None = None, source: str = 'auto', ignore_warnings: bool = False) DataArray

Method used to load data for a field. Fields can be loaded for one or multiple simulation steps. As this method is related to VectorField it will load all components of the vector field

Parameters:
  • steps (Union[int, List[int]]) – Which simulation steps to load. Either a single step, a list of steps.

  • source (str) – Target output format for the field. E. g. “z=0”, “cube”, “vtk”, …

  • ignore_warnings (bool) – Choose whether to ignore warnings that too much memory might be used when loading.

Returns:

Xarray contains the field, and an additional coordinate “step” or “t” (if time dependent) for selecting the simulation steps.

Return type:

xarray.DataArray

Examples

Single iteration:

>>> from pathlib import Path; from postopus import Run
>>> repodir = Path("path_to_repodir")
>>> testdata_dir = repodir / "tests" / "data" / "methane"
>>> run = Run(testdata_dir)
>>> run.default.td.current.get(steps=1, source="ncdf")
>>> <xarray.DataArray...

List of iterations:

>>> run.default.td.current.get(steps=[1, 2], source="ncdf")
>>> <xarray.DataArray...  # contains all 3 components + coordinate "t"
get_all(source: str = 'auto', ignore_warnings: bool = False) DataArray

Load all available simulation steps (including the converged step)

Also check if enough memory is available.

Parameters:
  • source (str) – Target output format for the field. E. g. “z=0”, “cube”, “vtk”, …

  • ignore_warnings (bool) – Choose whether to ignore warnings that to much memory might be used when loading.

Returns:

Xarray contains the field, and an additional coordinate “step” or “t” (if time dependent) for selecting the simulation steps.

Return type:

xarray.DataArray

Examples

>>> from pathlib import Path; from postopus import Run
>>> repodir = Path("path_to_repodir")
>>> testdata_dir = repodir / "tests" / "data" / "methane"
>>> run = Run(testdata_dir)
>>> run.default.td.current.get_all(source="ncdf")
>>> <xarray.DataArray...  # contains all 3 components + coordinate "t"
iget(indices: int | List[int] | slice | None = None, source: str = 'auto', ignore_warnings: bool = False)

Method used to load data for a field. Fields can be loaded for one or multiple simulation steps. The selection is done by index.

Parameters:
  • indices (Union[int, List[int], slice]) – Which simulation steps to load, by index. Either a single index, a list of indices or a slice(int, int) object. Negative integers are also allowed.

  • source (str) – Target output format for the field. E. g. “z=0”, “cube”, “vtk”, …

  • ignore_warnings (bool) – Choose whether to ignore warnings that to much memory might be used when loading.

Returns:

Xarray contains the field, and an additional coordinate “step”or “t” (if time dependent) for selecting the simulation steps.

Return type:

xarray.DataArray

Examples

Single iteration:

>>> from pathlib import Path; from postopus import Run
>>> repodir = Path("path_to_repodir")
>>> testdata_dir = repodir / "tests" / "data" / "methane"
>>> run = Run(testdata_dir)
>>> run.default.td.current.iget(-1, "ncdf")
>>> <xarray.DataArray... # one iteration

List of iterations:

>>> run.default.td.current.iget([5, 7], "ncdf")
>>> <xarray.DataArray...  # two iterations

Slice:

>>> run.default.td.current.iget(slice(0, 3), "ncdf")
>>> <xarray.DataArray...  # three iterations