Beispiel #1
0
class PyrockoRingfaultSource(SandboxSource, PyrockoSource):
    '''A ring fault with vertical doublecouples.

    See :class:`pyrocko.gf.seismosizer.RingfaultSource`.
    '''
    __implements__ = 'pyrocko'

    store_dir = String.T(help='Pyrocko GF Store path')
    diameter = Float.T(default=1.0, help='diameter of the ring in [m]')
    sign = Float.T(default=1.0,
                   help='inside of the ring moves up (+1) or down (-1)')
    strike = Float.T(
        default=0.0,
        help='strike direction of the ring plane, clockwise from north,'
        ' in [deg]')
    dip = Float.T(default=0.0,
                  help='dip angle of the ring plane from horizontal in [deg]')
    npointsources = Int.T(default=8, help='number of point sources to use')
    magnitude = Float.T(
        default=6.0,
        help='moment magnitude Mw as in [Hanks and Kanamori, 1979]')

    parametersUpdated = PyrockoSource.parametersUpdated

    def __init__(self, *args, **kwargs):
        SandboxSource.__init__(self, *args, **kwargs)
        PyrockoSource.__init__(self)
        self.pyrocko_source = gf.RingfaultSource(**self._src_args)

    @property
    def _src_args(self):
        return {
            'lat': 0.,
            'lon': 0.,
            'north_shift': self.northing,
            'east_shift': self.easting,
            'depth': self.depth,
            'diameter': self.diameter,
            'strike': self.strike,
            'dip': self.dip,
            'magnitude': self.magnitude,
            'npointsources': self.npointsources,
        }
Beispiel #2
0
class WaveformMisfitResult(gf.Result, MisfitResult):
    '''Carries the observations for a target and corresponding synthetics.

    A number of different waveform  or phase representations are possible.
    '''
    processed_obs = trace.Trace.T(optional=True)
    processed_syn = trace.Trace.T(optional=True)
    filtered_obs = trace.Trace.T(optional=True)
    filtered_syn = trace.Trace.T(optional=True)
    spectrum_obs = TraceSpectrum.T(optional=True)
    spectrum_syn = TraceSpectrum.T(optional=True)

    taper = trace.Taper.T(optional=True)
    tobs_shift = Float.T(optional=True)
    tsyn_pick = Timestamp.T(optional=True)
    tshift = Float.T(optional=True)
    cc = trace.Trace.T(optional=True)

    piggyback_subresults = List.T(WaveformPiggybackSubresult.T())
Beispiel #3
0
class MapParameters(Object):
    width = Float.T(help='width of map', optional=True, default=16)
    height = Float.T(help='heigth of map', optional=True, default=16)
    lat = Float.T(help='center latitude')
    lon = Float.T(help='center longitude')
    radius = Float.T(help='radius of map')
    outfn = String.T(help='output filename', optional=True, default='map.png')
    stations = List.T(model.Station.T(), optional=True)
    station_label_mapping = List.T(String.T(), optional=True)
    station_colors = Dict.T(String.T(), String.T(), optional=True)
    events = List.T(model.Event.T(), optional=True)
    show_topo = Bool.T(optional=True, default=True)
    show_grid = Bool.T(optional=True, default=True)
    color_wet = Tuple.T(3, Int.T(), default=(200, 200, 200))
    color_dry = Tuple.T(3, Int.T(), default=(253, 253, 253))

    @classmethod
    def process_args(cls, *args, **kwargs):
        return cls(**kwargs)
