Skip to content

Commit 656c8be

Browse files
committed
backports from development
- ed1b9ee - 6d41a97
1 parent ba09906 commit 656c8be

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

disstans/network.py

+3-7
Original file line numberDiff line numberDiff line change
@@ -2116,7 +2116,6 @@ def _get_2comp_pars_covs(self,
21162116
mdl_description: str,
21172117
index: int,
21182118
comps: tuple[int, int],
2119-
num_mdl_comps: int,
21202119
use_vars: bool,
21212120
use_covs: bool
21222121
) -> tuple[np.ndarray, np.ndarray | None]:
@@ -2132,10 +2131,9 @@ def _get_2comp_pars_covs(self,
21322131
.var[index, comps]
21332132
for station in stat_list_in], axis=0)
21342133
if use_covs:
2135-
linear_index_cov = index * num_mdl_comps
21362134
covlist = [station
21372135
.models[ts_description][mdl_description]
2138-
.cov[linear_index_cov + comps[0], linear_index_cov + comps[1]]
2136+
.get_cov_by_index(index)[comps]
21392137
for station in stat_list_in]
21402138
covs = np.concatenate([covs, np.array(covlist).reshape(-1, 1)], axis=1)
21412139
else:
@@ -2253,7 +2251,6 @@ def hom_velocity_field(self,
22532251
lat0, lon0 = ref_stat.location[0], ref_stat.location[1]
22542252
linear_index = ref_stat.models[ts_description][mdl_description].get_exp_index(1)
22552253
use_vars &= ref_stat.models[ts_description][mdl_description].cov is not None
2256-
num_mdl_comps = ref_stat.models[ts_description][mdl_description].num_parameters
22572254
v_pred_cols = [ref_stat[ts_description].data_cols[c] for c in comps]
22582255
# for the inversion, we need the indices of the subsets
22592256
ix_in = [n in stat_names_in for n in stat_names_valid]
@@ -2269,7 +2266,7 @@ def hom_velocity_field(self,
22692266
# get all velocities and weights for subset
22702267
vels, weights = self._get_2comp_pars_covs(stat_list_in, ts_description,
22712268
mdl_description, linear_index, comps,
2272-
num_mdl_comps, use_vars, use_covs)
2269+
use_vars, use_covs)
22732270
# calculate homogenous translation, strain, and rotation
22742271
v_O, epsilon, omega = get_hom_vel_strain_rot(lon_lat_in, vels, weights,
22752272
utmzone=utmzone, reference=[lon0, lat0])
@@ -2363,7 +2360,6 @@ def euler_rot_field(self,
23632360
ref_stat = stat_list_in[reference_index]
23642361
linear_index = ref_stat.models[ts_description][mdl_description].get_exp_index(1)
23652362
use_vars &= ref_stat.models[ts_description][mdl_description].cov is not None
2366-
num_mdl_comps = ref_stat.models[ts_description][mdl_description].num_parameters
23672363
v_pred_cols = [ref_stat[ts_description].data_cols[c] for c in comps]
23682364
# for the inversion, we need the indices of the subsets
23692365
ix_in = [n in stat_names_in for n in stat_names_valid]
@@ -2377,7 +2373,7 @@ def euler_rot_field(self,
23772373
# get all velocities and weights for subset
23782374
vels, weights = self._get_2comp_pars_covs(stat_list_in, ts_description,
23792375
mdl_description, linear_index, comps,
2380-
num_mdl_comps, use_vars, use_covs)
2376+
use_vars, use_covs)
23812377
# calculate Euler pole from input list
23822378
rotation_vector, rotation_covariance = \
23832379
estimate_euler_pole(lon_lat_in, vels, weights)

scripts/example_1_longvalleycaldera.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,12 @@
100100

101101
# estimate the common mode, either with a visualization of the result or not
102102
# (same underlying function)
103-
# net.graphical_cme(ts_in="raw_filt_res", ts_out="common", method="ica")
103+
# net.graphical_cme(ts_in="raw_filt_res", ts_out="common",
104+
# method="ica", rng=np.random.default_rng(0))
104105
# calculate common mode
105-
net.call_netwide_func("decompose", ts_in="raw_filt_res", ts_out="common", method="ica")
106+
net.call_netwide_func("decompose", ts_in="raw_filt_res", ts_out="common",
107+
method="ica", rng=np.random.default_rng(0))
108+
# now remove the common mode, call it the "intermed" timeseries,
106109
# now remove the common mode, call it the "intermed" timeseries,
107110
for station in net:
108111
station.add_timeseries("intermed", station["raw_clean"] - station["common"],

0 commit comments

Comments
 (0)