import os, pathlib
from frequency_band import FrequencyBand
from salvus import namespace as sn
SIMULATION_TIME_IN_SECONDS = 1200.0
RANKS_PER_JOB = 4
SALVUS_FLOW_SITE_NAME = os.environ.get("SITE_NAME", "local")
PROJECT_DIR = "project_dir_central_europe"
fband_file = pathlib.Path("./frequency_band_70_120.pkl")
fband = FrequencyBand.load(fband_file)
fband
FrequencyBand(min_frequency_in_hertz=0.008333333333333333, max_frequency_in_hertz=0.014285714285714285)
p = sn.Project(path=PROJECT_DIR)
p.viz.nb.domain()
SELECTED_EVENTS = [
"event_CRETE_GREECE_Mag_6.15_2015-04-16-18-07",
"event_ICELAND_REGION_Mag_5.75_2020-06-20-19-26",
"event_STRAIT_OF_GIBRALTAR_Mag_6.38_2016-01-25-04-22",
]
# Sanity check.
for event in SELECTED_EVENTS:
assert p.events.exists(event), event
wsc = sn.WaveformSimulationConfiguration(
attenuation=True, end_time_in_seconds=SIMULATION_TIME_IN_SECONDS
)
p.add_to_project(
sn.SimulationConfiguration(
tensor_order=2,
name=f"initial_model_{fband.period_band_name}",
elements_per_wavelength=1.25,
min_period_in_seconds=fband.min_period_in_seconds,
max_depth_in_meters=1750e3,
model_configuration=sn.ModelConfiguration(
background_model="prem_ani_no_crust",
),
topography_configuration=sn.TopographyConfiguration(
["surface_topography"]
),
bathymetry_configuration=sn.BathymetryConfiguration(
["ocean_bathymetry"]
),
event_configuration=sn.EventConfiguration(
wavelet=sn.simple_config.stf.FilteredHeaviside(
min_frequency_in_hertz=fband.min_frequency_in_hertz,
max_frequency_in_hertz=fband.max_frequency_in_hertz,
highpass_corners=3,
lowpass_corners=3,
end_time_in_seconds=SIMULATION_TIME_IN_SECONDS,
),
waveform_simulation_configuration=wsc,
),
absorbing_boundaries=sn.AbsorbingBoundaryParameters(
reference_velocity=3700.0,
number_of_wavelengths=0.0,
reference_frequency=fband.max_frequency_in_hertz,
),
),
overwrite=True,
)
p.viz.nb.simulation_setup(
f"initial_model_{fband.period_band_name}", events=SELECTED_EVENTS
)
[2024-11-20 13:43:47,716] INFO: Creating mesh. Hang on.
<salvus.flow.simple_config.simulation.waveform.Waveform object at 0x7d2ba1cca090>
p.simulations.launch(
f"initial_model_{fband.period_band_name}",
SELECTED_EVENTS,
site_name=SALVUS_FLOW_SITE_NAME,
ranks_per_job=RANKS_PER_JOB,
derived_job_config=sn.WavefieldCompression(
forward_wavefield_sampling_interval=10
),
)
p.simulations.query(block=True, ping_interval_in_seconds=5)
[2024-11-20 13:43:52,882] INFO: Submitting job array with 3 jobs ...
True
p.viz.nb.waveforms(
[
f"PROCESSED_DATA:{fband.period_band_name}",
f"initial_model_{fband.period_band_name}",
],
receiver_field="displacement",
)
plot
and verbose
arguments - if you have your window picking function you will have to implement your own debugging/tuning process. The function additionally returns the picked windows so further analysis would be possible.p.actions.seismology.pick_windows(
data_selection_configuration=f"initial_selection_{fband.period_band_name}",
observed_data_name=f"PROCESSED_DATA:{fband.period_band_name}",
synthetic_data_name=f"initial_model_{fband.period_band_name}",
events=SELECTED_EVENTS[1],
receiver_field="displacement",
window_taper_width_in_seconds=fband.min_period_in_seconds / 2.0,
window_picking_function="built-in",
window_picking_function_kwargs={
"minimum_period_in_seconds": fband.min_period_in_seconds,
"maximum_period_in_seconds": fband.max_period_in_seconds,
"plot": True,
"verbose": True,
},
save_results_in_project=False,
receiver_name_pattern="IU.KEV.*",
overwrite=True,
)
[Window selection for IU.KEV.00.BHZ] Correlation Coefficient: 0.8358 [Window selection for IU.KEV.00.BHZ] Absolute Noise Level: 2.817044e-08 [Window selection for IU.KEV.00.BHZ] Relative Noise Level: 6.280877e-03 [Window selection for IU.KEV.00.BHZ] Done, Selected 2 window(s)
[Window selection for IU.KEV.00.BHN] Correlation Coefficient: -0.3835 [Window selection for IU.KEV.00.BHN] Absolute Noise Level: 6.523066e-08 [Window selection for IU.KEV.00.BHN] Relative Noise Level: 5.648955e-02 [Window selection for IU.KEV.00.BHN] Correlation -0.3835 is below threshold of 0.1000
[Window selection for IU.KEV.00.BHE] Correlation Coefficient: 0.9298 [Window selection for IU.KEV.00.BHE] Absolute Noise Level: 1.469819e-07 [Window selection for IU.KEV.00.BHE] Relative Noise Level: 3.746031e-02 [Window selection for IU.KEV.00.BHE] Done, Selected 2 window(s)
[<salvus.flow.collections.event_window_and_weight_set.EventWindowAndWeightSet at 0x7d2aa9d05990>]
p.actions.seismology.pick_windows(
data_selection_configuration=f"initial_selection_{fband.period_band_name}",
observed_data_name=f"PROCESSED_DATA:{fband.period_band_name}",
synthetic_data_name=f"initial_model_{fband.period_band_name}",
events=SELECTED_EVENTS,
receiver_field="displacement",
window_taper_width_in_seconds=fband.min_period_in_seconds / 2.0,
window_picking_function="built-in",
window_picking_function_kwargs={
"minimum_period_in_seconds": fband.min_period_in_seconds,
"maximum_period_in_seconds": fband.max_period_in_seconds,
},
overwrite=True,
)
[2024-11-20 13:47:04,896] INFO: Encountered 6 issues during the window picking process. They have been logged to 'project_dir_central_europe/INTERNAL/LOGS/2024-11-20T13-47-04_actions_seismology_window_picking.log'.
[<salvus.flow.collections.event_window_and_weight_set.EventWindowAndWeightSet at 0x7d2aaa6f96d0>, <salvus.flow.collections.event_window_and_weight_set.EventWindowAndWeightSet at 0x7d2aaafdeb90>, <salvus.flow.collections.event_window_and_weight_set.EventWindowAndWeightSet at 0x7d2aaae71ed0>]
p.viz.nb.waveforms(
[
f"PROCESSED_DATA:{fband.period_band_name}",
f"initial_model_{fband.period_band_name}",
],
receiver_field="displacement",
data_selection_configuration=f"initial_selection_{fband.period_band_name}",
)
p.viz.seismology.windows(
data_selection_configuration=f"initial_selection_{fband.period_band_name}"
)
p.actions.seismology.add_receiver_weights_to_windows(
data_selection_configuration=f"initial_selection_{fband.period_band_name}",
events=SELECTED_EVENTS,
weighting_chain=[
{
"weighting_scheme": "ruan_et_al_2019",
"function_kwargs": {"ref_distance_condition_fraction": 1.0 / 3.0},
},
{
"weighting_scheme": "mute_near_source_receivers",
"function_kwargs": {
"minimum_receiver_distance_in_m": 200e3,
"maximum_receiver_mute_distance_in_m": 500e3,
"taper_type": "hanning",
},
},
],
normalize=True,
)
p.viz.seismology.receiver_weights_map(
data_selection_configuration=f"initial_selection_{fband.period_band_name}"
)
Configuration
object into project.p.add_to_project(
sn.MisfitConfiguration(
name=f"tf_phase_misfit_{fband.period_band_name}",
observed_data=f"PROCESSED_DATA:{fband.period_band_name}",
misfit_function="time_frequency_phase_misfit",
extra_kwargs_misfit_function={
# The length of each individual FFT segment.
"segment_length_in_seconds": 1.5 * fband.max_period_in_seconds,
"frequency_limits": (
fband.min_frequency_in_hertz,
fband.max_frequency_in_hertz,
),
},
receiver_field="displacement",
data_selection_configuration=f"initial_selection_{fband.period_band_name}",
)
)
p.viz.seismology.misfit_map(
reference_data=f"initial_model_{fband.period_band_name}",
misfit_configuration=f"tf_phase_misfit_{fband.period_band_name}",
)