Data

class stride.problem.data.Data(**kwargs)[source]

Bases: GriddedSaved, Variable

Objects of this type represent Data defined over a grid and on which mathematical operations might be performed. This data might or might not be structured.

clear_grad()[source]

Clear the gradient buffer of the variable.

property comms
property head
classmethod local(*args, uid=None, **kwargs)
classmethod local_parameter(*args, uid=None, **kwargs)
property logger
property loop
property monitor
property node
classmethod parameter(*args, uid=None, **kwargs)
process_grad()[source]

Process the gradient of the variable for its use.

Returns:

Processed gradient

Return type:

object

classmethod remote(*args, **kwargs)
property runtime
async classmethod select_worker(runtime=None)

Select an available worker.

Parameters:

runtime (str or Runtime, optional) – If a valid runtime is given, this will be selected as the target worker.

Returns:

UID of the target worker.

Return type:

str

property worker
property zmq_context
class stride.problem.data.StructuredData(**kwargs)[source]

Bases: Data

Objects of this type represent data defined over a structured grid.

This grid is on which the data lives is fully defined by the shape parameter. Optionally, an extended_shape may be provided if the data is defined over an inner and extended domain. If an extended domain is defined, the inner parameter can be used to determine the position of the inner domain within the larger extended domain.

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

  • shape (tuple) – Shape of the inner domain of the data.

  • extended_shape (tuple, optional) – Shape of the extended domain of the data, defaults to the shape.

  • inner (tuple, optional) – Tuple of slices defining the location of the inner domain inside the extended domain, defaults to the inner domain being centred.

  • dtype (data-type, optional) – Data type of the data, defaults to float32.

  • data (ndarray, optional) – Data with which to initialise the internal buffer, defaults to a new array. By default, no copies of the buffer are made if provided.

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

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

Create a data object that shares its characteristics with this object.

The same parameters as those given to __init__ are valid here. Otherwise the new object will be configured to be like this one.

Returns:

Newly created StructuredData.

Return type:

StructuredData

allocate()[source]

Allocate the data if this has not been allocated yet.

property allocated

Whether or not the data has been allocated.

apply_prec(prec_scale=0.25, prec_op=None, prec=None, **kwargs)[source]

Apply a pre-conditioner to the current field.

Parameters:
  • prec_scale (float, optional) – Condition scaling for the preconditioner.

  • prec_op (callable, optional) – Additional operation to apply to the preconditioner.

  • prec (StructuredData, optional) – Pre-conditioner to apply. Defaults to self.prec.

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

Create a copy of the variable that is detached from the original graph and re-initialised as a parameter.

Returns:

Detached variable.

Return type:

StructuredData

clear_grad()[source]

Initialise and clear the internal buffers for the gradient and preconditioner.

property comms
copy(**kwargs)[source]

Create a deep copy of the data object.

Returns:

Newly created StructuredData.

Return type:

StructuredData

property data

Data values inside the inner domain, as an ndarray.

deallocate(collect=False)[source]

Deallocate the data.

Parameters:

collect (bool, optional) –

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

Create a copy of the variable that is detached from the original graph.

Returns:

Detached variable.

Return type:

StructuredData

property dtype

Data-type of the data.

property extended_data

Data values inside the extended domain, as an ndarray.

property extended_shape

Shape of the extended domain, as a tuple.

fill(value)[source]

Fill the data with a certain value

Parameters:

value (float) – Value with which to fill the data.

property head
property inner

Slices that determine the location of the inner domain with respect to the extended domain, as a tuple of slices.

classmethod local(*args, uid=None, **kwargs)
classmethod local_parameter(*args, uid=None, **kwargs)
property logger
property loop
property monitor
property ndim

Number of data dimensions.

property node
pad(smooth=False)[source]

Pad internal data to match the extended shape of the StructuredData.

Parameters:

smooth (bool, optional) – Whether or not to smooth the padding area, defaults to False

pad_data(data, smooth=False)[source]

Pad input data to match the extended shape of the StructuredData.

Parameters:
  • data (ndarray) – Array to pad.

  • smooth (bool, optional) – Whether or not to smooth the padding area, defaults to False

Returns:

Padded array.

Return type:

ndarray

classmethod parameter(*args, uid=None, **kwargs)
process_grad(**kwargs)[source]

Process the gradient by applying the pre-conditioner to it.

Parameters:

prec_scale (float, optional) – Condition scaling for the preconditioner.

release_grad()[source]

Release the internal buffers for the gradient and preconditioner.

classmethod remote(*args, **kwargs)
property runtime
async classmethod select_worker(runtime=None)

Select an available worker.

Parameters:

runtime (str or Runtime, optional) – If a valid runtime is given, this will be selected as the target worker.

Returns:

UID of the target worker.

Return type:

str

property shape

Shape of the inner domain, as a tuple.

property worker
property zmq_context
class stride.problem.data.ScalarField(**kwargs)[source]

Bases: StructuredData

