AI4EPS / GaMMA

GaMMA: Earthquake Phase Association using a Bayesian Gaussian Mixture Model
MIT License
74 stars 29 forks source link

the script example_synthetic.ipynb has fails to execute successfully #46

Closed dh4931 closed 2 months ago

dh4931 commented 7 months ago

When i run the script example_synthetic.ipynb,I found that the script fails to execute successfully on my computer. I did not modify any parameters in the script, while executing it .

In the first step( Prepare synthetic data), the cell runs successfully. The output parameter _phase_type_ has a shape of (137,), which includes 65 'p' items and 72 's' items.

However, in the second step(Association with GaMMA ), the cell fails to run successfully. The Error occurs at "gmm= BayesianGaussianMixture(...)". and I have verified that the input parameter _num_event_init_ is 41.

my Python version is 3.7.13, my Numpy version is 1.21.5.

error report is as follow #

error report

--------------------------------------------------------------------------- IndexError Traceback (most recent call last) /tmp/ipykernel_98731/1795965897.py in 33 loss_type="l1", 34 # max_covar=10**2, ---> 35 ).fit(data) 36 37 # gmm = GaussianMixture(n_components=num_event_init, ~/software/Anaconda3/envs/phasenet/lib/python3.7/site-packages/gamma/_base.py in fit(self, X, y) 202 self 203 """ --> 204 self.fit_predict(X, y) 205 return self 206 ~/software/Anaconda3/envs/phasenet/lib/python3.7/site-packages/gamma/_base.py in fit_predict(self, X, y) 247 248 if do_init: --> 249 self._initialize_parameters(X, random_state) 250 251 lower_bound = (-np.infty if do_init else self.lower_bound_) ~/software/Anaconda3/envs/phasenet/lib/python3.7/site-packages/gamma/_base.py in _initialize_parameters(self, X, random_state) 166 % self.init_params) 167 --> 168 self._initialize(X, resp) 169 170 @abstractmethod ~/software/Anaconda3/envs/phasenet/lib/python3.7/site-packages/gamma/_bayesian_mixture.py in _initialize(self, X, resp) 541 self._estimate_weights(nk) 542 self._estimate_means(nk, xk) --> 543 self._estimate_precisions(nk, xk, sk) 544 self.centers_ = centers 545 ~/software/Anaconda3/envs/phasenet/lib/python3.7/site-packages/gamma/_bayesian_mixture.py in _estimate_precisions(self, nk, xk, sk) 596 "diag": self._estimate_wishart_diag, 597 "spherical": self._estimate_wishart_spherical --> 598 }[self.covariance_type](nk, xk, sk) 599 600 self.precisions_cholesky_ = _compute_precision_cholesky( ~/software/Anaconda3/envs/phasenet/lib/python3.7/site-packages/gamma/_bayesian_mixture.py in _estimate_wishart_full(self, nk, xk, sk) 624 625 for k in range(self.n_components): --> 626 diff = xk[k] - self.mean_prior_ 627 self.covariances_[k] = (self.covariance_prior_ + nk[k] * sk[k] + 628 nk[k] * self.mean_precision_prior_ / IndexError: index 39 is out of bounds for axis 0 with size 39

Additionally, I would like to understand why the parameter num_event_init is defined as min(int(len(data)/min(num_station, 20) * 6), len(data)). Why is there a comparison with min(num_station, 20)? What is the significance of the value 6? Does it represent six components related to 'p' and 's'?"

zhuwq0 commented 7 months ago

sorry, I cannot reproduce your error. I no longer maintain this synthetic test example. Please use the real data examples.