adjtomo/pyatoa

'waveform' misfit naming mismatch with Pyadjoint

Closed this issue · 0 comments

bch0w commented

Pyatoa's Config object expects the waveform misfit function to be input as 'waveform', but Pyadjoint expects this to be called 'waveform_misfit'. This mismatch causes Pyadjoint to throw the following error during the Manager.measure() task:

PyadjointError: Adjoint Source type 'waveform' is unknown. Available types: cc_traveltime_misfit, multitaper_misfit, waveform_misfit

To fix this, the Config object needs to be amended to set the adj_src_type for waveform misfit to be 'waveform_misfit' rather than waveform, which can be found in these code lines:

def format_adj_src_type(choice):
"""
Pyadjoint requires that a standard adjoint source type is given in the
calculate_adjoint_source() function. This function acts as simple dictionary
input to provide the correct input for that function. Allows for various
spellings and variations of the same name.
:type choice: str
:param choice: pyatoa.Config.adj_src_type
:rtype: str
:return: pyadjoint adj_src_type
:raises ValueError: if choice isn't in the provided lists
"""
if choice in ["cc", "cc_traveltime_misfit", "cross_correlation"]:
adj_src_type = "cc_traveltime_misfit"
elif choice in ["mt", "mtm", "multitaper_misfit", "multitaper"]:
adj_src_type = "multitaper_misfit"
elif choice in ["wav", "wave", "waveform", "w"]:
adj_src_type = "waveform"
else:
raise ValueError(f"'{choice}' does not match available adjoint source "
f"types, must be 'cc', 'mt', or 'wav'")
return adj_src_type