pyrokinetics.gk_code.gk_output.GKOutput#
- class pyrokinetics.gk_code.gk_output.GKOutput(*, coords, norm, output_convention='pyrokinetics', fields=None, fluxes=None, moments=None, eigenvalues=None, eigenfunctions=None, linear=True, normalise_flux_moment=False, gk_code=None, input_file=None, input_convention=None, jacobian=None)[source]#
Bases:
DatasetWrapper,ReadableFromFileContains the output data from gyrokinetics codes. Converts the results of each code to a standard set of normalisation conventions, which allows for easier cross-code comparisons.
Users are not expected to initialise
GKOutputobjects directly, and in most cases should instead make use of the functionread_gk_output.The inputs to
GKOutputshould be given “physical units”, as defined on thenormalisationpage, appropriate to the code that generated the output data. If inputs are not given units, it is assumed they are already compliant with the Pyrokinetics standards.- Parameters:
coords (
Coords) – Dataclass specifying the coordinates of the simulationnorm (
SimulationNormalisation) – The normalisation scheme of the simulation.fields (
Optional[Fields]) – Dataclass specifying the fields in the simulationfluxes (
Optional[Fluxes]) – Dataclass specifying the fluxes in the simulationmoments (
Optional[Moments]) – Dataclass specifying the moments in the simulationeigenvalues (
Optional[Eigenvalues]) – Dataclass specifying the eigenvalues in the simulation. Should only be supplied for linear runs. If not provided, will be set from field data.eigenfunctions (
Optional[Eigenfunctions]) – Dataclass specifying the eigenfunctions in the simulation Should only be supplied for linear runs. If not provided, will be set from field data.linear (
bool) – Set True for linear gyrokinetics runs, False for nonlinear runs.normalise_flux_moment (
bool) – TODO write docsgk_code (
Optional[str]) – The gyrokinetics code that generated the results.input_file (
Optional[str]) – The input file used to generate the results.output_convention (str)
input_convention (Optional[str])
jacobian (Optional[ArrayLike])
- data#
The internal representation of the
GKOutputobject. The functions__getattr__and__getitem__redirect most attribute/indexing lookups here, but the Dataset itself may be accessed directly by the user if they wish to perform more complex manipulations.- Type:
- norm#
The normalisation scheme used for the data.
- Type:
SimulationNormalisation
- __init__(*, coords, norm, output_convention='pyrokinetics', fields=None, fluxes=None, moments=None, eigenvalues=None, eigenfunctions=None, linear=True, normalise_flux_moment=False, gk_code=None, input_file=None, input_convention=None, jacobian=None)[source]#
- Parameters:
coords (Coords)
norm (SimulationNormalisation)
output_convention (str)
fields (Fields | None)
fluxes (Fluxes | None)
moments (Moments | None)
eigenvalues (Eigenvalues | None)
eigenfunctions (Eigenfunctions | None)
linear (bool)
normalise_flux_moment (bool)
gk_code (str | None)
input_file (str | None)
input_convention (str | None)
jacobian (numpy.typing.ArrayLike | None)
Methods
__init__(*, coords, norm[, ...])add_data(name, data, coords, units[, ...])Modifies existing GKOutput by adding specified data
convert_physical_units(norms)Convert physical-unit data vars and coords to generic simulation units of
norms.field(name)flux(name)from_file(path[, file_type])Read a file from disk, returning an instance of this class.
from_netcdf(path, *args[, ...])Initialise self.data from a netCDF file.
get_growth_rate_tolerance([time_range])Given a pyrokinetics output dataset with eigenvalues determined, calculate the growth rate tolerance.
moment(name)supported_file_types()Returns a list of all registered file types.
to(norms, *contexts)to_netcdf(*args, **kwargs)Writes self.data to disk.
Attributes
attrsRedirects to underlying Xarray Dataset attrs.
coordsRedirects to underlying Xarray Dataset coords.
Property for managing the underlying Xarray Dataset.
data_varsRedirects to underlying Xarray Dataset data_vars.
dimsRedirects to underlying Xarray Dataset dims.
sizesRedirects to underlying Xarray Dataset sizes.
- add_data(name, data, coords, units, output_convention='pyrokinetics')[source]#
Modifies existing GKOutput by adding specified data
- convert_physical_units(norms)[source]#
Convert physical-unit data vars and coords to generic simulation units of
norms.