def save_model(h, vs, vpvs=1.73, outfile=None): """Save input model as ASCII file.""" h = np.array(h) vs = np.array(vs) vp = vs * vpvs rho = vp * 0.32 + 0.77 if outfile is None: outfile = 'syn_mod.dat' x = np.arange(10) target = Targets.PReceiverFunction(x=x, y=None) target.moddata.plugin.write_startmodel(h, vp, vs, rho, outfile) logger.info('Model file saved: %s' % outfile)
def return_rfdata(h, vs, vpvs=1.73, pars=dict(), x=None): """Return dictionary of forward modeled data based on RFMini. - x must be linspace to provide an equal sampling rate - pars is a dictionary of additional parameters used for RF computation (uses defaults if empty), such as: - gauss: Gaussian factor (low pass filter), - water: water level, - p: slowness in s/deg - nsv: near surface velocity (km/s) for RF rotation angle. """ if x is None: x = np.linspace(-5, 35, 201) h = np.array(h) vs = np.array(vs) gauss = pars.get('gauss', 1.0) water = pars.get('water', 0.001) p = pars.get('p', 6.4) nsv = pars.get('nsv', None) target5 = Targets.PReceiverFunction(x=x, y=None) target5.moddata.plugin.set_modelparams(gauss=gauss, water=water, p=p, nsv=nsv) target6 = Targets.SReceiverFunction(x=x, y=None) target6.moddata.plugin.set_modelparams(gauss=gauss, water=water, p=p, nsv=nsv) vp = vs * vpvs rho = vp * 0.32 + 0.77 targets = [target5, target6] data = {} for i, target in enumerate(targets): xmod, ymod = target.moddata.plugin.run_model(h=h, vp=vp, vs=vs, rho=rho) data[target.ref] = np.array([xmod, ymod]) logger.info('Compute RF with gauss: %.2f, waterlevel: ' % gauss + '%.4f, slowness: %.2f' % (water, p)) return data
'noise': truenoise, 'explike': explike, } print truenoise, explike # # ----------------------------------------------------------- DEFINE TARGETS # # Only pass x and y observed data to the Targets object which is matching # the data type. You can chose for SWD any combination of Rayleigh, Love, group # and phase velocity. Default is the fundamendal mode, but this can be updated. # For RF chose P or S. You can also use user defined targets or replace the # forward modeling plugin wih your own module. target1 = Targets.RayleighDispersionPhase(xsw, ysw) target2 = Targets.PReceiverFunction(xrf, yrf) target2.moddata.plugin.set_modelparams(gauss=1., water=0.01, p=6.4) # Join the targets. targets must be a list instance with all targets # you want to use for MCMC Bayesian inversion. targets = Targets.JointTarget(targets=[target1, target2]) # # --------------------------------------------------- Quick parameter update # # "priors" and "initparams" from config.ini are python dictionaries. You could # also simply define the dictionaries directly in the script, if you don't want # to use a config.ini file. Or update the dictionaries as follows, e.g. if you # have station specific values, etc. # See docs/bayhunter.pdf for explanation of parameters