Beispiel #4
0
class NoiseAnalyserConfig(AnalyserConfig):
    """Configuration parameters for the pre-event noise analysis."""

    nwindows = Int.T(default=1, help='number of windows for trace splitting')

    pre_event_noise_duration = Float.T(
        default=0., help='Total length of noise trace in the analysis')

    phase_def = String.T(
        default='P', help='Onset of phase_def used for upper limit of window')

    check_events = Bool.T(default=False,
                          help='check the GlobalCMT for M>5 earthquakes'
                          ' that produce phase arrivals'
                          ' contaminating and affecting the noise analysis')

    statistic = StringChoice.T(
        choices=('var', 'std'),
        default='var',
        help='Set weight to inverse of noise variance (var) or standard '
        'deviation (std).')

    mode = StringChoice.T(
        choices=('weighting', 'weeding'),
        default='weighting',
        help='Generate weights based on inverse of noise measure (weighting), '
        'or discrete on/off style in combination with cutoff value '
        '(weeding).')

    cutoff = Float.T(
        optional=True,
        help='Set weight to zero, when noise level exceeds median by the '
        'given cutoff factor.')

    def get_analyser(self):
        return NoiseAnalyser(
            nwindows=self.nwindows,
            pre_event_noise_duration=self.pre_event_noise_duration,
            check_events=self.check_events,
            phase_def=self.phase_def,
            statistic=self.statistic,
            mode=self.mode,
            cutoff=self.cutoff)
Beispiel #5
0
class PlotConfig(Object):
    name = 'undefined'
    variant = String.T(default='default',
                       help='Variant of the plot (if applicable)')
    formats = List.T(PlotFormat.T(),
                     default=[PNG()],
                     help='Format of the plot')
    size_cm = Tuple.T(2, Float.T(), help='size of the plot')
    font_size = Float.T(default=10., help='font size')

    @property
    def size_inch(self):
        return self.size_cm[0] / inch, self.size_cm[1] / inch

    @property
    def size_points(self):
        return self.size_cm[0] / points, self.size_cm[1] / points

    def make(self, environ):
        pass
Beispiel #6
0
class SeismicGFConfig(GFConfig):
    """
    Seismic GF parameters for Layered Halfspace.
    """
    code = String.T(default='qssp',
                    help='Modeling code to use. (qssp, qseis, comming soon: '
                    'qseis2d)')
    sample_rate = Float.T(default=2.,
                          help='Sample rate for the Greens Functions.')
    depth_limit_variation = Float.T(
        default=600., help='Depth limit [km] for varying the velocity model.')
    rm_gfs = Bool.T(default=True,
                    help='Flag for removing modeling module GF files after'
                    ' completion.')
    source_distance_radius = Float.T(
        default=20.,
        help='Radius of distance grid [km] for GF function grid around '
        'reference event.')
    source_distance_spacing = Float.T(
        default=1., help='Distance spacing [km] for GF function grid.')
Beispiel #7
0
class GPSNoiseGenerator(NoiseGenerator):
    measurement_duarion_days = Float.T(default=2.,
                                       help='Measurement duration in days')

    def add_noise(self, campaign):
        # https://www.nat-hazards-earth-syst-sci.net/15/875/2015/nhess-15-875-2015.pdf
        waterlevel = 1. - (.99 + .0015 * self.measurement_duarion_days)  # noqa
        logger.warning('GNSSNoiseGenerator is a work-in-progress!')

        for ista, sta in enumerate(campaign.stations):
            pass
Beispiel #8
0
class SandboxSource(Object):

    easting = Float.T(
        help='Easting in [m]')
    northing = Float.T(
        help='Northing in [m]')
    depth = Float.T(
        help='Depth in [m]')

    def __init__(self, *args, **kwargs):
        Object.__init__(self, *args, **kwargs)
        self._cached_result = None
        self.evParametersChanged = Subject()

    def parametersUpdated(self):
        self._cached_result = None
        self.evParametersChanged.notify()

    def getParametersArray(self):
        raise NotImplemented
