Skip to content

Commit 242af33

Browse files
committed
Added an option to normalize traces
1 parent 26ca96f commit 242af33

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

seismic/receiver_fn/rf_3dmigrate.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929
@click.option('--relax-sanity-checks', is_flag=True, default=False, show_default=True,
3030
help='RF traces with amplitudes > 1.0 or troughs around onset time are dropped by default. '
3131
'This option allows RF traces with amplitudes > 1.0 to pass through')
32+
@click.option('--normalize', is_flag=True, default=False, show_default=True,
33+
help='Normalizes each trace by its maximum absolute value')
3234
@click.option('--dz', type=float, default=0.1, show_default=True,
3335
help='Depth-step (km)')
3436
@click.option('--max-depth', type=click.FloatRange(0, 750), default=150, show_default=True,
@@ -51,7 +53,7 @@
5153
default=100, show_default=True,
5254
help='Maximum depth (km) up to which velocities from the ANT model are to be extracted. '
5355
'Has no impact if --ant-model is not speficied.')
54-
def main(rf_h5_file, output_h5_file, relax_sanity_checks, dz, max_depth, fmin, fmax,
56+
def main(rf_h5_file, output_h5_file, relax_sanity_checks, normalize, dz, max_depth, fmin, fmax,
5557
min_slope_ratio, ant_model, ant_model_max_depth):
5658
"""Perform 3D migration of RFs
5759
RF_H5_FILE : Path to RFs in H5 format
@@ -71,7 +73,8 @@ def main(rf_h5_file, output_h5_file, relax_sanity_checks, dz, max_depth, fmin, f
7173
m = Migrator(rf_filename=rf_h5_file, dz=dz, max_depth=max_depth,
7274
min_slope_ratio=min_slope_ratio, ant_model=am,
7375
logger=log)
74-
m.process_streams(output_h5_file, relax_sanity_checks=relax_sanity_checks, fmin=fmin, fmax=fmax)
76+
m.process_streams(output_h5_file, relax_sanity_checks=relax_sanity_checks,
77+
normalize=normalize, fmin=fmin, fmax=fmax)
7578
# end
7679

7780
if __name__ == "__main__":

seismic/receiver_fn/rf_ccp_util.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ def __init__(self, rf_filename, dz, max_depth, min_slope_ratio=-1,
209209
# end func
210210

211211
def process_streams(self, output_file, relax_sanity_checks=False,
212-
fmin=None, fmax=None, model='iasp91'):
212+
normalize=False, fmin=None, fmax=None, model='iasp91'):
213213
proc_hkeys = None
214214
if(self._rank == 0):
215215
hkeys = get_obspyh5_index(self._rf_filename, seeds_only=True)
@@ -279,6 +279,14 @@ def process_streams(self, output_file, relax_sanity_checks=False,
279279
continue
280280
# end if
281281

282+
# normalize traces
283+
if(normalize):
284+
for tr in p_traces:
285+
max_val = np.max(np.fabs(tr.data))
286+
if(max_val > 0): tr.data /= max_val
287+
# end for
288+
# end if
289+
282290
has_reverberations = rf_corrections.has_reverberations(p_traces)
283291
if(has_reverberations):
284292
if (self._logger):

0 commit comments

Comments
 (0)