Objects of this type describe a scalar field defined over the spatial grid. Scalar fields can also be time-dependent.

By default, the domain over which the field is defined is determined by the grid provided. This can be overwritten by providing a defined shape instead.

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

  • time_dependent (bool, optional) – Whether or not the field is time-dependent, defaults to False.

  • slow_time_dependent (bool, optional) – Whether or not the field is slow-time dependent, defaults to False.

  • shape (tuple, optional) – Shape of the inner domain of the data.

  • extended_shape (tuple, optional) – Shape of the extended domain of the data, defaults to the shape.

  • inner (tuple, optional) – Tuple of slices defining the location of the inner domain inside the extended domain, defaults to the inner domain being centred.

  • dtype (data-type, optional) – Data type of the data, defaults to float32.

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

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

Create a data object that shares its characteristics with this object.

The same parameters as those given to __init__ are valid here. Otherwise the new object will be configured to be like this one.

Returns:

Newly created ScalarField.

Return type:

ScalarField

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

Create a copy of the variable that is detached from the original graph and re-initialised as a parameter.

Returns:

Detached variable.

Return type:

ScalarField

property comms
detach(*args, **kwargs)[source]

Create a copy of the variable that is detached from the original graph.

Returns:

Detached variable.

Return type:

ScalarField

extended_plot(**kwargs)[source]

Plot the extended domain of the field.

Parameters:

kwargs – Arguments for plotting.

Returns:

Axes on which the plotting is done.

Return type:

axes

property head
classmethod local(*args, uid=None, **kwargs)
classmethod local_parameter(*args, uid=None, **kwargs)
property logger
property loop
property monitor
property node
classmethod parameter(*args, uid=None, **kwargs)
plot(**kwargs)[source]

Plot the inner domain of the field.

Parameters:

kwargs – Arguments for plotting.

Returns:

Axes on which the plotting is done.

Return type:

axes

classmethod remote(*args, **kwargs)
resample(space=None, **kwargs)[source]

Resample the internal (non-padded) data given some new space object.

Parameters:
  • space (Space) – New space.

  • order (int, optional) – Order of the interplation, default is 3.

  • prefilter (bool, optional) – Determines if the input array is prefiltered before interpolation. If downsampling, this defaults to False as an anti-aliasing filter will be applied instead. If upsampling, this defaults to True.

  • anti_alias (bool, optional) – Whether a Gaussian filter is applied to smooth the data before interpolation. The default is True. This is only applied when downsampling.

  • anti_alias_sigma (float or tuple of floats, optional) – Gaussian filter standard deviations used for the anti-aliasing filter. The default is (d - 1) / 2 where d is the downsampling factor and d > 1. When upsampling, d < 1, and no anti-aliasing filter is applied.

resample_data(data, space, **kwargs)[source]

Resample the data given some new space object.

Parameters:
  • data (ndarray) – Data to stagger.

  • space (Space) – New space.

  • order (int, optional) – Order of the interpolation, default is 3.

  • prefilter (bool, optional) – Determines if the input array is prefiltered before interpolation. If downsampling, this defaults to False as an anti-aliasing filter will be applied instead. If upsampling, this defaults to True.

  • anti_alias (bool, optional) – Whether a Gaussian filter is applied to smooth the data before interpolation. The default is True. This is only applied when downsampling.

  • anti_alias_sigma (float or tuple of floats, optional) – Gaussian filter standard deviations used for the anti-aliasing filter. The default is (d - 1) / 2 where d is the downsampling factor and d > 1. When upsampling, d < 1, and no anti-aliasing filter is applied.

Returns:

Resampled data.

Return type:

ndarray

property runtime
async classmethod select_worker(runtime=None)

Select an available worker.

Parameters:

runtime (str or Runtime, optional) – If a valid runtime is given, this will be selected as the target worker.

Returns:

UID of the target worker.

Return type:

str

property slow_time_dependent

Whether or not the field is slow-time dependent.

stagger(stagger, method='nearest')[source]

Resample the internal (non-padded) data given some spatial staggering.

Parameters:
  • stagger (float or tuple of floats) – Stagger in each dimension.

  • method (str, optional) – Method used for resampling, linear or nearest, defaults to nearest.

stagger_data(data, stagger, method='nearest')[source]

Resample the data given some spatial staggering.

Parameters:
  • data (ndarray) – Data to stagger.

  • stagger (float or tuple of floats) – Stagger in each dimension.

  • method (str, optional) – Method used for resampling, linear or nearest, defaults to nearest.

Returns:

Resampled data.

Return type:

ndarray

property time_dependent

Whether or not the field is time dependent.

property worker
property zmq_context
class stride.problem.data.VectorField(**kwargs)[source]

Bases: ScalarField

Objects of this type describe a vector field defined over the spatial grid. Vector fields can also be time-dependent.