Beispiel #9
0
class ParameterStats(Object):
    name = String.T()
    mean = Float.T()
    std = Float.T()
    best = Float.T()
    minimum = Float.T()
    percentile5 = Float.T()
    percentile16 = Float.T()
    median = Float.T()
    percentile84 = Float.T()
    percentile95 = Float.T()
    maximum = Float.T()

    def __init__(self, *args, **kwargs):
        kwargs.update(zip(self.T.propnames, args))
        Object.__init__(self, **kwargs)

    def get_values_dict(self):
        return dict((self.name + '.' + k, getattr(self, k))
                    for k in self.T.propnames if k != 'name')
Beispiel #10
0
class PolesZeros(BaseFilter):
    '''Response: complex poles and zeros. Corresponds to SEED
    blockette 53.'''

    pz_transfer_function_type = PzTransferFunction.T(
        xmltagname='PzTransferFunctionType')
    normalization_factor = Float.T(default=1.0,
                                   xmltagname='NormalizationFactor')
    normalization_frequency = Frequency.T(xmltagname='NormalizationFrequency')
    zero_list = List.T(PoleZero.T(xmltagname='Zero'))
    pole_list = List.T(PoleZero.T(xmltagname='Pole'))

    def get_pyrocko_response(self):
        if self.pz_transfer_function_type == 'DIGITAL (Z-TRANSFORM)':
            logger.warn(
                'unhandled pole-zero response of type "DIGITAL (Z-TRANSFORM)"')

            return []

        if self.pz_transfer_function_type not in (
                'LAPLACE (RADIANS/SECOND)',
                'LAPLACE (HERTZ)'):

            raise NoResponseInformation(
                'cannot convert PoleZero response of type %s' %
                self.pz_transfer_function_type)

        factor = 1.0
        cfactor = 1.0
        if self.pz_transfer_function_type == 'LAPLACE (HERTZ)':
            factor = 2. * math.pi
            cfactor = (2. * math.pi)**(
                len(self.pole_list) - len(self.zero_list))

        resp = trace.PoleZeroResponse(
            constant=self.normalization_factor*cfactor,
            zeros=[z.value()*factor for z in self.zero_list],
            poles=[p.value()*factor for p in self.pole_list])

        computed_normalization_factor = self.normalization_factor / abs(
            resp.evaluate(num.array([self.normalization_frequency.value]))[0])

        perc = abs(computed_normalization_factor /
                   self.normalization_factor - 1.0) * 100

        if perc > 2.0:
            logger.warn(
                'computed and reported normalization factors differ by '
                '%.1f%%: computed: %g, reported: %g' % (
                    perc,
                    computed_normalization_factor,
                    self.normalization_factor))

        return [resp]
Beispiel #11
0
class PyrockoDoubleCouple(SandboxSource, PyrockoSource):

    __implements__ = 'pyrocko'

    strike = Float.T(
        default=0.0,
        help='strike direction in [deg], measured clockwise from north')
    magnitude = Float.T(
        default=6.0,
        help='moment magnitude Mw as in [Hanks and Kanamori, 1979]')
    dip = Float.T(default=90.0,
                  help='dip angle in [deg], measured downward from horizontal')
    rake = Float.T(default=0.0,
                   help='rake angle in [deg], '
                   'measured counter-clockwise from right-horizontal '
                   'in on-plane view')
    store_dir = String.T(help='Pyrocko GF Store path')

    parametersUpdated = PyrockoSource.parametersUpdated

    def __init__(self, *args, **kwargs):
        SandboxSource.__init__(self, *args, **kwargs)
        self.pyrocko_source = gf.DCSource(**self._src_args)

    @property
    def moment(self):
        return self.pyrocko_source.moment

    @property
    def _src_args(self):
        return {
            'lat': 0.,
            'lon': 0.,
            'north_shift': self.northing,
            'east_shift': self.easting,
            'depth': self.depth,
            'magnitude': self.magnitude,
            'strike': self.strike,
            'dip': self.dip,
            'rake': self.rake
        }
