def show(self, ax, **kwargs): I = np.zeros(len(self.f)) for i in xrange(len(self.f)): I[i] = discrete_time_primitive(self.v, self.H[:, i], area = True) I = discrete_time_primitive(self.f, I, area = True) H = np.ma.masked_where(self.H == 0., self.H) ax.pcolormesh1(1. / self.f, self.v, H / I, **kwargs) ax.set_xscale('log') ax.set_yscale('log')
def show(self, ax, **kwargs): I = np.zeros(len(self.z)) for i in xrange(len(self.z)): I[i] = discrete_time_primitive(self.v, self.H[i, :], area=True) I = discrete_time_primitive(self.z, I, area=True) H = np.ma.masked_where(self.H == 0., self.H) v_ = np.concatenate((self.v, [self.v[-1] + self.v[-1] - self.v[-2]])) z_ = np.concatenate((self.z, [self.z[-1] + self.z[-1] - self.z[-2]])) ax.pcolormesh1(v_, z_, H / I, **kwargs) if not ax.yaxis_inverted(): ax.invert_yaxis()
def U2C(nu, u, nuo, co): """signaltools.U2C : convert group to phase velocity. Knowledge of the phase dispersion curve is needed at a given frequency nuo. nuo must appear into frequency array nu. nuo must be as low as possible. input : nu = numpy.ndarray, frequency array (positive) of the group dispersion curve (Hz) u = numpy.ndarray, group dispersion curve (km/s) nuo = float, reference frequency (Hz) co = float, reference phase velocity (km/s) output : nu_ = numpy.ndarray, frequency array of the phase dispersion curve (Hz) c = numpy.ndarray, phase dispersion curve (km/s) """ Is = nu.argsort() nus, us = nu[Is], u[Is] if nuo < nu.min() or nuo > nu.max(): raise ValueError('reference frequency nuo (%f Hz) must be between %f Hz and %f Hz' % (nuo, nu.min(), nu.max())) nu_ = nus su = discrete_time_primitive(nus, 1. / us, area=False) if abs(nu_ - nuo).min() > 0.: # need to intepolate su at point nuo suo = np.interp(x=nuo, xp=nu_, fp=su) else: suo = su[abs(nu_ - nuo).argmin()] c = co * np.ones(len(nu_)) Iok = nu_ != nuo c[Iok] = nu_[Iok] / (nuo / co + (su[Iok] - suo)) return nu_, c
def interp(self, z, interpmethod=None): """ :param z: depth at which to interpolate the model :param interpmethod: method "stairs" means simply reading the "staired" model at input depths z method "weightedstairs" means creating a new model that preserves the average values use it to resample a depthmodel without loosing its average shape :return: values of the depthmodel at required depth z """ if interpmethod is None: #no user specification, use the default interpolation method interpmethod = self.interpmethod if interpmethod == "stairs": Z, V = self.stairs() return np.interp(xp=Z, fp=V, x=z, left=V[0], right=V[-1]) elif interpmethod == "weightedstairs": # determine the stairs shape of the model Z, V = self.stairs() Z[-1] = 10. * Z[-2] # compute model integral U = discrete_time_primitive(Z, V) + V[0] u = np.interp(xp=Z, fp=U, x=z, left=U[0], right=U[-1]) # derivate the integral at required location newv = np.concatenate( ((u[1:] - u[:-1]) / (z[1:] - z[:-1]), [V[-1]])) return newv else: raise ValueError('interpmethod %s not valid for %s' % (interpmethod, type(self)))