Skip to content

Commit ed1b9ee

Browse files
committed
bugfix in hom_velocity_field & euler_rot_field
1 parent 28ee7a1 commit ed1b9ee

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

disstans/network.py

+3-7
Original file line numberDiff line numberDiff line change
@@ -2135,7 +2135,6 @@ def _get_2comp_pars_covs(self,
21352135
mdl_description: str,
21362136
index: int,
21372137
comps: tuple[int, int],
2138-
num_mdl_comps: int,
21392138
use_vars: bool,
21402139
use_covs: bool
21412140
) -> tuple[np.ndarray, np.ndarray | None]:
@@ -2151,10 +2150,9 @@ def _get_2comp_pars_covs(self,
21512150
.var[index, comps]
21522151
for station in stat_list_in], axis=0)
21532152
if use_covs:
2154-
linear_index_cov = index * num_mdl_comps
21552153
covlist = [station
21562154
.models[ts_description][mdl_description]
2157-
.cov[linear_index_cov + comps[0], linear_index_cov + comps[1]]
2155+
.get_cov_by_index(index)[comps]
21582156
for station in stat_list_in]
21592157
covs = np.concatenate([covs, np.array(covlist).reshape(-1, 1)], axis=1)
21602158
else:
@@ -2272,7 +2270,6 @@ def hom_velocity_field(self,
22722270
lat0, lon0 = ref_stat.location[0], ref_stat.location[1]
22732271
linear_index = ref_stat.models[ts_description][mdl_description].get_exp_index(1)
22742272
use_vars &= ref_stat.models[ts_description][mdl_description].cov is not None
2275-
num_mdl_comps = ref_stat.models[ts_description][mdl_description].num_parameters
22762273
v_pred_cols = [ref_stat[ts_description].data_cols[c] for c in comps]
22772274
# for the inversion, we need the indices of the subsets
22782275
ix_in = [n in stat_names_in for n in stat_names_valid]
@@ -2288,7 +2285,7 @@ def hom_velocity_field(self,
22882285
# get all velocities and weights for subset
22892286
vels, weights = self._get_2comp_pars_covs(stat_list_in, ts_description,
22902287
mdl_description, linear_index, comps,
2291-
num_mdl_comps, use_vars, use_covs)
2288+
use_vars, use_covs)
22922289
# calculate homogenous translation, strain, and rotation
22932290
v_O, epsilon, omega = get_hom_vel_strain_rot(lon_lat_in, vels, weights,
22942291
utmzone=utmzone, reference=[lon0, lat0])
@@ -2382,7 +2379,6 @@ def euler_rot_field(self,
23822379
ref_stat = stat_list_in[reference_index]
23832380
linear_index = ref_stat.models[ts_description][mdl_description].get_exp_index(1)
23842381
use_vars &= ref_stat.models[ts_description][mdl_description].cov is not None
2385-
num_mdl_comps = ref_stat.models[ts_description][mdl_description].num_parameters
23862382
v_pred_cols = [ref_stat[ts_description].data_cols[c] for c in comps]
23872383
# for the inversion, we need the indices of the subsets
23882384
ix_in = [n in stat_names_in for n in stat_names_valid]
@@ -2396,7 +2392,7 @@ def euler_rot_field(self,
23962392
# get all velocities and weights for subset
23972393
vels, weights = self._get_2comp_pars_covs(stat_list_in, ts_description,
23982394
mdl_description, linear_index, comps,
2399-
num_mdl_comps, use_vars, use_covs)
2395+
use_vars, use_covs)
24002396
# calculate Euler pole from input list
24012397
rotation_vector, rotation_covariance = \
24022398
estimate_euler_pole(lon_lat_in, vels, weights)

0 commit comments

Comments
 (0)