Beispiel #12
0
class RandomResponse(trace.FrequencyResponse):

    scale = Float.T(default=0.0)

    def set_random_state(self, rstate):
        self._rstate = rstate

    def evaluate(self, freqs):
        n = freqs.size
        return 1.0 + (
            self._rstate.normal(scale=self.scale, size=n) +
            0.0J * self._rstate.normal(scale=self.scale, size=n))
Beispiel #13
0
class City(Object):
    def __init__(self, name, lat, lon, population=None, asciiname=None):
        name = newstr(name)
        lat = float(lat)
        lon = float(lon)
        if asciiname is None:
            asciiname = name.encode('ascii', errors='replace')

        if population is None:
            population = 0
        else:
            population = int(population)

        Object.__init__(self, name=name, lat=lat, lon=lon,
                        population=population, asciiname=asciiname)

    name = Unicode.T()
    lat = Float.T()
    lon = Float.T()
    population = Int.T()
    asciiname = String.T()
Beispiel #14
0
class ConfidenceEllipsoid(Object):
    semi_major_axis_length = Float.T()
    semi_minor_axis_length = Float.T()
    semi_intermediate_axis_length = Float.T()
    major_axis_plunge = Float.T()
    major_axis_azimuth = Float.T()
    major_axis_rotation = Float.T()
Beispiel #15
0
class EnhancedSacPzResponse(Object):
    codes = Tuple.T(4, String.T())
    tmin = Timestamp.T(optional=True)
    tmax = Timestamp.T(optional=True)
    lat = Float.T()
    lon = Float.T()
    elevation = Float.T()
    depth = Float.T()
    dip = Float.T()
    azimuth = Float.T()
    input_unit = String.T()
    output_unit = String.T()
    response = trace.PoleZeroResponse.T()

    def spans(self, *args):
        if len(args) == 0:
            return True
        elif len(args) == 1:
            return ((self.tmin is None or
                     self.tmin <= args[0]) and
                    (self.tmax is None or
                     args[0] <= self.tmax))

        elif len(args) == 2:
            return ((self.tmin is None or
                     args[1] >= self.tmin) and
                    (self.tmax is None or
                     self.tmax >= args[0]))
Beispiel #16
0
class PsCmpCoulombStressMasterFault(PsCmpCoulombStress):
    friction = Float.T(default=0.7)
    skempton_ratio = Float.T(default=0.0)
    master_fault_strike = Float.T(default=300.)
    master_fault_dip = Float.T(default=15.)
    master_fault_rake = Float.T(default=90.)
    sigma1 = Float.T(default=1.e6)
    sigma2 = Float.T(default=-1.e6)
    sigma3 = Float.T(default=0.0)

    def string_for_config(self):
        return '%(friction)15e %(skempton_ratio)15e %(master_fault_strike)15f' \
               '%(master_fault_dip)15f %(master_fault_rake)15f' \
               '%(sigma1)15e %(sigma2)15e %(sigma3)15e' % self.__dict__
Beispiel #17
0
class Channel(Object):
    name = String.T()
    azimuth = Float.T(optional=True)
    dip = Float.T(optional=True)
    gain = Float.T(default=1.0)

    def __init__(self, name, azimuth=None, dip=None, gain=1.0):
        if azimuth is None:
            azimuth = guess_azimuth_from_name(name)
        if dip is None:
            dip = guess_dip_from_name(name)

        Object.__init__(self,
                        name=name,
                        azimuth=float_or_none(azimuth),
                        dip=float_or_none(dip),
                        gain=float(gain))

    @property
    def ned(self):
        if None in (self.azimuth, self.dip):
            return None

        n = math.cos(self.azimuth * d2r) * math.cos(self.dip * d2r)
        e = math.sin(self.azimuth * d2r) * math.cos(self.dip * d2r)
        d = math.sin(self.dip * d2r)
        return mkvec(n, e, d)

    @property
    def enu(self):
        if None in (self.azimuth, self.dip):
            return None

        n = math.cos(self.azimuth * d2r) * math.cos(self.dip * d2r)
        e = math.sin(self.azimuth * d2r) * math.cos(self.dip * d2r)
        d = math.sin(self.dip * d2r)
        return mkvec(e, n, -d)

    def __str__(self):
        return '%s %f %f %g' % (self.name, self.azimuth, self.dip, self.gain)
