Version:

salvus.opt.data_normalizations

salvus.opt.data_normalizations salvus opt data_normalizations
Data normalizations and their jacobians.

Functions

get_available_data_normalizations()

Get a list of all available data normalizations.
SIGNATURE
def get_available_data_normalizations() -> list[str]: ...
RETURNS
Return type: list[str]

get_data_normalization()

Get a built-in data normalization via its name.
SIGNATURE
def get_data_normalization(name: str) -> Normalization: ...
ARGUMENTS
Required
name
Type:str
Description:
The name of the data normalization.
RETURNS
Return type: Normalization

Classes

ForwardNormProtocol

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:
        ...
SIGNATURE
class ForwardNormProtocol(typing.Protocol):
    def __init__(self):
        ...

ForwardTraceNormProtocol

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:
        ...
SIGNATURE
class ForwardTraceNormProtocol(typing.Protocol):
    def __init__(self):
        ...

JacobianNormProtocol

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:
        ...
SIGNATURE
class JacobianNormProtocol(typing.Protocol):
    def __init__(self):
        ...

JacobianTraceNormProtocol

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:
        ...
SIGNATURE
class JacobianTraceNormProtocol(typing.Protocol):
    def __init__(self):
        ...

Normalization

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.
SIGNATURE
class Normalization(
    salvus.flow.utils.serialization_helpers.SerializationMixin, typing.Generic
):
    def __init__(
        self,
        forward: ForwardNormProtocol | str,
        jacobian: JacobianNormProtocol | str,
        skip_validation: bool = False,
    ): ...
ARGUMENTS
Required
forward
Type:ForwardNormProtocol | str
Description:
Function implementing the data normalization.
Required
jacobian
Type:JacobianNormProtocol | str
Description:
Function implementing the jacobian of the data normalization.
Optional
skip_validation
Type:bool
Default value:False
Description:
By default the forward and jacobian functions will be validated with a gradient test. Set this to True to skip that test.

Class Methods

Normalization.from_json()
Recreate the object from a dictionary serialization of its initialization parameters.
SIGNATURE
def from_json(d: builtins.dict) -> Any: ...
ARGUMENTS
Required
d
Type:builtins.dict
Description:
Dictionary containing its init parameters and a few other things.

Methods

Normalization.forward()
Apply the forward data normalization function.
Returns the normalized synthetic and observed data traces, respectively.
SIGNATURE
def forward(
    self,
    data_array_synthetic: xr.DataArray,
    data_array_observed: T,
    event: Event,
) -> tuple[xr.DataArray, T]: ...
ARGUMENTS
Required
data_array_synthetic
Type:xr.DataArray
Description:
The synthetic data traces without normalization.
Required
data_array_observed
Type:T
Description:
The observed data traces without normalization.
Required
event
Type:Event
Description:
The event object.
Normalization.jacobian()
Apply the jacobian of the forward data normalization function to the adjoint source and return it.
SIGNATURE
def jacobian(
    self,
    data_array_adjoint_sources: xr.DataArray,
    data_array_synthetic: xr.DataArray,
    data_array_observed: T,
    event: Event,
) -> xr.DataArray: ...
ARGUMENTS
Required
data_array_adjoint_sources
Type:xr.DataArray
Description:
The adjoint sources.
Required
data_array_synthetic
Type:xr.DataArray
Description:
The synthetic data traces without normalization.
Required
data_array_observed
Type:T
Description:
The observed data traces without normalization.
Required
event
Type:Event
Description:
The event object.
Normalization.perform_gradient_test()
Perform a gradient test to validate the jacobian function.
This will test that the jacobian is the correct jacobian for the chosen forward normalization.
SIGNATURE
def perform_gradient_test(self) -> None: ...
Normalization.to_json()
Serialize the object to a dictionary that can be written to JSON.
SIGNATURE
def to_json(
    self,
    external_file_hash: types = None,
    timer: types = None,
    log_to_logger: bool = False,
    comm: types = None,
) -> builtins.dict: ...
ARGUMENTS
Optional
external_file_hash
Type:types
Default value:None
Description:
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.
Optional
timer
Type:types
Default value:None
Description:
Execution timer.
Optional
log_to_logger
Type:bool
Default value:False
Description:
Log timings to the logger.
Optional
comm
Type:types
Default value:None
Description:
MPI communicator, if any.

