freegsnke.dump module
Legacy HDF5 persistence for FreeGSNKE Equilibrium objects.
This inherited format is not used by FreeGSNKE and is not part of its supported backend API. The isolated HDF5 round trip remains tested while the legacy I/O surface is reviewed.
Copyright 2018 Ben Dudson, University of York. Email: benjamin.dudson@york.ac.uk
This file is part of FreeGSNKE.
FreeGSNKE is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
FreeGSNKE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along with FreeGSNKE. If not, see <http://www.gnu.org/licenses/>.
- class freegsnke.dump.OutputFile(name: str, mode: str | None = None, **kwds: object)[source]
Bases:
objectRead/write FreeGSNKE Equilibrium objects to file.
Currently supports HDF5 format only.
Given an Equilibrium object, eq, write to file like:
>>> with freegsnke.OutputFile("test_readwrite.h5", 'w') as f: ... f.write_equilibrium(eq)
Read back into an Equilibrium like so:
>>> with freegs.OutputFile("test_readwrite.h5", 'r') as f: ... eq = f.read_equilibrium()
- COILS_GROUP_NAME = 'coils'
- EQUILIBRIUM_GROUP_NAME = 'equilbrium'
- MACHINE_GROUP_NAME = 'tokamak'
- __init__(name: str, mode: str | None = None, **kwds: object) None[source]
Open the file.
- Parameters:
name (str) – Name of file to open.
mode (str or None, optional) –
Mode string to pass to h5py.File, one of:
r: read-only, file must existr+: read-write, file must existw: create file, truncate if existsw-: create file, fail if existsa: read-write if exists, create otherwise
**kwds (object) – Other keyword arguments to pass to h5py.File.
- Raises:
OutputFormatNotAvailableError – If
h5pycould not be imported.
- read_equilibrium() Equilibrium[source]
Read an equilibrium from the file.
- Returns:
A new Equilibrium object.
- Return type:
- write_equilibrium(equilibrium: Equilibrium) None[source]
Write an equilibrium to the file.
- Parameters:
equilibrium (Equilibrium) – Equilibrium to write (grid, plasma current, flux, boundary function, wall and coils).
- Raises:
ValueError – If a coil has a type that cannot be saved.