Beispiel #18
0
class LinearGFConfig(GFConfig):
    """
    Config for linear GreensFunction calculation parameters.
    """
    reference_sources = List.T(
        RectangularSource.T(),
        help='Geometry of the reference source(s) to fix')
    patch_width = Float.T(default=5. * km,
                          help='Patch width [m] to divide reference sources')
    patch_length = Float.T(default=5. * km,
                           help='Patch length [m] to divide reference sources')
    extension_width = Float.T(
        default=0.1,
        help='Extend reference sources by this factor in each'
        ' dip-direction. 0.1 means extension of the fault by 10% in each'
        ' direction, i.e. 20% in total. If patches would intersect with'
        ' the free surface they are constrained to end at the surface.')
    extension_length = Float.T(
        default=0.1,
        help='Extend reference sources by this factor in each'
        ' strike-direction. 0.1 means extension of the fault by 10% in'
        ' each direction, i.e. 20% in total.')
Beispiel #19
0
class NonlinearGFConfig(GFConfig):
    """
    Config for non-linear GreensFunction calculation parameters.
    Defines how the grid of Green's Functions in the respective store is
    created.
    """

    earth_model_name = String.T(
        default='ak135-f-average.m',
        help='Name of the reference earthmodel, see '
        'pyrocko.cake.builtin_models() for alternatives.')
    use_crust2 = Bool.T(
        default=True,
        help='Flag, for replacing the crust from the earthmodel'
        'with crust from the crust2 model.')
    replace_water = Bool.T(
        default=True,
        help='Flag, for replacing water layers in the crust2 model.')
    custom_velocity_model = gf.Earthmodel1D.T(
        default=None,
        optional=True,
        help='Custom Earthmodel, in case crust2 and standard model not'
        ' wanted. Needs to be a :py::class:cake.LayeredModel')
    source_depth_min = Float.T(default=0.,
                               help='Minimum depth [km] for GF function grid.')
    source_depth_max = Float.T(default=10.,
                               help='Maximum depth [km] for GF function grid.')
    source_depth_spacing = Float.T(
        default=1., help='Depth spacing [km] for GF function grid.')
    source_distance_radius = Float.T(
        default=20.,
        help='Radius of distance grid [km] for GF function grid around '
        'reference event.')
    source_distance_spacing = Float.T(
        default=1.,
        help='Distance spacing [km] for GF function grid w.r.t'
        ' reference_location.')
    nworkers = Int.T(
        default=1, help='Number of processors to use for calculating the GFs')
Beispiel #20
0
class FrameConfig(Object):
    """Config object holding :class:`kite.scene.Scene` configuration"""

    llLat = Float.T(default=0.0, help="Scene latitude of lower left corner")
    llLon = Float.T(default=0.0, help="Scene longitude of lower left corner")
    dN = Float.T(default=25.0, help="Scene pixel spacing in north, give [m] or [deg]")
    dE = Float.T(default=25.0, help="Scene pixel spacing in east, give [m] or [deg]")
    spacing = StringChoice.T(
        choices=("degree", "meter"), default="meter", help="Unit of pixel space"
    )

    def __init__(self, *args, **kwargs):
        self.old_import = False
        mapping = {"dE": "dLon", "dN": "dLat"}

        for new, old in mapping.items():
            if old in kwargs:
                kwargs[new] = kwargs.pop(old)
                kwargs["spacing"] = "degree"
                self.old_import = True

        Object.__init__(self, *args, **kwargs)
