Time Observer

Header file: <libs/observers/time_observer.hpp> [source]

template<typename Store>
class DoTimeObs

Template class for functionality to observe time at the start of each timestep and write it to a Zarr array as a coordinate of an Xarray dataset.

Template Parameters:

Store – Type of store for dataset.

Public Functions

inline DoTimeObs(Dataset<Store> &dataset, const size_t maxchunk, const std::function<double(unsigned int)> step2dimlesstime)

Constructor for DoTimeObs.

Parameters:
  • datasetDataset to write time data to.

  • maxchunk – Maximum number of elements in a chunk (1-D vector size).

  • step2dimlesstime – Function to convert model timesteps to a real time [assumed seconds].

inline ~DoTimeObs()

Destructor for DoTimeObs.

inline void before_timestepping(const viewd_constgbx d_gbxs) const

Placeholder for before timestepping functionality and to make class satisfy observer concept.

inline void after_timestepping() const

Placeholder for after timestepping functionality and to make class satisfy observer concept.

inline void at_start_step(const unsigned int t_mdl, const viewd_constgbx d_gbxs, const viewd_constsupers totsupers) const

Adapter to call at start step function which writes the current time of the model (assumed seconds) to the array in the dataset.

Parameters:
  • t_mdl – Current model timestep.

  • d_gbxs – View of gridboxes on device.

  • totsupers – View of superdrops on device.

inline SDMMonitor auto get_sdmmonitor() const

Get null monitor for SDM processes from observer.

Returns:

monitor ‘mo’ of the observer that does nothing

Private Functions

inline void at_start_step(const unsigned int t_mdl) const

Increment size of time dimension in dataset and write out current time of model (assumed seconds) to the array in the dataset.

Note: conversion of time from double precision (8 bytes double) to single precision (4 bytes float) in output.

Parameters:

t_mdl – Current model time.

Private Members

Dataset<Store> &dataset

Dataset to write time data to.

std::shared_ptr<XarrayZarrArray<Store, float>> xzarr_ptr

Pointer to time array in dataset.

std::function<double(unsigned int)> step2dimlesstime

Function to convert timesteps to real time [assumed seconds].

template<typename Store>
inline Observer auto TimeObserver(const unsigned int interval, Dataset<Store> &dataset, const size_t maxchunk, const std::function<double(unsigned int)> step2dimlesstime)

Constructs an observer which writes (real) time at start of each observation timestep to a 1-D array with a constant observation timestep “interval”.

Template Parameters:

Store – Type of store for dataset.

Parameters:
  • interval – Observation timestep.

  • datasetDataset to write time data to.

  • maxchunk – Maximum number of elements in a chunk (1-D vector size).

  • step2dimlesstime – Function to convert model timesteps to real time (assumed seconds).

Returns:

Constructed type satisfying observer concept.