By default, the domain over which the field is defined is determined by the grid provided. This can be overwritten by providing a defined shape instead.

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

  • dim (int, optional) – Number of dimensions for the vector field, defaults to the spatial dimensions.

  • time_dependent (bool, optional) – Whether or not the field is time-dependent, defaults to False.

  • slow_time_dependent (bool, optional) – Whether or not the field is slow-time dependent, defaults to False.

  • shape (tuple, optional) – Shape of the inner domain of the data.

  • extended_shape (tuple, optional) – Shape of the extended domain of the data, defaults to the shape.

  • inner (tuple, optional) – Tuple of slices defining the location of the inner domain inside the extended domain, defaults to the inner domain being centred.

  • dtype (data-type, optional) – Data type of the data, defaults to float32.

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

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

Create a data object that shares its characteristics with this object.

The same parameters as those given to __init__ are valid here. Otherwise the new object will be configured to be like this one.

Returns:

Newly created VectorField.

Return type:

VectorField

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

Create a copy of the variable that is detached from the original graph and re-initialised as a parameter.

Returns:

Detached variable.

Return type:

VectorField

property comms
detach(*args, **kwargs)[source]

Create a copy of the variable that is detached from the original graph.

Returns:

Detached variable.

Return type:

VectorField

property dim

Number of dimensions of the vector field.

property head
classmethod local(*args, uid=None, **kwargs)
classmethod local_parameter(*args, uid=None, **kwargs)
property logger
property loop
property monitor
property node
classmethod parameter(*args, uid=None, **kwargs)
plot_dims(**kwargs)[source]

Plot separated dimensions of the field.

classmethod remote(*args, **kwargs)
property runtime
async classmethod select_worker(runtime=None)

Select an available worker.

Parameters:

runtime (str or Runtime, optional) – If a valid runtime is given, this will be selected as the target worker.

Returns:

UID of the target worker.

Return type:

str

property worker
property zmq_context
class stride.problem.data.Traces(**kwargs)[source]

Bases: StructuredData

Objects of this type describe a set of time traces defined over the time grid.

By default, the domain over which the field is defined is determined by the time grid provided. This can be overwritten by providing a defined shape instead.

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

  • transducer_ids (list) – List of IDs to which the time traces correspond.

  • shape (tuple, optional) – Shape of the inner domain of the data.

  • extended_shape (tuple, optional) – Shape of the extended domain of the data, defaults to the shape.

  • inner (tuple, optional) – Tuple of slices defining the location of the inner domain inside the extended domain, defaults to the inner domain being centred.

  • dtype (data-type, optional) – Data type of the data, defaults to float32.

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

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

Create a data object that shares its characteristics with this object.

The same parameters as those given to __init__ are valid here. Otherwise the new object will be configured to be like this one.

Returns:

Newly created Traces.

Return type:

Traces

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

Create a copy of the variable that is detached from the original graph and re-initialised as a parameter.

Returns:

Detached variable.

Return type:

Traces

property comms
detach(*args, **kwargs)[source]

Create a copy of the variable that is detached from the original graph.

Returns:

Detached variable.

Return type:

Traces

get(id)[source]

Get one trace based on a transducer ID, selecting the inner domain.

Parameters:

id (int) – Transducer ID.

Returns:

Time trace.

Return type:

1d-array

get_extended(id)[source]

Get one trace based on a transducer ID, selecting the extended domain.

Parameters:

id (int) – Transducer ID.

Returns:

Time trace.

Return type:

1d-array

property head
classmethod local(*args, uid=None, **kwargs)
classmethod local_parameter(*args, uid=None, **kwargs)
property logger
property loop
property monitor
property node
property num_transducers

Number of transducers.

classmethod parameter(*args, uid=None, **kwargs)
plot(**kwargs)[source]

Plot the inner domain of the traces as a shot gather.

Parameters:

kwargs – Arguments for plotting.

Returns:

Axes on which the plotting is done.

Return type:

axes

plot_one(id, **kwargs)[source]

Plot the the inner domain of one of the traces.

Parameters:
  • id (int) – Transducer ID.

  • kwargs – Arguments for plotting.

Returns:

Axes on which the plotting is done.

Return type:

axes

classmethod remote(*args, **kwargs)
property runtime
async classmethod select_worker(runtime=None)

Select an available worker.

Parameters:

runtime (str or Runtime, optional) – If a valid runtime is given, this will be selected as the target worker.

Returns:

UID of the target worker.

Return type:

str

property transducer_ids

List of transducer IDs associated with the traces.

property worker
property zmq_context
class stride.problem.data.Scalar(**kwargs)[source]

Bases: StructuredData

property comms
property head
classmethod local(*args, uid=None, **kwargs)
classmethod local_parameter(*args, uid=None, **kwargs)
property logger
property loop
property monitor
property node
classmethod parameter(*args, uid=None, **kwargs)
classmethod remote(*args, **kwargs)
property runtime
async classmethod select_worker(runtime=None)

Select an available worker.

Parameters:

runtime (str or Runtime, optional) – If a valid runtime is given, this will be selected as the target worker.

Returns:

UID of the target worker.

Return type:

str

property worker
property zmq_context