AI4EPS / GaMMA

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

'float' object has no attribute 'log' #37

Closed wuhongsheng closed 1 year ago

wuhongsheng commented 1 year ago

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "/Users/whs/VS_code/PhasePick/performer/position_analysis.py", line 547, in gamma_location(filepath, "") File "/Users/whs/VS_code/PhasePick/performer/position_analysis.py", line 82, in gamma_location catalogs, assignments = association(pick_df, stationdf, config, method=config["method"]) File "/Users/whs/anaconda3/envs/TF2/lib/python3.9/site-packages/gamma/utils.py", line 86, in association events, assignment_ = associate( File "/Users/whs/anaconda3/envs/TF2/lib/python3.9/site-packages/gamma/utils.py", line 208, in associate gmm = BayesianGaussianMixture( File "/Users/whs/anaconda3/envs/TF2/lib/python3.9/site-packages/gamma/_base.py", line 204, in fit self.fit_predict(X, y) File "/Users/whs/anaconda3/envs/TF2/lib/python3.9/site-packages/gamma/_base.py", line 256, in fit_predict log_prob_norm, log_resp = self._e_step(X) File "/Users/whs/anaconda3/envs/TF2/lib/python3.9/site-packages/gamma/_base.py", line 311, in _e_step log_prob_norm, log_resp = self._estimate_log_prob_resp(X) File "/Users/whs/anaconda3/envs/TF2/lib/python3.9/site-packages/gamma/_base.py", line 516, in _estimate_log_prob_resp weighted_log_prob = self._estimate_weighted_log_prob(X) File "/Users/whs/anaconda3/envs/TF2/lib/python3.9/site-packages/gamma/_base.py", line 469, in _estimate_weighted_log_prob return self._estimate_log_prob(X) + self._estimate_log_weights() File "/Users/whs/anaconda3/envs/TF2/lib/python3.9/site-packages/gamma/_bayesian_mixture.py", line 770, in _estimate_log_prob log_gauss += np.log(self.phase_weight)[:,np.newaxis] TypeError: loop of ufunc does not support argument 0 of type float which has no callable log method

my pick dataframe is id timestamp prob type 0 1 2023-07-03 20:52:18.439 0.982461 p 2 2 2023-07-03 20:52:18.439 0.980837 p 6 5 2023-07-03 20:52:18.449 0.976844 p 1 1 2023-07-03 20:52:18.459 0.990819 s 3 2 2023-07-03 20:52:18.459 0.992283 s 4 4 2023-07-03 20:52:18.459 0.964814 p 5 4 2023-07-03 20:52:18.469 0.989519 s 8 6 2023-07-03 20:52:18.469 0.974579 p 7 5 2023-07-03 20:52:18.479 0.991218 s 9 6 2023-07-03 20:52:18.489 0.98942 s

zhuwq0 commented 1 year ago

It seems you have phase_weight == 0?

wuhongsheng commented 1 year ago

I fix this problem in utils.py phase_weight = picks["prob"].to_numpy(dtype=float)[:, np.newaxis]