rsqsim_api.catalogue.utilities ============================== .. py:module:: rsqsim_api.catalogue.utilities .. autoapi-nested-parse:: Utility functions for RSQSim catalogue statistics and seismological calculations. Provides magnitude–moment conversions, b-value estimation, stress drop and scaling-parameter calculations, and helper functions for computing weighted circular statistics. Functions --------- .. autoapisummary:: rsqsim_api.catalogue.utilities.calculate_b_value_kijko_smit rsqsim_api.catalogue.utilities.calculate_scaling_c rsqsim_api.catalogue.utilities.calculate_stress_drop rsqsim_api.catalogue.utilities.summary_statistics rsqsim_api.catalogue.utilities.mw_to_m0 rsqsim_api.catalogue.utilities.m0_to_mw rsqsim_api.catalogue.utilities.weighted_circular_mean rsqsim_api.catalogue.utilities.median_cumulant rsqsim_api.catalogue.utilities.jit_intersect rsqsim_api.catalogue.utilities.mw_from_area_and_scaling_c rsqsim_api.catalogue.utilities.slip_from_area_and_scaling_c Module Contents --------------- .. py:function:: calculate_b_value_kijko_smit(magnitudes, min_mw = 0.0, max_mw = 10.0) Estimate the Gutenberg-Richter b-value using the Kijko and Smit (2012) method. :param magnitudes: Array of moment magnitudes. :type magnitudes: numpy.ndarray :param min_mw: Lower magnitude cutoff. Events below this are excluded. Defaults to 0.0. :type min_mw: float, optional :param max_mw: Upper magnitude cutoff. Events above this are excluded. Defaults to 10.0. :type max_mw: float, optional :returns: Estimated b-value (log₁₀ base). :rtype: float .. py:function:: calculate_scaling_c(magnitudes, areas) Calculate the Gutenberg-Richter scaling parameter c. The parameter ``c`` is defined as ``Mw - log10(area) + 6``, where ``area`` is in m². :param magnitudes: Array of moment magnitudes. :type magnitudes: numpy.ndarray :param areas: Array of rupture areas in m². :type areas: numpy.ndarray :returns: Scaling parameter c for each event. :rtype: numpy.ndarray .. py:function:: calculate_stress_drop(seismic_moments, areas, stress_c=2.44) Calculate stress drop from seismic moments and rupture areas. Uses the relation ``Δσ = C * M0 / A^1.5``. Typical values of ``C`` are 2.44 for a circular crack, and 2.53, 3.02, 5.21 for rectangular cracks with aspect ratios of 1, 4, and 16, respectively. :param seismic_moments: Scalar seismic moments in N·m. :type seismic_moments: numpy.ndarray :param areas: Rupture areas in m². :type areas: numpy.ndarray :param stress_c: Shape constant. Defaults to 2.44 (circular crack). :type stress_c: float, optional :returns: Stress drop in Pa for each event. :rtype: numpy.ndarray .. py:function:: summary_statistics(dataframe, stress_c = 2.44) Compute summary statistics for a catalogue DataFrame. Calculates the 5th, 50th, and 95th percentiles of the scaling parameter c and the stress drop, together with the maximum magnitude. :param dataframe: Catalogue DataFrame with columns ``"mw"``, ``"area"`` (m²), and ``"m0"`` (N·m). :type dataframe: pandas.DataFrame :param stress_c: Shape constant passed to :func:`calculate_stress_drop`. Defaults to 2.44. :type stress_c: float, optional :returns: Series with index ``["Max Mw, 5th C, 50th C, 95th C, 5th SD, 50th SD, 95th SD"]`` where ``C`` is the scaling parameter and ``SD`` is the stress drop in MPa. :rtype: pandas.Series .. py:function:: mw_to_m0(magnitudes) Convert moment magnitude to scalar seismic moment. Uses the relation ``M0 = 10^(1.5 * Mw + 9.05)``. :param magnitudes: Array of moment magnitudes. :type magnitudes: numpy.ndarray :returns: Scalar seismic moments in N·m. :rtype: numpy.ndarray .. py:function:: m0_to_mw(seismic_moment) Convert scalar seismic moment to moment magnitude. Uses the relation ``Mw = (log10(M0) - 9.05) / 1.5``. :param seismic_moment: Scalar seismic moment in N·m. :type seismic_moment: float :returns: Moment magnitude. :rtype: float .. py:function:: weighted_circular_mean(azimuths, weights) Compute the weighted circular (angular) mean of a set of azimuths. :param azimuths: Azimuth values in degrees. :type azimuths: numpy.ndarray :param weights: Weights for each azimuth (e.g. patch areas or seismic moments). :type weights: numpy.ndarray :returns: Weighted circular mean azimuth in degrees. :rtype: float .. py:function:: median_cumulant(m0_array, mw_array) Compute the median cumulant magnitude for a set of events on a patch. Sorts events by M0, forms the normalised cumulative sum of Mw, and returns the Mw at the index where the cumulative sum first reaches 0.5. :param m0_array: Scalar seismic moments (N·m) for all events rupturing a patch. :type m0_array: numpy.ndarray :param mw_array: Corresponding moment magnitudes. :type mw_array: numpy.ndarray :returns: Moment magnitude at the median of the cumulative M0 distribution. :rtype: float .. py:function:: jit_intersect(l1, l2) JIT-compiled intersection of two integer arrays. Returns the unique values that appear in both ``l1`` and ``l2``. :param l1: First integer array. :type l1: numpy.ndarray of int32 :param l2: Second integer array. :type l2: numpy.ndarray of int32 :returns: Sorted unique values present in both arrays. :rtype: numpy.ndarray of int32 .. py:function:: mw_from_area_and_scaling_c(area, c) Calculate moment magnitude from rupture area and scaling parameter c. Uses the relation ``Mw = log10(area) - 6 + c``. :param area: Rupture area in m². :type area: float :param c: Scaling parameter (typically ~4.2 for New Zealand crustal faults). :type c: float :returns: Moment magnitude. :rtype: float .. py:function:: slip_from_area_and_scaling_c(area, c, mu = 30000000000.0) Calculate mean slip from rupture area and scaling parameter c. Computes the seismic moment from the area and ``c``, then divides by ``mu * area`` to give the average slip. :param area: Rupture area in m². :type area: float :param c: Scaling parameter (typically ~4.2 for New Zealand crustal faults). :type c: float :param mu: Shear modulus in Pa. Defaults to 3×10¹⁰ Pa (30 GPa). :type mu: float, optional :returns: Average slip in metres. :rtype: float