Data
- class stride.problem.data.Data(**kwargs)[source]
Bases:
stride.problem.base.GriddedSaved
,stride.core.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.
- 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:
stride.problem.data.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, anextended_shape
may be provided if the data is defined over an inner and extended domain. If an extended domain is defined, theinner
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
- property allocated
Whether or not the data has been allocated.
- 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
- 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
- property data
Data values inside the inner domain, as an ndarray.
- detach(*args, **kwargs)[source]
Create a copy of the variable that is detached from the original graph.
- Returns
Detached variable.
- Return type
- 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(prec_scale=1e-09, **kwargs)[source]
Process the gradient by applying the pre-conditioner to it.
- Parameters
prec_scale (float, optional) – Condition scaling for the 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:
stride.problem.data.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
- 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
- property comms
- detach(*args, **kwargs)[source]
Create a copy of the variable that is detached from the original graph.
- Returns
Detached variable.
- Return type
- 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, order=3, prefilter=True, **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. The default is
True
.
- resample_data(data, space, order=3, prefilter=True)[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 interplation, default is 3.
prefilter (bool, optional) – Determines if the input array is prefiltered before interpolation. The default is
True
.
- 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
ornearest
, defaults tonearest
.
- 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
ornearest
, defaults tonearest
.
- 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:
stride.problem.data.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
- 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
- property comms
- detach(*args, **kwargs)[source]
Create a copy of the variable that is detached from the original graph.
- Returns
Detached variable.
- Return type
- 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)
- 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:
stride.problem.data.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
- 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
- property comms
- detach(*args, **kwargs)[source]
Create a copy of the variable that is detached from the original graph.
- Returns
Detached variable.
- Return type
- 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:
stride.problem.data.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