TraceNormalization

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.
SIGNATURE
class TraceNormalization(
    salvus.flow.utils.serialization_helpers.SerializationMixin, typing.Generic
):
    def __init__(
        self,
        forward: ForwardTraceNormProtocol | str,
        jacobian: JacobianTraceNormProtocol | str,
        skip_validation: bool = False,
    ): ...
ARGUMENTS
Required
forward
Type:ForwardTraceNormProtocol | str
Description:
Function implementing the data normalization.
Required
jacobian
Type:JacobianTraceNormProtocol | str
Description:
Function implementing the jacobian of the data normalization.
Optional
skip_validation
Type:bool
Default value:False
Description:
By default the forward and jacobian functions will be validated with a gradient test. Set this to True to skip that test.

Class Methods

TraceNormalization.from_json()
Recreate the object from a dictionary serialization of its initialization parameters.
SIGNATURE
def from_json(d: builtins.dict) -> Any: ...
ARGUMENTS
Required
d
Type:builtins.dict
Description:
Dictionary containing its init parameters and a few other things.

Methods

TraceNormalization.forward()
Apply the forward data normalization function.
Returns the normalized synthetic and observed data traces, respectively.
SIGNATURE
def forward(
    self,
    data_synthetic: npt.NDArray,
    data_observed: T,
    sampling_rate_in_hertz: float,
) -> tuple[npt.NDArray, T]: ...
ARGUMENTS
Required
data_synthetic
Type:npt.NDArray
Description:
The synthetic data trace without normalization.
Required
data_observed
Type:T
Description:
The observed data trace without normalization.
Required
sampling_rate_in_hertz
Type:float
Description:
The sampling rate of both data traces in Hz.
TraceNormalization.jacobian()
Apply the jacobian of the forward data normalization function to the adjoint source and return it.
SIGNATURE
def jacobian(
    self,
    adjoint_source: npt.NDArray,
    data_synthetic: npt.NDArray,
    data_observed: T,
    sampling_rate_in_hertz: float,
) -> npt.NDArray: ...
ARGUMENTS
Required
adjoint_source
Type:npt.NDArray
Description:
The adjoint source.
Required
data_synthetic
Type:npt.NDArray
Description:
The synthetic data trace without normalization.
Required
data_observed
Type:T
Description:
The observed data trace without normalization.
Required
sampling_rate_in_hertz
Type:float
Description:
The sampling rate of the adjoint source and data in Hz.
TraceNormalization.perform_gradient_test()
Perform a gradient test to validate the jacobian function.
This will test that the jacobian is the correct jacobian for the chosen forward normalization.
SIGNATURE
def perform_gradient_test(self) -> None: ...
TraceNormalization.to_block_normalization()
Convert the trace wise normalization to a block normalization.
SIGNATURE
def to_block_normalization(self) -> Normalization: ...
TraceNormalization.to_json()
Serialize the object to a dictionary that can be written to JSON.
SIGNATURE
def to_json(
    self,
    external_file_hash: types = None,
    timer: types = None,
    log_to_logger: bool = False,
    comm: types = None,
) -> builtins.dict: ...
ARGUMENTS
Optional
external_file_hash
Type:types
Default value:None
Description:
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.
Optional
timer
Type:types
Default value:None
Description:
Execution timer.
Optional
log_to_logger
Type:bool
Default value:False
Description:
Log timings to the logger.
Optional
comm
Type:types
Default value:None
Description:
MPI communicator, if any.

Submodules

PAGE CONTENTS