def instantaneous_phase2(syn, obs, nt, dt, eps=0., *args, **kwargs): """ Alterative instantaneous phase function :type syn: np.array :param syn: synthetic data array :type obs: np.array :param obs: observed data array :type nt: int :param nt: number of time steps in the data array :type dt: float :param dt: time step in sec """ esyn = abs(analytic(syn)) eobs = abs(analytic(obs)) esyn1 = esyn + eps * max(esyn) eobs1 = eobs + eps * max(eobs) esyn3 = esyn**3 + eps * max(esyn**3) diff1 = (syn / esyn1) - (obs / eobs1) diff2 = (hilbert(syn) / esyn1) - (hilbert(obs) / eobs1) part1 = diff1 * hilbert(syn)**2 / esyn3 part2 = diff2 * syn * hilbert(syn) / esyn3 part3 = diff1 * syn * hilbert(syn) / esyn3 - diff2 * syn**2 / esyn3 wadj = part1 - part2 + hilbert(part3) return wadj
def envelope3(syn, obs, nt, dt, eps=0., *args, **kwargs): """ Envelope cross-correlation lag from Yuan et al. 2015, Eq. B-4 :type syn: np.array :param syn: synthetic data array :type obs: np.array :param obs: observed data array :type nt: int :param nt: number of time steps in the data array :type dt: float :param dt: time step in sec """ env_syn = abs(analytic(syn)) env_obs = abs(analytic(obs)) return Traveltime(env_syn, env_obs, nt, dt)
def envelope2(syn, obs, nt, dt, *args, **kwargs): """ Envelope amplitude ratio from Yuan et al. 2015 Eq. B-1 :type syn: np.array :param syn: synthetic data array :type obs: np.array :param obs: observed data array :type nt: int :param nt: number of time steps in the data array :type dt: float :param dt: time step in sec """ env_syn = abs(analytic(syn)) env_obs = abs(analytic(obs)) raise NotImplementedError
def instantaneous_phase(syn, obs, nt, dt, eps=0.05, *args, **kwargs): """ Instantaneous phase difference from Bozdag et al. 2011 Eq. 27 :type syn: np.array :param syn: synthetic data array :type obs: np.array :param obs: observed data array :type nt: int :param nt: number of time steps in the data array :type dt: float :param dt: time step in sec """ r = np.real(analytic(syn)) i = np.imag(analytic(syn)) phi_syn = np.arctan2(i, r) r = np.real(analytic(obs)) i = np.imag(analytic(obs)) phi_obs = np.arctan2(i, r) phi_rsd = phi_syn - phi_obs env_syn = abs(analytic(syn)) env_max = max(env_syn**2.) wadj_1 = phi_rsd * np.imag(analytic(syn)) / (env_syn**2. + eps * env_max) wadj_2 = np.imag(analytic(phi_rsd * syn / (env_syn**2. + eps * env_max))) wadj = wadj_1 + wadj_2 return wadj
def envelope(syn, obs, nt, dt, *args, **kwargs): """ Waveform envelope difference from Yuan et al. 2015 Eq. 9 :type syn: np.array :param syn: synthetic data array :type obs: np.array :param obs: observed data array :type nt: int :param nt: number of time steps in the data array :type dt: float :param dt: time step in sec """ env_syn = abs(analytic(syn)) env_obs = abs(analytic(obs)) # Residual of envelopes env_rsd = env_syn - env_obs return np.sqrt(np.sum(env_rsd * env_rsd * dt))
def envelope(syn, obs, nt, dt, eps=0.05, *args, **kwargs): """ Waveform envelope difference from Yuan et al. 2015 Eq. 16 :type syn: np.array :param syn: synthetic data array :type obs: np.array :param obs: observed data array :type nt: int :param nt: number of time steps in the data array :type dt: float :param dt: time step in sec """ env_syn = abs(analytic(syn)) env_obs = abs(analytic(obs)) env_tmp = (env_syn - env_obs) / (env_syn + eps * env_syn.max()) wadj = env_tmp * syn - np.imag(analytic(env_tmp * np.imag(analytic(syn)))) return wadj
def hilbert(w): """ Take the Hilbert transform of some function to get the analytic signal TODO Change the naming here, it seems confusing to rename a scipy function TODO and then overwrite its name with this function. :type w: np.array :param w: signal data, must be real :rtype: float :return: imaginary part of the analytic signal """ return np.imag(analytic(w))
def instantaneous_phase2(syn, obs, nt, dt, eps=0., *args, **kwargs): """ Alterative instantaneous phase function :type syn: np.array :param syn: synthetic data array :type obs: np.array :param obs: observed data array :type nt: int :param nt: number of time steps in the data array :type dt: float :param dt: time step in sec """ env_syn = abs(analytic(syn)) env_obs = abs(analytic(obs)) env_syn1 = env_syn + eps * max(env_syn) env_obs1 = env_obs + eps * max(env_obs) diff = (syn / env_syn1) - (obs / env_obs1) return np.sqrt(np.sum(diff * diff * dt))
def envelope3(syn, obs, nt, dt, eps=0., *args, **kwargs): """ Envelope lag from Yuan et al. 2015 Eq. B-2, B-5 :type syn: np.array :param syn: synthetic data array :type obs: np.array :param obs: observed data array :type nt: int :param nt: number of time steps in the data array :type dt: float :param dt: time step in sec """ env_syn = abs(analytic(syn)) env_obs = abs(analytic(obs)) env_rat = np.zeros(nt) env_rat[1:-1] = (env_syn[2:] - env_syn[0:-2]) / (2. * dt) env_rat[1:-1] /= env_syn[1:-1] env_rat *= misfit.envelope3(syn, obs, nt, dt) wadj = -env_rat * syn + hilbert(env_rat * hilbert(env_syn)) return wadj
def instantaneous_phase(syn, obs, nt, dt, *args, **kwargs): """ Instantaneous phase difference from Bozdag et al. 2011 :type syn: np.array :param syn: synthetic data array :type obs: np.array :param obs: observed data array :type nt: int :param nt: number of time steps in the data array :type dt: float :param dt: time step in sec """ r = np.real(analytic(syn)) i = np.imag(analytic(syn)) phi_syn = np.arctan2(i, r) r = np.real(analytic(obs)) i = np.imag(analytic(obs)) phi_obs = np.arctan2(i, r) phi_rsd = phi_syn - phi_obs return np.sqrt(np.sum(phi_rsd * phi_rsd * dt))
def hilbert(w): return np.imag(analytic(w))
def hilbert(w): return np.imag(analytic(w))