Contributing#
We welcome contributions to the project. Please read the following guidelines before submitting a pull request.
General#
In General, please refer to existing implementations and adhere to the structure and style of the existing code.
B-Value Estimation Methods#
Create a new file inside the
seismostats.analysis.bvaluepackage, containing a class which inherits fromseismostats.analysis.bvalue.BValueEstimator.
class MyBValueEstimator(BValueEstimator):
Implement a constructor, which takes as a minimum
*argsand**kwargsand passes them on tosuper().__init__(*args, **kwargs). This is necessary for the class to be able to be instantiated.
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
If your method takes additional parameters, add them in the constructor and assign them to class variables
def __init__(self, my_parameter: float, *args, **kwargs):
super().__init__(*args, **kwargs)
self.my_parameter = my_parameter
Implement the
_estimatemethod, which does the actual calculation. This method does not take any input parameters, and returns the b-value. Please note the following points:All necessary parameters are available as class variables. Just inheriting from the base class, will give you access to the following variables:
self.magnitudes: The magnitudes of the earthquakes.self.delta_m: The magnitude bin width.self.mc: The magnitude of completeness.(optional)
self.weights: The weights assigned to the magnitudes.
If you are filtering or modifying the
self.magnitudesarray, please make sure to updateself.magnitudeswith the final version of the magnitudes you are using.
def _estimate(self):
# Do the calculation here
return b_value
If your implementation allows using weights, set the
_weights_supportedclass variable toTrue, orFalseotherwise.
class MyBValueEstimator(BValueEstimator):
_weights_supported = True
The basic functionalities should now work automatically, like calculation of the standard deviation or estimation of
betainstead ofb. You can still add additional methods to the class if you would like to, or submit a pull request to extend the base functionality ofBValueEstimatorif needed.Add a simple regression test to the
testsfolder, which tests the functionality of your method. This is necessary to ensure that the method works correctly and to prevent future changes from breaking the method.
The test should be simple, and only test the correct calculation of the b-value using a static dataset and b-value. If you added more functionality, you should also test this.Add docstrings, following the Google Style Guide, this is necessary for the documentation to be generated correctly.