Beispiel #21
0
class PyrockoVLVDSource(SandboxSource, PyrockoSource):
    """A ring fault with vertical doublecouples.

    See :class:`pyrocko.gf.seismosizer.VLVDSource`.
    """

    __implements__ = "pyrocko"

    store_dir = String.T(help="Pyrocko GF Store path")
    volume_change = Float.T(default=0.25, help="Volume change in [km^3]")
    azimuth = Float.T(default=0.0,
                      help="azimuth direction of CLVD, clockwise from north,"
                      " in [deg]")
    dip = Float.T(default=90.0,
                  help="dip angle of the CLVD from horizontal in [deg]")
    clvd_moment = Float.T(default=3e18,
                          help="Moment in [Nm] of the CLVD contribution")

    parametersUpdated = PyrockoSource.parametersUpdated

    def __init__(self, *args, **kwargs):
        SandboxSource.__init__(self, *args, **kwargs)
        PyrockoSource.__init__(self)
        self.pyrocko_source = gf.VLVDSource(**self._src_args)

    @property
    def _src_args(self):
        return {
            "lat": 0.0,
            "lon": 0.0,
            "north_shift": self.northing,
            "east_shift": self.easting,
            "depth": self.depth,
            "volume_change": self.volume_change * km3,
            "azimuth": self.azimuth,
            "dip": self.dip,
            "clvd_moment": self.clvd_moment,
        }
Beispiel #22
0
class SourceGenerator(LocationGenerator):

    nevents = Int.T(default=2)
    avoid_water = Bool.T(
        default=False,
        help='Avoid sources offshore under the ocean / lakes.')

    radius = Float.T(
        default=10*km)

    time_min = Timestamp.T(default=util.str_to_time('2017-01-01 00:00:00'))
    time_max = Timestamp.T(default=util.str_to_time('2017-01-03 00:00:00'))

    magnitude_min = Float.T(default=4.0)
    magnitude_max = Float.T(default=7.0)

    def get_sources(self):
        sources = []
        for ievent in range(self.nevents):
            sources.append(self.get_source(ievent))

        return sources

    def dump_data(self, path):
        fn_sources = op.join(path, 'sources.yml')
        with open(fn_sources, 'w') as f:
            for src in self.get_sources():
                f.write(src.dump())

        fn_events = op.join(path, 'events.txt')
        with open(fn_events, 'w') as f:
            for src in self.get_sources():
                f.write(src.pyrocko_event().dump())

        return [fn_events, fn_sources]

    def add_map_artists(self, automap):
        pass
Beispiel #23
0
class GNSSComponent(Object):
    ''' Component of a GNSSStation
    '''
    unit = StringChoice.T(choices=['mm', 'cm', 'm'], default='m')

    shift = Float.T(default=0., help='Shift in unit')

    sigma = Float.T(default=0.,
                    help='One sigma uncertainty of the measurement')

    def __add__(self, other):
        if not isinstance(other, self.__class__):
            raise AttributeError('Other has to be of instance %s' %
                                 self.__class__)
        comp = self.__class__()
        comp.shift = self.shift + other.shift
        comp.sigma = math.sqrt(self.sigma**2 + other.sigma**2)
        return comp

    def __iadd__(self, other):
        self.shift += other.shift
        self.sigma = math.sqrt(self.sigma**2 + other.sigma**2)
        return self
Beispiel #24
0
class MomentTensor(Object):
    public_id = ResourceReference.T(
        xmlstyle='attribute', xmltagname='publicID')
    data_used_list = List.T(DataUsed.T())
    comment_list = List.T(Comment.T())
    derived_origin_id = ResourceReference.T(xmltagname='derivedOriginID')
    moment_magnitude_id = ResourceReference.T(
        optional=True, xmltagname='momentMagnitudeID')
    scalar_moment = RealQuantity.T(optional=True)
    tensor = Tensor.T(optional=True)
    variance = Float.T(optional=True)
    variance_reduction = Float.T(optional=True)
    double_couple = Float.T(optional=True)
    clvd = Float.T(optional=True)
    iso = Float.T(optional=True)
    greens_function_id = ResourceReference.T(
        optional=True, xmltagname='greensFunctionID')
    filter_id = ResourceReference.T(optional=True, xmltagname='filterID')
    source_time_function = SourceTimeFunction.T(optional=True)
    method_id = ResourceReference.T(optional=True, xmltagname='methodID')
    category = MomentTensorCategory.T(optional=True)
    inversion_type = MTInversionType.T(optional=True)
    creation_info = CreationInfo.T(optional=True)
