# http://pyrocko.org - GPLv3 # # The Pyrocko Developers, 21st Century # ---|P------/S----------~Lg----------
# how to call the programs 'qseis.2006': 'fomosto_qseis2006', 'qseis.2006a': 'fomosto_qseis2006a', }
if not cs: return '\n#'
return '\n'+' '.join('(%e,%e)' % (c.real, c.imag) for c in cs)
'%(mne)15e %(med)15e %(mnd)15e ' % self.__dict__
return '2 %(m_iso)15e %(m_clvd)15e %(m_dc)15e ' \ '%(strike)15e %(dip)15e %(rake)15e ' % self.__dict__
return '%(min_depth)15e %(max_depth)15e ' \ '%(filtered_phase)i' % self.__dict__
if version == '2006a': return '(%e,%e)\n%i%s\n%i%s' % ( self.constant.real, self.constant.imag, len(self.zeros), scl(self.zeros), len(self.poles), scl(self.poles)) elif version == '2006': return '%e\n%i%s\n%i%s' % ( abs(self.constant), len(self.zeros), scl(self.zeros), len(self.poles), scl(self.poles))
Timing('-10'), Timing('+890')))
optional=True, default=QSeisSourceMechMT.D())
def example(): conf = QSeisConfigFull() conf.receiver_distances = [2000.] conf.receiver_azimuths = [0.] conf.time_start = -10.0 conf.time_reduction_velocity = 15.0 conf.earthmodel_1d = cake.load_model().extract(depth_max='cmb') conf.earthmodel_receiver_1d = None conf.sw_flat_earth_transform = 1 return conf
for c in qseis_components]
return [pjoin(rundir, fn+'.t'+c) for fn in self.gf_filenames for c in qseis_components]
[''] + [x.string_for_config() for x in xx])
# fixing these switches here to reduce the amount of wrapper code
self.earthmodel_receiver_1d) else:
aggregate(self.propagation_filters)
d['str_w_samples'] = '\n' \ + '%i\n' % len(self.user_wavelet_samples) \ + str_float_vals(self.user_wavelet_samples) else:
d['str_receiver_filter'] = self.receiver_filter.string_for_config( self.qseis_version) else: else: d['str_receiver_filter'] = '1.0\n0\n#\n0'
self.source_mech.string_for_config(), self.seismogram_filename) else: d['str_source'] = '0'
# # This is the input file of FORTRAN77 program "qseis06" for calculation of # synthetic seismograms based on a layered halfspace earth model. # # by # Rongjiang Wang <wang@gfz-potsdam.de> # GeoForschungsZentrum Potsdam # Telegrafenberg, D-14473 Potsdam, Germany # # Last modified: Potsdam, Nov., 2006 # # = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = # If not specified, SI Unit System is used overall! # # Coordinate systems: # cylindrical (z,r,t) with z = downward, # r = from source outward, # t = azmuth angle from north to east; # cartesian (x,y,z) with x = north, # y = east, # z = downward; # = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = # # SOURCE PARAMETERS # ================= # 1. source depth [km] #------------------------------------------------------------------------------ %(source_depth)e |dble: source_depth; #------------------------------------------------------------------------------ # # RECEIVER PARAMETERS # =================== # 1. receiver depth [km] # 2. switch for distance sampling role (1/0 = equidistant/irregular); switch # for unit used (1/0 = km/deg) # 3. number of distance samples # 4. if equidistant, then start and end trace distance (> 0); else distance # list (please order the receiver distances from small to large) # 5. (reduced) time begin [sec] & length of time window [sec], number of time # samples (<= 2*nfmax in qsglobal.h) # 6. switch for unit of the following time reduction parameter: 1 = velocity # [km/sec], 0 = slowness [sec/deg]; time reduction parameter #------------------------------------------------------------------------------ %(receiver_depth)e |dble: receiver_depth; %(sw_equidistant)i %(sw_distance_unit)i |int: sw_equidistant, sw_d_unit; %(n_distances)i |int: no_distances; %(str_distances)s |dble: d_1,d_n; or d_1,d_2, ...(no comments in between!); %(time_start)e %(time_window)e %(nsamples)i |dble: t_start,t_window; int: no_t_samples; %(sw_t_reduce)i %(time_reduction_velocity)e |int: sw_t_reduce; dble: t_reduce; #------------------------------------------------------------------------------ # # WAVENUMBER INTEGRATION PARAMETERS # ================================= # 1. select slowness integration algorithm (0 = suggested for full wave-field # modelling; 1 or 2 = suggested when using a slowness window with narrow # taper range - a technique for suppressing space-domain aliasing); # 2. 4 parameters for low and high slowness (Note 1) cut-offs [s/km] with # tapering: 0 < slw1 < slw2 defining cosine taper at the lower end, and 0 < # slw3 < slw4 defining the cosine taper at the higher end. default values # will be used in case of inconsistent input of the cut-offs (possibly with # much more computational effort); # 3. parameter for sampling rate of the wavenumber integration (1 = sampled # with the spatial Nyquist frequency, 2 = sampled with twice higher than # the Nyquist, and so on: the larger this parameter, the smaller the space- # domain aliasing effect, but also the more computation effort); # 4. the factor for suppressing time domain aliasing (> 0 and <= 1) (Note 2). #------------------------------------------------------------------------------ %(sw_algorithm)i |int: sw_algorithm; %(str_slowness_window)s |dble: slw(1-4); %(wavenumber_sampling)e |dble: sample_rate; %(aliasing_suppression_factor)e |dble: supp_factor; #------------------------------------------------------------------------------ # # OPTIONS FOR PARTIAL SOLUTIONS # (only applied to the source-site structure) # =========================================== # # 1. switch for filtering free surface effects (0 = with free surface, i.e., # do not select this filter; 1 = without free surface; 2 = without free # surface but with correction on amplitude and wave form. Note switch 2 # can only be used for receivers at the surface) # 2. switch for filtering waves with a shallow penetration depth (concerning # their whole trace from source to receiver), penetration depth limit [km] # # if this option is selected, waves whose travel path never exceeds the # given depth limit will be filtered ("seismic nuting"). the condition for # selecting this filter is that the given shallow path depth limit should # be larger than both source and receiver depth. # # 3. number of depth ranges where the following selected up/down-sp2oing P or # SV waves should be filtered # 4. the 1. depth range: upper and lower depth [km], switch for filtering P # or SV wave in this depth range: # # switch no: 1 2 3 4 other # filtered phase: P(up) P(down) SV(up) SV(down) Error # # 5. the 2. ... # # The partial solution options are useful tools to increase the numerical # significance of desired wave phases. Especially when the desired phases # are smaller than the undesired phases, these options should be selected # and carefully combined. #------------------------------------------------------------------------------ %(filter_surface_effects)i |int: isurf; %(filter_shallow_paths)i %(filter_shallow_paths_depth)e |int: sw_path_filter; dble:shallow_depth_limit; %(n_depth_ranges)i %(str_depth_ranges)s #------------------------------------------------------------------------------ # # SOURCE TIME FUNCTION (WAVELET) PARAMETERS (Note 3) # ================================================== # 1. wavelet duration [unit = time sample rather than sec!], that is about # equal to the half-amplitude cut-off period of the wavelet (> 0. if <= 0, # then default value = 2 time samples will be used), and switch for the # wavelet form (0 = user's own wavelet; 1 = default wavelet: normalized # square half-sinusoid for simulating a physical delta impulse; 2 = tapered # Heaviside wavelet, i.e. integral of wavelet 1) # 2. IF user's own wavelet is selected, then number of the wavelet time samples # (<= 1024), and followed by # 3. equidistant wavelet time samples # 4 ...(continue) (! no comment lines allowed between the time sample list!) # IF default, delete line 2, 3, 4 ... or comment them out! #------------------------------------------------------------------------------ %(wavelet_duration_samples)e %(wavelet_type)i%(str_w_samples)s #------------------------------------------------------------------------------ # # FILTER PARAMETERS OF RECEIVERS (SEISMOMETERS OR HYDROPHONES) # ============================================================ # 1. constant coefficient (normalization factor) # 2. number of roots (<= nrootmax in qsglobal.h) # 3. list of the root positions in the complex format (Re,Im). If no roots, # comment out this line # 4. number of poles (<= npolemax in qsglobal.h) # 5. list of the pole positions in the complex format (Re,Im). If no poles, # comment out this line #------------------------------------------------------------------------------ %(str_receiver_filter)s #------------------------------------------------------------------------------ # # OUTPUT FILES FOR GREEN'S FUNCTIONS (Note 4) # =========================================== # 1. selections of source types (yes/no = 1/0) # 2. file names of Green's functions (please give the names without extensions, # which will be appended by the program automatically: *.tz, *.tr, *.tt # and *.tv are for the vertical, radial, tangential, and volume change (for # hydrophones) components, respectively) #------------------------------------------------------------------------------ # explosion strike-slip dip-slip clvd single_f_v single_f_h #------------------------------------------------------------------------------ %(str_gf_sw_source_types)s %(str_gf_filenames)s #------------------------------------------------------------------------------ # OUTPUT FILES FOR AN ARBITRARY POINT DISLOCATION SOURCE # (for applications to earthquakes) # ====================================================== # 1. selection (0 = not selected; 1 or 2 = selected), if (selection = 1), then # the 6 moment tensor elements [N*m]: Mxx, Myy, Mzz, Mxy, Myz, Mzx (x is # northward, y is eastward and z is downard); else if (selection = 2), then # Mis [N*m] = isotropic moment part = (MT+MN+MP)/3, Mcl = CLVD moment part # = (2/3)(MT+MP-2*MN), Mdc = double-couple moment part = MT-MN, Strike [deg], # Dip [deg] and Rake [deg]. # # Note: to use this option, the Green's functions above should be computed # (selection = 1) if they do not exist already. # # north(x) # / # /\ strike # *-----------------------> east(y) # |\ \ # |-\ \ # | \ fault plane \ # |90 \ \ # |-dip\ \ # | \ \ # | \ \ # downward(z) \-----------------------\\ # # 2. switch for azimuth distribution of the stations (0 = uniform azimuth, # else = irregular azimuth angles) # 3. list of the azimuth angles [deg] for all stations given above (if the # uniform azimuth is selected, then only one azimuth angle is required) # #------------------------------------------------------------------------------ # Mis Mcl Mdc Strike Dip Rake File #------------------------------------------------------------------------------ # 2 0.00 1.00 6.0E+19 120.0 30.0 25.0 'seis' #------------------------------------------------------------------------------ # Mxx Myy Mzz Mxy Myz Mzx File #------------------------------------------------------------------------------ %(str_source)s %(sw_irregular_azimuths)i %(str_azimuths)s #------------------------------------------------------------------------------ # # GLOBAL MODEL PARAMETERS (Note 5) # ================================ # 1. switch for flat-earth-transform # 2. gradient resolution [%%] of vp, vs, and ro (density), if <= 0, then default # values (depending on wave length at cut-off frequency) will be used #------------------------------------------------------------------------------ %(sw_flat_earth_transform)i |int: sw_flat_earth_transform; %(gradient_resolution_vp)e %(gradient_resolution_vs)e %(gradient_resolution_density)e |dble: vp_res, vs_res, ro_res; #------------------------------------------------------------------------------ # # LAYERED EARTH MODEL # (SHALLOW SOURCE + UNIFORM DEEP SOURCE/RECEIVER STRUCTURE) # ========================================================= # 1. number of data lines of the layered model (source site) #------------------------------------------------------------------------------ %(n_model_lines)i |int: no_model_lines; #------------------------------------------------------------------------------ # # MULTILAYERED MODEL PARAMETERS (source site) # =========================================== # no depth[km] vp[km/s] vs[km/s] ro[g/cm^3] qp qs #------------------------------------------------------------------------------ %(model_lines)s #------------------------------------------------------------------------------ # # LAYERED EARTH MODEL # (ONLY THE SHALLOW RECEIVER STRUCTURE) # ===================================== # 1. number of data lines of the layered model # # Note: if the number = 0, then the receiver site is the same as the # source site, else different receiver-site structure is considered. # please be sure that the lowest interface of the receiver-site # structure given given below can be found within the source-site # structure, too. # #------------------------------------------------------------------------------ %(n_model_receiver_lines)i |int: no_model_lines; #------------------------------------------------------------------------------ # # MULTILAYERED MODEL PARAMETERS (shallow receiver-site structure) # =============================================================== # no depth[km] vp[km/s] vs[km/s] ro[g/cm^3] qp qs #------------------------------------------------------------------------------ %(model_receiver_lines)s #---------------------------------end of all inputs----------------------------
Note 1:
The slowness is defined by inverse value of apparent wave velocity = sin(i)/v with i = incident angle and v = true wave velocity.
Note 2:
The suppression of the time domain aliasing is achieved by using the complex frequency technique. The suppression factor should be a value between 0 and 1. If this factor is set to 0.1, for example, the aliasing phase at the reduced time begin is suppressed to 10%%.
Note 3:
The default basic wavelet function (option 1) is (2/tau)*sin^2(pi*t/tau), for 0 < t < tau, simulating physical delta impuls. Its half-amplitude cut-off frequency is 1/tau. To avoid high-frequency noise, tau should not be smaller than 4-5 time samples.
Note 4:
Double-Couple m11/ m22/ m33/ m12/ m23/ m31 Azimuth_Factor_(tz,tr,tv)/(tt) ============================================================================ explosion 1.0/ 1.0/ 1.0/ -- / -- / -- 1.0 / 0.0 strike-slip -- / -- / -- / 1.0/ -- / -- sin(2*azi) / cos(2*azi) 1.0/-1.0/ -- / -- / -- / -- cos(2*azi) / -sin(2*azi) dip-slip -- / -- / -- / -- / -- / 1.0 cos(azi) / sin(azi) -- / -- / -- / -- / 1.0/ -- sin(azi) / -cos(azi) clvd -0.5/-0.5/ 1.0/ -- / -- / -- 1.0 / 0.0 ============================================================================ Single-Force fx / fy / fz Azimuth_Factor_(tz,tr,tv)/(tt) ============================================================================ fz -- / -- / 1.0 1.0 / 0.0 fx 1.0/ -- / -- cos(azi) / sin(azi) fy -- / 1.0/ -- sin(azi) / -cos(azi) ============================================================================
Note 5:
Layers with a constant gradient will be discretized with a number of homogeneous sublayers. The gradient resolutions are then used to determine the maximum allowed thickness of the sublayers. If the resolutions of Vp, Vs and Rho (density) require different thicknesses, the smallest is first chosen. If this is even smaller than 1%% of the characteristic wavelength, then the latter is taken finally for the sublayer thickness. ''' # noqa
def __str__(self): return 'Interrupted.'
'%s===== end qseis input =====' % input_str.decode())
os.kill(proc.pid, signal.SIGTERM) interrupted.append(True)
except OSError: os.chdir(old_wd) raise QSeisError( '''could not start qseis executable: "%s" Available fomosto backends and download links to the modelling codes are listed on
https://pyrocko.org/docs/current/apps/fomosto/backends.html
''' % program)
finally:
raise KeyboardInterrupt()
'%s===== end qseis output =====' % output_str.decode())
errmess.append( 'qseis had a non-zero exit state: %i' % proc.returncode)
logger.warn( 'qseis emitted something via stderr:\n\n%s' % error_str.decode())
# errmess.append('qseis emitted something via stderr')
errmess.append("the string 'error' appeared in qseis output")
self.keep_tmp = True
os.chdir(old_wd) raise QSeisError(''' ===== begin qseis input ===== %s===== end qseis input ===== ===== begin qseis output ===== %s===== end qseis output ===== ===== begin qseis error ===== %s===== end qseis error ===== %s qseis has been invoked as "%s" in the directory %s'''.lstrip() % ( input_str.decode(), output_str.decode(), error_str.decode(), '\n'.join(errmess), program, self.tempdir))
elif which == 'gf': fns = self.config.get_output_filenames_gf(self.tempdir) components = [ fn+'.t'+c for fn in self.config.gf_filenames for c in qseis_components] else: raise Exception( 'get_traces: which argument should be "seis" or "gf"')
continue
range(ntraces), distances, azimuths):
'', '%04i' % itrace, '', comp, tmin=tmin, deltat=deltat, ydata=data[:, itrace+1], meta=dict( distance=distance*km, azimuth=azimuth))
else: logger.warn( 'not removing temporary directory: %s' % self.tempdir)
force=False):
self, self.store.config, step, block_size=block_size, force=force)
conf.time_region[0], conf.time_region[1], force=force)
util.ensuredir(self.tmp)
self.get_block_extents(index)
else: (rz, sz, firstx), (rz, sz, lastx), (nr, ns, nx) = \ self.get_block_extents(index)
(index+1, self.nblocks))
# add global max distance, because qseis does some adjustments with # this value distances.append(self.gf_config.distance_max)
{'r': (0, +1), 'z': (1, +1)})
{'r': (0, +1), 't': (3, +1), 'z': (5, +1)}) {'r': (1, +1), 't': (4, +1), 'z': (6, +1)}) {'r': (2, +1), 'z': (7, +1)}) {'r': (8, +1), 'z': (9, +1)})
off = 8
'fz.tr': (off+0, +1), 'fh.tr': (off+1, +1), 'fh.tt': (off+2, -1), 'fz.tz': (off+3, +1), 'fh.tz': (off+4, +1)}) gfsneeded = (1, 0, 0, 0, 0, 0) gfmapping = [mex]
gfsneeded = (0, 0, 0, 0, 1, 1) gfmapping = [msf]
gfsneeded = (1, 1, 1, 1, 0, 0) gfmapping = [mmt1, mmt2, mmt3]
elif component_scheme == 'elastic13': gfsneeded = (1, 1, 1, 1, 1, 1) gfmapping = [mmt1, mmt2, mmt3, msf]
elif component_scheme == 'elastic15': gfsneeded = (1, 1, 1, 1, 1, 1) gfmapping = [mmt1, mmt2, mmt3, mmt4, msf]
mnn=f(m[0, 0]), mee=f(m[1, 1]), mdd=f(m[2, 2]), mne=f(m[0, 1]), mnd=f(m[0, 2]), med=f(m[1, 2])) else: conf.source_mech = None
else: rawtraces = runner.get_traces('gf')
interrupted.append(True)
continue
else: args = (rz, sz, x, ig)
self.warn( 'Failed cutting {} traces. ' + 'Failed to determine time window') continue
self.store.t(v, args[:-1]) for v in conf.fade]
continue
raise QSeisError( 'invalid fade configuration ' '(it should be (ta <= tb <= tc <= td) but ' 'ta=%g, tb=%g, tc=%g, td=%g)' % ( ta, tb, tc, td))
else: yin = 0.0
else: yout = 0.0
except gf.store.DuplicateInsert: self.warn('{} insertions_skipped (duplicates)')
finally:
raise KeyboardInterrupt()
(index+1, self.nblocks))
variant = '2006'
raise gf.store.StoreError('unsupported variant: %s' % variant)
gf.meta.Timing('begin-50'), gf.meta.Timing('end+100'))
gf.meta.Timing('begin-50'), gf.meta.Timing('end+100'))
id=store_id, ncomponents=10, sample_rate=0.2, receiver_depth=0*km, source_depth_min=10*km, source_depth_max=20*km, source_depth_delta=10*km, distance_min=100*km, distance_max=1000*km, distance_delta=10*km, earthmodel_1d=cake.load_model().extract(depth_max='cmb'), modelling_code_id=modelling_code_id, tabulated_phases=[ gf.meta.TPDef( id='begin', definition='p,P,p\\,P\\,Pv_(cmb)p'), gf.meta.TPDef( id='end', definition='2.5'), gf.meta.TPDef( id='P', definition='!P'), gf.meta.TPDef( id='S', definition='!S'), gf.meta.TPDef( id='p', definition='!p'), gf.meta.TPDef( id='s', definition='!s')])
store_dir, config=config, extra={'qseis': qseis})
iblock=None):
store_dir, force=force, nworkers=nworkers, continue_=continue_, step=step, iblock=iblock) |