# http://pyrocko.org - GPLv3 # # The Pyrocko Developers, 21st Century # ---|P------/S----------~Lg----------
All functions defined in this module return SI units (m, m/s, kg/m^3).
.. note:: Please refer to the REM web site if you use this model:
http://igppweb.ucsd.edu/~gabi/rem.html
or
Bassin, C., Laske, G. and Masters, G., The Current Limits of Resolution for Surface Wave Tomography in North America, EOS Trans AGU, 81, F897, 2000. A description of CRUST 5.1 can be found in: Mooney, Laske and Masters, Crust 5.1: a global crustal model at 5x5 degrees, JGR, 103, 727-747, 1998.
Usage -----
::
>>> from pyrocko import crust2x2 >>> p = crust2x2.get_profile(10., 20.) >>> print p type, name: G2, Archean 0.5 km seds. elevation: 529 crustal thickness: 38500 average vp, vs, rho: 6460.7 3665.1 2867.5 mantle ave. vp, vs, rho: 8200 4700 3400
0 3810 1940 920 ice 0 1500 0 1020 water 500 2500 1200 2100 soft sed. 0 4000 2100 2400 hard sed. 12500 6200 3600 2800 upper crust 13000 6400 3600 2850 middle crust 13000 6800 3800 2950 lower crust >>> print p.get_weeded() [[ 0. 500. 500. 13000. 13000. 26000. 26000. 39000. 39000.] [ 2500. 2500. 6200. 6200. 6400. 6400. 6800. 6800. 8200.] [ 1200. 1200. 3600. 3600. 3600. 3600. 3800. 3800. 4700.] [ 2100. 2100. 2800. 2800. 2850. 2850. 2950. 2950. 3400.]]
Constants ---------
============== ============== Layer id Layer name ============== ============== LICE ice LWATER water LSOFTSED soft sediments LHARDSED hard sediments LUPPERCRUST upper crust LMIDDLECRUST middle crust LLOWERCRUST lower crust LBELOWCRUST below crust ============== ==============
Contents -------- '''
LLOWERCRUST, LBELOWCRUST = list(range(8))
'''Representation of a CRUST2.0 key profile.'''
'ice', 'water', 'soft sed.', 'hard sed.', 'upper crust', 'middle crust', 'lower crust', 'mantle')
'''Get layers used in the profile.
:param include_waterlayer: include water layer if ``True``. Default is ``False``
:returns: NumPy array with rows ``depth``, ``vp``, ``vs``, ``density`` ''' range(8), self._thickness, self._vp[:-1], self._vs[:-1], self._rho[:-1]):
continue
depth, self._vp[LBELOWCRUST], self._vs[LBELOWCRUST], self._rho[LBELOWCRUST]])
'''Get parameters for a layer.
:param ilayer: id of layer :returns: thickness, vp, vs, density '''
else:
def __str__(self):
vvp, vvs, vrho, vthi = self.averages()
return '''type, name: %s, %s elevation: %15.5g crustal thickness: %15.5g average vp, vs, rho: %15.5g %15.5g %15.5g mantle ave. vp, vs, rho: %15.5g %15.5g %15.5g
%s''' % (self._ident, self._name, self._elevation, vthi, vvp, vvs, vrho, self._vp[LBELOWCRUST], self._vs[LBELOWCRUST], self._rho[LBELOWCRUST], '\n'.join([ '%15.5g %15.5g %15.5g %15.5g %s' % x for x in zip( self._thickness, self._vp[:-1], self._vs[:-1], self._rho[:-1], Crust2Profile.layer_names)]))
'''Get total crustal thickness
Takes into account ice layer. Does not take into account water layer. '''
'''Get crustal averages for vp, vs and density and total crustal thickness,
Takes into account ice layer. Does not take into account water layer. '''
self._thickness[LICE] / self._vp[LICE] self._thickness[LICE] / self._vs[LICE] self._thickness[LICE] * self._rho[LICE]
return x - math.floor((x-mi)/(ma-mi)) * (ma-mi)
'''Access CRUST2.0 model.
:param directory: Directory with the data files which contain the CRUST2.0 model data. If this is set to ``None``, builtin CRUST2.0 files are used. '''
''' Get crustal profile at a specific location or raw profile for given key.
Get profile for location ``(lat, lon)``, or raw profile for given string key.
:rtype: instance of :py:class:`Crust2Profile` '''
else: return self._raw_profiles[args[0]]
path_keys = os.path.join(self._directory, Crust2.fn_keys) f = open(path_keys, 'r') else:
# skip header
ident.strip(), name.strip(), vp, vs, rho, thickness, 0.0)
path_map = os.path.join(self._directory, Crust2.fn_map) f = open(path_map, 'r') else:
path_elevation = os.path.join(self._directory, Crust2.fn_elevation) f = open(path_elevation, 'r')
else:
def instance(): '''Get the global default Crust2 instance.'''
'''Get list of all profile keys.'''
crust2 = Crust2.instance() return list(crust2.profile_keys)
'''Get Crust2x2 profile for given location or profile key.
Get profile for (lat,lon) or raw profile for given string key. '''
''' Create a quick and dirty plot of the crustal thicknesses defined in CRUST2.0. '''
if crust2 is None: crust2 = Crust2.instance()
def func(lat, lon): return crust2.get_profile(lat, lon).crustal_thickness(),
plot(func, filename, zscaled_unit='km', zscaled_unit_factor=0.001)
''' Create a quick and dirty plot of vp below the crust, as defined in CRUST2.0. '''
if crust2 is None: crust2 = Crust2.instance()
def func(lat, lon): return crust2.get_profile(lat, lon).get_layer(LBELOWCRUST)[1]
plot(func, filename, zscaled_unit='km/s', zscaled_unit_factor=0.001)
nlats, nlons = 91, 181 lats = num.linspace(-90., 90., nlats) lons = num.linspace(-180., 180., nlons)
vecfunc = num.vectorize(func, [float]) latss, lonss = num.meshgrid(lats, lons) thickness = vecfunc(latss, lonss)
from pyrocko.plot import gmtpy cm = gmtpy.cm marg = (1.5*cm, 2.5*cm, 1.5*cm, 1.5*cm) p = gmtpy.Simple( width=20*cm, height=10*cm, margins=marg, with_palette=True, **kwargs)
p.density_plot(gmtpy.tabledata(lons, lats, thickness.T)) p.save(filename) |