Beispiel #25
0
class PyrockoConfig(Object):
    cache_dir = PathWithPlaceholders.T(
        default=os.path.join(pyrocko_dir_tmpl, 'cache'))
    earthradius = Float.T(default=6371. * 1000.)
    gf_store_dirs = List.T(PathWithPlaceholders.T())
    gf_store_superdirs = List.T(PathWithPlaceholders.T())
    topo_dir = PathWithPlaceholders.T(
        default=os.path.join(pyrocko_dir_tmpl, 'topo'))
    geonames_dir = PathWithPlaceholders.T(
        default=os.path.join(pyrocko_dir_tmpl, 'geonames'))
    leapseconds_path = PathWithPlaceholders.T(
        default=os.path.join(pyrocko_dir_tmpl, 'leap-seconds.list'))
    leapseconds_url = String.T(
        default='http://www.ietf.org/timezones/data/leap-seconds.list')
Beispiel #26
0
class FrameConfig(Object):
    """Config object holding :class:`kite.scene.Scene` configuration """
    llLat = Float.T(default=0., help='Scene latitude of lower left corner')
    llLon = Float.T(default=0., help='Scene longitude of lower left corner')
    dN = Float.T(default=25.,
                 help='Scene pixel spacing in north, give [m] or [deg]')
    dE = Float.T(default=25.,
                 help='Scene pixel spacing in east, give [m] or [deg]')
    spacing = StringChoice.T(choices=('degree', 'meter'),
                             default='meter',
                             help='Unit of pixel space')

    def __init__(self, *args, **kwargs):
        self.old_import = False
        mapping = {'dE': 'dLon', 'dN': 'dLat'}

        for new, old in mapping.items():
            if old in kwargs:
                kwargs[new] = kwargs.pop(old)
                kwargs['spacing'] = 'degree'
                self.old_import = True

        Object.__init__(self, *args, **kwargs)
Beispiel #27
0
class PyrockoVLVDSource(SandboxSource, PyrockoSource):
    '''A ring fault with vertical doublecouples.

    See :class:`pyrocko.gf.seismosizer.VLVDSource`.
    '''
    __implements__ = 'pyrocko'

    store_dir = String.T(help='Pyrocko GF Store path')
    volume_change = Float.T(default=.25, help='Volume change in [km^3]')
    azimuth = Float.T(default=0.0,
                      help='azimuth direction of CLVD, clockwise from north,'
                      ' in [deg]')
    dip = Float.T(default=90.0,
                  help='dip angle of the CLVD from horizontal in [deg]')
    clvd_moment = Float.T(default=3e18,
                          help='Moment in [Nm] of the CLVD contribution')

    parametersUpdated = PyrockoSource.parametersUpdated

    def __init__(self, *args, **kwargs):
        SandboxSource.__init__(self, *args, **kwargs)
        PyrockoSource.__init__(self)
        self.pyrocko_source = gf.VLVDSource(**self._src_args)

    @property
    def _src_args(self):
        return {
            'lat': 0.,
            'lon': 0.,
            'north_shift': self.northing,
            'east_shift': self.easting,
            'depth': self.depth,
            'volume_change': self.volume_change * km3,
            'azimuth': self.azimuth,
            'dip': self.dip,
            'clvd_moment': self.clvd_moment
        }
