salvus.opt.data_normalizations
salvus.opt.data_normalizations salvus opt data_normalizations Data normalizations and their jacobians.
Functions
get_available_data_normalizations()
get_available_data_normalizations()def get_available_data_normalizations() -> list[str]: ...Get a list of all available data normalizations.
get_data_normalization()
get_data_normalization()def get_data_normalization(name: str) -> Normalization: ...Get a built-in data normalization via its name.
namestr — The name of the data normalization.
Classes
ForwardNormProtocol
ForwardNormProtocolclass ForwardNormProtocol(typing.Protocol):
def __init__(self):
...Base class for protocol classes.
Protocol classes are defined as::
class Proto(Protocol):
def meth(self) -> int:
...
Such classes are primarily used with static type checkers that recognize structural subtyping (static duck-typing).
For example::
class C:
def meth(self) -> int:
return 0
def func(x: Proto) -> int:
return x.meth()
func(C()) # Passes static type check
See PEP 544 for details. Protocol classes decorated with @typing.runtime_checkable act as simple-minded runtime protocols that check only the presence of given attributes, ignoring their type signatures. Protocol classes can be generic, they are defined as::
class GenProto(Protocol[T]):
def meth(self) -> T:
...ForwardTraceNormProtocol
ForwardTraceNormProtocolclass ForwardTraceNormProtocol(typing.Protocol):
def __init__(self):
...Base class for protocol classes.
Protocol classes are defined as::
class Proto(Protocol):
def meth(self) -> int:
...
Such classes are primarily used with static type checkers that recognize structural subtyping (static duck-typing).
For example::
class C:
def meth(self) -> int:
return 0
def func(x: Proto) -> int:
return x.meth()
func(C()) # Passes static type check
See PEP 544 for details. Protocol classes decorated with @typing.runtime_checkable act as simple-minded runtime protocols that check only the presence of given attributes, ignoring their type signatures. Protocol classes can be generic, they are defined as::
class GenProto(Protocol[T]):
def meth(self) -> T:
...JacobianNormProtocol
JacobianNormProtocolclass JacobianNormProtocol(typing.Protocol):
def __init__(self):
...Base class for protocol classes.
Protocol classes are defined as::
class Proto(Protocol):
def meth(self) -> int:
...
Such classes are primarily used with static type checkers that recognize structural subtyping (static duck-typing).
For example::
class C:
def meth(self) -> int:
return 0
def func(x: Proto) -> int:
return x.meth()
func(C()) # Passes static type check
See PEP 544 for details. Protocol classes decorated with @typing.runtime_checkable act as simple-minded runtime protocols that check only the presence of given attributes, ignoring their type signatures. Protocol classes can be generic, they are defined as::
class GenProto(Protocol[T]):
def meth(self) -> T:
...JacobianTraceNormProtocol
JacobianTraceNormProtocolclass JacobianTraceNormProtocol(typing.Protocol):
def __init__(self):
...Base class for protocol classes.
Protocol classes are defined as::
class Proto(Protocol):
def meth(self) -> int:
...
Such classes are primarily used with static type checkers that recognize structural subtyping (static duck-typing).
For example::
class C:
def meth(self) -> int:
return 0
def func(x: Proto) -> int:
return x.meth()
func(C()) # Passes static type check
See PEP 544 for details. Protocol classes decorated with @typing.runtime_checkable act as simple-minded runtime protocols that check only the presence of given attributes, ignoring their type signatures. Protocol classes can be generic, they are defined as::
class GenProto(Protocol[T]):
def meth(self) -> T:
...Normalization
Normalizationclass Normalization(
salvus.flow.utils.serialization_helpers.SerializationMixin, typing.Generic
):
def __init__(
self,
forward: ForwardNormProtocol | str,
jacobian: JacobianNormProtocol | str,
skip_validation: bool = False,
): ...Keeps track of the initial arguments passed to an objects and can later on serialize them to JSON document.
It will only consider whatever is passed in the init.
A per-shot type of data normalization and its jacobian.
forwardForwardNormProtocol | str — Function implementing the data normalization.jacobianJacobianNormProtocol | str — Function implementing the jacobian of the data normalization.skip_validationbool — By default the forward and jacobian functions will be validated with a gradient test. Set this to True to skip that test.
from_json()
from_json()def from_json(d: builtins.dict) -> Any: ...Recreate the object from a dictionary serialization of its initialization parameters.
dbuiltins.dict — Dictionary containing its init parameters and a few other things.
forward()
forward()def forward(
self,
data_array_synthetic: xr.DataArray,
data_array_observed: T,
event: Event,
) -> tuple[xr.DataArray, T]: ...Apply the forward data normalization function.
Returns the normalized synthetic and observed data traces, respectively.
data_array_syntheticxr.DataArray — The synthetic data traces without normalization.data_array_observedT — The observed data traces without normalization.eventEvent — The event object.
jacobian()
jacobian()def jacobian(
self,
data_array_adjoint_sources: xr.DataArray,
data_array_synthetic: xr.DataArray,
data_array_observed: T,
event: Event,
) -> xr.DataArray: ...Apply the jacobian of the forward data normalization function to the adjoint source and return it.
data_array_adjoint_sourcesxr.DataArray — The adjoint sources.data_array_syntheticxr.DataArray — The synthetic data traces without normalization.data_array_observedT — The observed data traces without normalization.eventEvent — The event object.
perform_gradient_test()
perform_gradient_test()def perform_gradient_test(self) -> None: ...Perform a gradient test to validate the jacobian function.
This will test that the jacobian is the correct jacobian for the chosen forward normalization.
to_json()
to_json()def to_json(
self,
external_file_hash: types = None,
timer: types = None,
log_to_logger: bool = False,
comm: types = None,
) -> builtins.dict: ...Serialize the object to a dictionary that can be written to JSON.
external_file_hashtypes — Hash of any external files associated with this object. Can be passed here in which case it will be stored in a centralized location in the JSON file.timertypes — Execution timer.log_to_loggerbool — Log timings to the logger.commtypes — MPI communicator, if any.
TraceNormalization
TraceNormalizationclass TraceNormalization(
salvus.flow.utils.serialization_helpers.SerializationMixin, typing.Generic
):
def __init__(
self,
forward: ForwardTraceNormProtocol | str,
jacobian: JacobianTraceNormProtocol | str,
skip_validation: bool = False,
): ...Keeps track of the initial arguments passed to an objects and can later on serialize them to JSON document.
It will only consider whatever is passed in the init.
A per-trace type of data normalization and its jacobian.
forwardForwardTraceNormProtocol | str — Function implementing the data normalization.jacobianJacobianTraceNormProtocol | str — Function implementing the jacobian of the data normalization.skip_validationbool — By default the forward and jacobian functions will be validated with a gradient test. Set this to True to skip that test.
from_json()
from_json()def from_json(d: builtins.dict) -> Any: ...Recreate the object from a dictionary serialization of its initialization parameters.
dbuiltins.dict — Dictionary containing its init parameters and a few other things.
forward()
forward()def forward(
self,
data_synthetic: npt.NDArray,
data_observed: T,
sampling_rate_in_hertz: float,
) -> tuple[npt.NDArray, T]: ...Apply the forward data normalization function.
Returns the normalized synthetic and observed data traces, respectively.
data_syntheticnpt.NDArray — The synthetic data trace without normalization.data_observedT — The observed data trace without normalization.sampling_rate_in_hertzfloat — The sampling rate of both data traces in Hz.
jacobian()
jacobian()def jacobian(
self,
adjoint_source: npt.NDArray,
data_synthetic: npt.NDArray,
data_observed: T,
sampling_rate_in_hertz: float,
) -> npt.NDArray: ...Apply the jacobian of the forward data normalization function to the adjoint source and return it.
adjoint_sourcenpt.NDArray — The adjoint source.data_syntheticnpt.NDArray — The synthetic data trace without normalization.data_observedT — The observed data trace without normalization.sampling_rate_in_hertzfloat — The sampling rate of the adjoint source and data in Hz.
perform_gradient_test()
perform_gradient_test()def perform_gradient_test(self) -> None: ...Perform a gradient test to validate the jacobian function.
This will test that the jacobian is the correct jacobian for the chosen forward normalization.
to_block_normalization()
to_block_normalization()def to_block_normalization(self) -> Normalization: ...Convert the trace wise normalization to a block normalization.
to_json()
to_json()def to_json(
self,
external_file_hash: types = None,
timer: types = None,
log_to_logger: bool = False,
comm: types = None,
) -> builtins.dict: ...Serialize the object to a dictionary that can be written to JSON.
external_file_hashtypes — Hash of any external files associated with this object. Can be passed here in which case it will be stored in a centralized location in the JSON file.timertypes — Execution timer.log_to_loggerbool — Log timings to the logger.commtypes — MPI communicator, if any.