Base

class stride.problem.base.Gridded(**kwargs)[source]

Bases: object

Objects of this type are defined over a spatio-temporal grid.

This grid can be provided either as a Grid object or as any of Space, Time or SlowTime objects that define a grid.

Parameters:
  • grid (Grid, optional) – Existing grid, if not provided one will be created.

  • space (Space, optional) –

  • time (Time, optional) –

  • slow_time (SlowTime, optional) –

property grid

Access the grid.

resample(grid=None, space=None, time=None, slow_time=None)[source]
property slow_time

Access the slow time grid.

property space

Access the space grid.

property time

Access the time grid.

class stride.problem.base.Saved(**kwargs)[source]

Bases: object

Saved objects include helper functions to interact with the file system.

Classes that inherit from Saved need to define __get_desc__ and __set_desc__ to define how the object is described to be saved and how a loaded description is digested by the class respectively.

__get_desc__ expects a dict-like object with all the attributes that need to be stored to disk and is called when dumping the object.

__set_desc__ will take a dict-like object as a parameter, which it can then be used to set the state of the object, and is called when loading it.

Parameters:

name (str) – Name of the saved object.

append(*args, **kwargs)[source]

Append the object to a file according to the __get_desc__ description.

See HDF5 for more information on the parameters of this method.

dump(*args, **kwargs)[source]

Dump the object according to the __get_desc__ description.

See HDF5 for more information on the parameters of this method.

load(*args, **kwargs)[source]

Load the object using __set_desc__ to digest the description.

See HDF5 for more information on the parameters of this method.

rm(*args, **kwargs)[source]

Remove file.

See rm for more information on the parameters of this method.

class stride.problem.base.GriddedSaved(**kwargs)[source]

Bases: Saved, Gridded

Objects of this type are include utils to dump and load the instance, taking into account that it is defined over a grid.

append(*args, **kwargs)[source]

Append the object to a file according to the __get_desc__ description.

It will ensure that the grid of the instance is also dumped to disk.

See HDF5 for more information on the parameters of this method.

dump(*args, **kwargs)[source]

Dump the object according to the __get_desc__ description.

It will ensure that the grid of the instance is also dumped to disk.

See HDF5 for more information on the parameters of this method.

grid_description()[source]

Get a description of the grid of the object.

Returns:

Description of the grid.

Return type:

dict

load(*args, **kwargs)[source]

Load the object using __set_desc__ to digest the description.

It will use the grid loaded from file to determine the grid of the instance.

See HDF5 for more information on the parameters of this method.

resample(grid=None, space=None, time=None, slow_time=None)[source]
class stride.problem.base.ProblemBase(**kwargs)[source]

Bases: GriddedSaved

Base class for the different components of the problem that need to have access to it and that also create sub-problems.

Parameters:
  • name (str) – Name of the object.

  • problem (Problem) – Problem to which the object belongs.

  • grid (Grid or any of Space or Time) – Grid on which the object is defined

property problem

Access problem object.

sub_problem(shot, sub_problem)[source]

Create a subset object for a certain shot.

A SubProblem contains everything that is needed to fully determine how to run a particular shot. This method takes care of selecting the portions of the object that are needed for a given shot.

By default, this has no effect.

Parameters:
  • shot (Shot) – Shot for which the SubProblem is being generated.

  • sub_problem (SubProblem) – Container for the sub-problem being generated.

Returns:

ProblemBase instance.

Return type:

ProblemBase