wolfgpu.results_store
Author: HECE - University of Liege, Stéphane Champailler, Pierre Archambeau Date: 2024
Copyright (c) 2024 University of Liege. All rights reserved.
This script and its content are protected by copyright law. Unauthorized copying or distribution of this file, via any medium, is strictly prohibited.
Module Contents
- class wolfgpu.results_store.SimulationEventType[source]
Bases:
enum.Enum
Generic enumeration.
Derive from this class to define new enumerations.
- class wolfgpu.results_store.ResultType[source]
Bases:
enum.Enum
Enumerate all the possible results types stored in the
ResultsStore
. Some of these represents scalars, some are numpy arrays.- NB_ACTIVE_TILES = 3[source]
The number of active tiles in the simulation. An active tile is a tile where there is some water.
- DELTA_EARLY_OUT = 6[source]
The delta early out is an approximate measurement of the “stabilisation” of the simulation. It is computed like so:
\(\Delta S = S_{i+1} - S_i\) where \(S_i = \sum_{\text{m in all meshes}} |m_h| + |m_{q_x}| + |m_{q_y}|\)
In other words, the rate of change between two successive recordings computed over \(h,qx,qy\) of each mesh individually.
- NB_MOSTLY_DRY_MESHES = 7[source]
Number of mostly dry mesh. A mostly dry mesh is a mesh where water height is not zero but very small (< 1e-5 m).
- class wolfgpu.results_store.SimulationEvent(event_type: SimulationEventType, simulation_time: float, simulation_step: int, data=None)[source]
-
- file_content()[source]
Return the file content of the event. In case of a BathymetryUpdate event, returns the numpy array used for the update.
Note: we return the file content because we make no guarantees on the fact that the file can actually be read from the disk like a regular file (because we may zip it).
- class wolfgpu.results_store.ResultsStore(sim_path: pathlib.Path, mode: str = 'a', tile_packer: wolfgpu.tile_packer.TilePacker = None)[source]
A ResultsStore is a tiny container meant to hold the results of a simulation. It gives several ways to query the results easily.
- property nb_results[source]
The number of results currently stored in the result store. The last result’s index is this value.
- property path: pathlib.Path[source]
Returns the path where the result store is located. It is either a directory or a path to a zip-file.
- property _first_row_len[source]
Returns the number of columns in the first row of the CSV file.
This is useful to know if the CSV file has been updated with new columns that we don’t know about yet.
- reload(only_if_changed: bool = True)[source]
Reloads this result store.
If only_if_changed is True (the default), the store will be reloaded only if its number of results has changed (compared to what it was when first opened). If False, the store will be reloaded forcefully. Reloading only makes sense in ‘r’ (read) mode.
This method can be used to track the growth of a result store while it is populated by the simulator.
- truncate_at_report(n: int)[source]
Kill records from n+1 (included) to the last one n is one based !
- make_a_copy(dest_path: str | pathlib.Path) ResultsStore [source]
Make a copy of the result store and put it in the given path.
- Parameters:
dest_path – where to put the copy.
- Returns:
the copy of the results store, open in read only mode.
- append_result(step_num: int, sim_time: float, dt: float, niter: int, niter_rk: int, h: numpy.ndarray, qx: numpy.ndarray, qy: numpy.ndarray, dbg1: numpy.ndarray = None, dbg2: numpy.ndarray = None, clock_time: float = 0, delta_early_out: float = 0, nb_mostly_dry_meshes: int = 0)[source]
- append_additional_result(name, data: numpy.ndarray)[source]
One can store additional results which have their own names (so they don’t belong to the ResultType). For now this is limited to numpy arrays.
This function is a hack to help debugging. Don’t use it !!!
- add_event(event_type: SimulationEventType, simulation_time=float, simulation_step=int, data=None)[source]
Record a simulation event. - simulation_time is expressed in seconds - simulation_step is of course an unsigned integer
For BathymetryUdate event you must pass the a Path to the bathymetry update file (which will be copied into the result store).
- get_events_between_steps(first_step: int, last_step: int) list[SimulationEvent] [source]
Query the events that sits between the given first/last simulation steps.
- Parameters:
first_step – the first simulation steps to consider (1-based)
last_step – the last simulation steps to consider (1-based)
- get_last_result_index() int [source]
Get the index of the last result in in this result store. The index can be used to query data in the store.
- get_last_result(ndx=0) tuple[float, float, int, int, numpy.ndarray, numpy.ndarray, numpy.ndarray] [source]
returns [t,dt,n_iter_dry_up_euler, n_iter_dry_up_rk, h,qx,qy]
- get_result(ndx: int) tuple[float, float, int, int, numpy.ndarray, numpy.ndarray, numpy.ndarray] [source]
returns [t, dt, n_iter_dry_up_euler, n_iter_dry_up_rk, h, qx, qy]
- get_last_named_result(name: str | list[str], delta_ndx: int = 0) numpy.ndarray | list[numpy.ndarray] [source]
- Get the last result by name(s). The names are those accepted by
get_named_result. delta_ndx means an offset to be added to the last index so that you can count backward fro the last index (so it’s always negative). For example a value of -2 means you’ll take the third result starting from the last one. A value of 0 means you take the last one.
You can call this like this: - get_last_named_result(“qy”) - get_last_named_result( “h”, “qy”) - get_last_named_result( [ “h”, “qy” ]) - get_last_named_result( [ “h”, “qy”, ResultType.QX ])
- _is_result_type_in_database(rt: ResultType)[source]
- get_named_series(name: str | ResultType) list [source]
Returns the series of all recordings of the value identified by the name parameter.
Currently only works for scalar values (i.e. not matrices).
- get_named_result(name: str | list[str] | ResultType | list[ResultType], ndx: int) numpy.ndarray | list[numpy.ndarray] [source]
Looks for result by names.
- Parameters:
name – Supported names are: t, last_delta_t, step_num, h, qx, qy. You can also use ResultType.
ndx – Result number. 1-based.