提交 7a4990bc 编辑于 作者: Mijian Xu's avatar Mijian Xu 😷
浏览文件

Add slant stack in RFStation

上级 95480455
......@@ -7,6 +7,7 @@ from seispy.geo import skm2srad, sdeg2skm, rad2deg, latlon_from, \
asind, tand, srad2skm, km2deg
from seispy.psrayp import get_psrayp
from seispy.rfani import RFAni
from seispy.slantstack import SlantStack
import matplotlib.pyplot as plt
import warnings
import glob
......@@ -152,6 +153,11 @@ class SACStation(object):
best_f, best_t = self.ani.joint_ani(weight=weight)
return best_f, best_t
def slantstack(self, ref_dis=None, rayp_range=None, tau_range=None):
self.slant = SlantStack(self.datar, self.time_axis, self.dis)
self.slant.stack(ref_dis, rayp_range, tau_range)
return self.slant.stack_amp
class RFStation(SACStation):
def __init__(self, data_path, only_r=False):
......@@ -159,7 +165,7 @@ class RFStation(SACStation):
:param data_path: Path to RF data with SAC format. A finallist.dat must be in this path.
:type data_path: str
:param only_r: [description], defaults to False
:param only_r: Wether only read R component, defaults to False
:type only_r: bool, optional
"""
super().__init__(data_path, only_r=only_r)
......
import numpy as np
from scipy.interpolate import interp1d
import matplotlib.pyplot as plt
from os.path import join
class SlantStack():
def __init__(self, seis, timeaxis, dis) -> None:
......@@ -44,11 +43,22 @@ class SlantStack():
tmp[i, :] = interp1d(self.time_axis, self.datar[i, :], fill_value='extrapolate')(tps)
self.stack_amp[j, :] = np.mean(tmp, axis=0)
def plot(self, cmap='jet', xlim=None, figpath=None):
maxamp = np.max(np.abs(self.stack_amp))
def plot(self, cmap='jet', xlim=None, vmin=None, vmax=None, figpath=None):
self.fig = plt.figure()
self.ax = self.fig.add_subplot()
cs = self.ax.pcolor(self.tau_range, self.rayp_range, self.stack_amp, vmax=maxamp, vmin=-maxamp, cmap=cmap)
if vmin is None and vmax is None:
vmax = np.max(np.abs(self.stack_amp))
vmin = -vmax
elif vmin is None and isinstance(vmax, (int, float)):
vmin = np.min(self.stack_amp)
elif vmax is None and isinstance(vmin, (int, float)):
vmax = np.max(self.stack_amp)
elif isinstance(vmax, (int, float)) and isinstance(vmin, (int, float)):
pass
else:
raise TypeError('vmin and vmax must be in int or in float type')
cs = self.ax.pcolor(self.tau_range, self.rayp_range, self.stack_amp,
vmax=vmax, vmin=vmin, cmap=cmap)
self.ax.colorbar(cs)
if xlim is not None and isinstance(xlim, (list, np.ndarray)):
self.ax.set_xlim(xlim)
......
支持 Markdown
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册