Peano
Loading...
Searching...
No Matches
tarch.plotter.api.output.Visualiser.Visualiser Class Reference

The visualiser is first and foremost a persistency layer around datasets. More...

Inheritance diagram for tarch.plotter.api.output.Visualiser.Visualiser:

Public Member Functions

 __init__ (self, file_name, start, end, verbose=False)
 Abstract superclass of a visualiser.
 display (self)
 This is the one routine the visualisers typically do overwrite.
 display_single_file (self)
 If we are here we've supplied a single file which is itself a snapshot.
 read_metadata (self)
 Read the patch file metadata.
 append_filter (self, filter)
 remove_filters (self)
 parse_and_render_snapshot (self, snapshot)
 We pass in a snapshot object here, which should contain time stamp and filenames for everything we want to render here.
 parse_snapshot (self, snapshot)
 We rewrite "reload" from previous version of this file.

Data Fields

tuple identifier
 verbose = verbose
bool show_progress = True
 patch_filter = None
list snapshots = []
bool meta_data_has_been_read = False

Protected Attributes

 _file_name = file_name
 _start = start
 _end = end
list _filter = []
int _dimensions = 0
str _description = "" #
bool _is_data_associated_to_cell = False

Detailed Description

The visualiser is first and foremost a persistency layer around datasets.

It serves as abstract base class for real output formats, i.e. it can parse files and hold them, but it does not do anything with them.

The flow should work like this:

  • Pass the file name of the patch file meta data to this class. We then use read_metadata() to read this file, and gather, for each timestamp, the list of patch files that we need to read. For each timestamp, we create an instance of the Snapshot helper class, which captures the timestamp, plus a list of patch files to parse
  • We then pass back to display(). Then, for each snapshot, we do the following:
    • Create a PatchFileParser object for each patch file within this timestamp
    • Read all the patch file data and combine it into the PatchFileData class in this file.
    • Return this data to child class, so that it can be rendered by display()

Currently, the only working child class is the VTU renderer.

Definition at line 197 of file Visualiser.py.

Constructor & Destructor Documentation

◆ __init__()

tarch.plotter.api.output.Visualiser.Visualiser.__init__ ( self,
file_name,
start,
end,
verbose = False )

Abstract superclass of a visualiser.

file_name: String Name of a Peano patch file. This does not need to be a meta file.

If we run render.py with the argument -s (to denote we are using single file), then we will use the file_name to create a member of the snapshot class (which captures the patch file to read, with default timestamp of 0). This is then parsed by parse_and_render, and handed back to child class.

If this is a meta file, then display() will be used.

verbose: Boolean Controls how much the class writes out.

Attributes

self.identifier: String Pick one subidentifier from the input file. If this one is empty, we take every input data set. However, some output formats (such as ParaView) don't support multiple output data sets, so we might end up with either the first or last one from the file - depending on the implementations.

Definition at line 224 of file Visualiser.py.

Member Function Documentation

◆ append_filter()

tarch.plotter.api.output.Visualiser.Visualiser.append_filter ( self,
filter )

Definition at line 361 of file Visualiser.py.

References _filter.

◆ display()

tarch.plotter.api.output.Visualiser.Visualiser.display ( self)

This is the one routine the visualisers typically do overwrite.

Reimplemented in tarch.plotter.api.output.PointProbe.PointProbe, and tarch.plotter.api.output.VTUUnstructuredGrid.VTUUnstructuredGrid.

Definition at line 289 of file Visualiser.py.

References read_metadata().

Here is the call graph for this function:

◆ display_single_file()

tarch.plotter.api.output.Visualiser.Visualiser.display_single_file ( self)

If we are here we've supplied a single file which is itself a snapshot.

Turn it into an instance of the snapshot helper class, set the timestamp to 0 and pass it back. We can just call parse_and_render_snapshot() on the result

Reimplemented in tarch.plotter.api.output.PointProbe.PointProbe, and tarch.plotter.api.output.VTUUnstructuredGrid.VTUUnstructuredGrid.

Definition at line 297 of file Visualiser.py.

References peano4.api.Logger.Logger._file_name, and _file_name.

◆ parse_and_render_snapshot()

tarch.plotter.api.output.Visualiser.Visualiser.parse_and_render_snapshot ( self,
snapshot )

We pass in a snapshot object here, which should contain time stamp and filenames for everything we want to render here.

Behaviour is:

  • parse all the files listed in snapshot (use the method we wrote)
  • return a dict, where the keys are unknown names, and the values are cell data to be rendered
  • child class should handle the rest.

Reimplemented in tarch.plotter.api.output.VTUUnstructuredGrid.VTUUnstructuredGrid.

Definition at line 369 of file Visualiser.py.

References parse_snapshot().

Referenced by tarch.plotter.api.output.VTUUnstructuredGrid.VTUUnstructuredGrid.display_single_file().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ parse_snapshot()