Beispiel #28
0
class GRLawSTF(STF):
    '''Poisson distributed random impulses based on the Gutenberg-Richter law.'''

    duration = Float.T(default=0.0, help='baseline of the ramp')

    anchor = Float.T(
        default=0.0,
        help='anchor point with respect to source-time: ('
        '-1.0: left -> source duration [0, T] ~ hypocenter time, '
        ' 0.0: center -> source duration [-T/2, T/2] ~ centroid time, '
        '+1.0: right -> source duration [-T, 0] ~ rupture end time)')

    mag = Float.T(default=5.0, help='magnitude used for Gutenberg-Richter law')

    b = Float.T(default=1.2, help='b parameter for Gutenberg-Richter law')

    poisson_envelope = Int.T(
        default=0,
        help=
        'Whether to apply a Poisson distribution envelope to the magnitudes of the asperities.'
    )

    mu = Float.T(default=10, help='Mu parameter for Poisson envelope')

    loc = Float.T(optional=True,
                  help="'loc' parameter for Poisson distribution function")

    def discretize_t(self, deltat, tref):
        # Gutenberg-Ricther law
        M = np.linspace(0, self.mag, 1000)
        pdf = self.b * np.log(10) * 10**(-self.b * M)
        self.cdf = 1 - 10**(-self.b * M)

        # method returns discrete times and the respective amplitudes
        tmin_stf = tref - self.duration * (self.anchor + 1.) * 0.5
        tmax_stf = tref + self.duration * (1. - self.anchor) * 0.5
        tmin = round(tmin_stf / deltat) * deltat
        tmax = round(tmax_stf / deltat) * deltat
        nt = int(round((tmax - tmin) / deltat)) + 1
        times = np.linspace(tmin, tmax, nt)
        if nt > 1:
            self._amplitudes = np.random.uniform(min(self.cdf), max(self.cdf),
                                                 nt)
            if self.poisson_envelope:
                x = np.linspace(0, nt - 1, nt)
                self.envelope = poisson.pmf(x, mu=self.mu, loc=self.loc)
                self.amplitudes = self.mag * (self._amplitudes * self.envelope)
            else:
                self.amplitudes = self._amplitudes
        else:
            self.amplitudes = np.ones(1)

        return times, self.amplitudes

    def base_key(self):
        # method returns STF name and the values
        return (self.__class__.__name__, self.duration, self.anchor)
Beispiel #29
0
class Arrival(Object):
    public_id = ResourceReference.T(xmlstyle='attribute',
                                    xmltagname='publicID')
    comment_list = List.T(Comment.T())
    pick_id = ResourceReference.T(xmltagname='pickID')
    phase = Phase.T()
    time_correction = Float.T(optional=True)
    azimuth = Float.T(optional=True)
    distance = Float.T(optional=True)
    takeoff_angle = RealQuantity.T(optional=True)
    time_residual = Float.T(optional=True)
    horizontal_slowness_residual = Float.T(optional=True)
    backazimuth_residual = Float.T(optional=True)
    time_weight = Float.T(optional=True)
    time_used = Int.T(optional=True)
    horizontal_slowness_weight = Float.T(optional=True)
    backazimuth_weight = Float.T(optional=True)
    earth_model_id = ResourceReference.T(optional=True,
                                         xmltagname='earthModelID')
    creation_info = CreationInfo.T(optional=True)
Beispiel #30
0
class QSSPSourceMT(QSSPSource):
    munit = Float.T(default=1.0)
    mrr = Float.T(default=1.0)
    mtt = Float.T(default=1.0)
    mpp = Float.T(default=1.0)
    mrt = Float.T(default=0.0)
    mrp = Float.T(default=0.0)
    mtp = Float.T(default=0.0)

    def string_for_config(self):
        return '%(munit)15e %(mrr)15e %(mtt)15e %(mpp)15e ' \
               '%(mrt)15e %(mrp)15e %(mtp)15e ' \
            % self.__dict__ + QSSPSource.string_for_config(self)