Input/Output
Writers
ClimaCore.InputOutput.HDF5Writer — TypeHDF5Writer(filename::AbstractString[,
context::ClimaComms.AbstractCommsContext];
overwrite::Bool = true)
HDF5Writer(::Function,
filename::AbstractString[,
context::ClimaComms.AbstractCommsContext];
overwrite::Bool = true)An AbstractWriter for writing to HDF5-formatted files using the ClimaCore storage conventions. An internal cache is used to avoid writing duplicate domains, meshes, topologies and spaces to the file. Use HDF5Reader to load the data from the file.
The optional context can be used for writing distributed fields: in this case, the MPICommsContext used passed as an argument: this must match the context used for distributing the Field.
The writer overwrites or appends to existing files depending on the value of the overwrite keyword argument. When overwrite is false, the writer appends to filename if the file already exists, otherwise it creates a new one.
The default Julia HDF5 binaries are not built with MPI support. To use the distributed functionality, you will need to configure HDF5.jl with an MPI-enabled HDF5 library, see the HDF5.jl documentation.
Interface
Usage
InputOutput.HDF5Writer(filename) do writer
InputOutput.write!(writer, Y, "Y")
endClimaCore.InputOutput.write! — Functionwrite!(writer::AbstractWriter, obj[, preferredname])Write the object obj using writer. An optional preferredname can be provided, otherwise defaultname will be used to generate a name. The name of the object will be returned.
A cache of domains, meshes, topologies and spaces is kept: if one of these objects has already been written, then the file will not be modified: instead the name under which the object was first written will be returned. Note that Fields and FieldVectors are not cached, and so can be written multiple times.
write!(writer::HDF5Writer, field::Fields.Field, name::AbstractString)Write the field to the HDF5 in writer and assign it the given name.
write!(
writer::HDF5Writer,
field::Fields.Field,
name::AbstractString,
space::Spaces.AbstractPointSpace,
)Write a Field, with axes of type PointSpace, to the HDF5 file. The field is written to the fields group in the file, with the name name. The local geometry data of the PointSpace is written to the local_geometry_data group with name name.
write!(
writer::HDF5Writer,
values::DataLayouts.AbstractData,
name::AbstractString,
topology::Topologies.AbstractTopology,
)Write an object of type AbstractData and name name to the HDF5 file.
The values should belong to a Field whose space's topology is topology(axes(field)).
write!(
writer::HDF5Writer,
field::Fields.Field,
name::AbstractString,
space::Spaces.AbstractSpace,
)Write an object of type 'Field' and name 'name' to the HDF5 file.
write!(writer::HDF5Writer, name => value...)Write one or more name => value pairs to writer.
write!(filename::AbstractString, name => value...)Write one or more name => value pairs to the HDF5 file filename.
Readers
ClimaCore.InputOutput.HDF5Reader — TypeHDF5Reader(filename::AbstractString[, context::ClimaComms.AbstractCommsContext])
HDF5Reader(::Function, filename::AbstractString[, context::ClimaComms.AbstractCommsContext])An AbstractReader for reading from HDF5 files created by HDF5Writer. The reader object contains an internal cache of domains, meshes, topologies and spaces that are read so that duplicate objects are not created.
The optional context can be used for reading distributed fields: in this case, the MPICommsContext used passed as an argument: resulting Fields will be distributed using this context. As with HDF5Writer, this requires a HDF5 library with MPI support.
Interface
Usage
InputOutput.HDF5Reader(filename) do reader
Y = read_field(reader, "Y")
Y.c |> propertynames
Y.f |> propertynames
ρ_field = read_field(reader, "Y.c.ρ")
w_field = read_field(reader, "Y.f.w")
endTo explore the contents of the reader, use either
julia> reader |> propertynamese.g, to explore the components of the space,
julia> reader.space_cache
Dict{Any, Any} with 3 entries:
"center_extruded_finite_difference_space" => CenterExtrudedFiniteDifferenceSpace:…
"horizontal_space" => SpectralElementSpace2D:…
"face_extruded_finite_difference_space" => FaceExtrudedFiniteDifferenceSpace:…Once "unpacked" as shown above, ClimaCorePlots or ClimaCoreMakie can be used to visualise fields. ClimaCoreTempestRemap supports interpolation onto user-specified grids if necessary.
ClimaCore.InputOutput.read_domain — Functionread_domain(reader::AbstractReader, name)Reads a domain named name from reader. Domain objects are cached in the reader to avoid creating duplicate objects.
ClimaCore.InputOutput.read_mesh — Functionread_mesh(reader::AbstractReader, name)Reads a mesh named name from reader, or from the reader cache if it has already been read.
ClimaCore.InputOutput.read_topology — Functionread_topology(reader::AbstractReader, name)Reads a topology named name from reader, or from the reader cache if it has already been read.
ClimaCore.InputOutput.read_space — Functionread_space(reader::AbstractReader, name)Reads a space named name from reader, or from the reader cache if it has already been read.
ClimaCore.InputOutput.read_field — Functionread_field(reader, name)Reads a Field or FieldVector named name from reader. Fields are not cached, so that reading the same field multiple times will create multiple distinct objects.
ClimaCore.InputOutput.defaultname — Functiondefaultname(obj)Default name of object for InputOutput writers.