tarch.plotter.api.output.Visualiser.Visualiser.parse_snapshot ( self,
snapshot )

We rewrite "reload" from previous version of this file.

We take in a argument of "snapshot", which is a helper class with two attributes: timestamp and a list of patch files to parse.

We need to ensure that self.identifier is set correctly so that the correct unknown is picked by the PatchFileParser. Remove this line of comment when this is done.

Also need to handle removal of relative file paths here

The reason we (possibly) apply filters on individual pieces of data, or once the patches have been concatenated is because we may have more than one file to parse per snapshot. The choice is is about whether we want to apply filters before combining all the patches into one list, or afterwards?

What does this function do?

  • Get filename for each patch file in this timestamp
  • Produce a PatchFileParser object for each
  • Parse each file in parallel
  • Apply all the filters specified in render.py
  • Amalgamate data as in original reload() method
  • Returns a dict, where the keys are unknown names, and the values are patches that can be placed into individual patch files

Definition at line 385 of file Visualiser.py.

References _filter, identifier, tarch.plotter.api.input.PatchFileParser.PatchFileParser.patch_filter, tarch.plotter.api.output.PointProbe.PointProbe.patch_filter, patch_filter, tarch.plotter.api.input.PatchFileParser.PatchFileParser.show_progress, tarch.plotter.api.output.PointProbe.PointProbe.show_progress, show_progress, tarch.plotter.api.filters.AverageOverCell.AverageOverCell.verbose, tarch.plotter.api.filters.Calculator.Calculator.verbose, tarch.plotter.api.filters.ExtractFineGrid.ExtractFineGrid.verbose, tarch.plotter.api.filters.Filter.Filter.verbose, tarch.plotter.api.output.PointProbe.PointProbe.verbose, verbose, and TP::Parameters.verbose.

Referenced by parse_and_render_snapshot().

Here is the caller graph for this function:

◆ read_metadata()

tarch.plotter.api.output.Visualiser.Visualiser.read_metadata ( self)

Read the patch file metadata.

In this routine we should:

  • Count the number of timesteps this patch file records
  • Get each of the file paths for the timestep

The meta file includes the snapshot files relative to its own location. We therefore prefix each included file with the directory of the meta file, so the visualiser works from any working directory.

Definition at line 310 of file Visualiser.py.

References _end, peano4.api.Logger.Logger._file_name, _file_name, _start, meta_data_has_been_read, tarch.plotter.api.output.PointProbe.PointProbe.snapshots, and snapshots.

Referenced by display().

Here is the caller graph for this function:

◆ remove_filters()

tarch.plotter.api.output.Visualiser.Visualiser.remove_filters ( self)

Definition at line 365 of file Visualiser.py.

References _filter.

Field Documentation

◆ _description

str tarch.plotter.api.output.Visualiser.Visualiser._description = "" #
protected

Definition at line 279 of file Visualiser.py.

◆ _dimensions

◆ _end

tarch.plotter.api.output.Visualiser.Visualiser._end = end
protected

Definition at line 253 of file Visualiser.py.

Referenced by read_metadata().

◆ _file_name

◆ _filter

list tarch.plotter.api.output.Visualiser.Visualiser._filter = []
protected

Definition at line 254 of file Visualiser.py.

Referenced by append_filter(), parse_snapshot(), and remove_filters().

◆ _is_data_associated_to_cell

bool tarch.plotter.api.output.Visualiser.Visualiser._is_data_associated_to_cell = False
protected

Definition at line 280 of file Visualiser.py.

◆ _start

tarch.plotter.api.output.Visualiser.Visualiser._start = start
protected

Definition at line 252 of file Visualiser.py.

Referenced by read_metadata().

◆ identifier

tuple tarch.plotter.api.output.Visualiser.Visualiser.identifier
Initial value:
= (
"" # This identifier is also used in helper class. pass it along
)

Definition at line 257 of file Visualiser.py.

Referenced by parse_snapshot().

◆ meta_data_has_been_read

bool tarch.plotter.api.output.Visualiser.Visualiser.meta_data_has_been_read = False

Definition at line 287 of file Visualiser.py.

Referenced by read_metadata().

◆ patch_filter

tarch.plotter.api.output.Visualiser.Visualiser.patch_filter = None

Definition at line 276 of file Visualiser.py.

Referenced by parse_snapshot().

◆ show_progress

bool tarch.plotter.api.output.Visualiser.Visualiser.show_progress = True

Definition at line 271 of file Visualiser.py.

Referenced by parse_snapshot().

◆ snapshots

list tarch.plotter.api.output.Visualiser.Visualiser.snapshots = []

Definition at line 284 of file Visualiser.py.

Referenced by read_metadata().

◆ verbose

tarch.plotter.api.output.Visualiser.Visualiser.verbose = verbose

The documentation for this class was generated from the following file: