Skip to content

Commit

Permalink
correct scaling of pcs for eigen
Browse files Browse the repository at this point in the history
  • Loading branch information
nicrie committed Jul 29, 2021
1 parent 0292214 commit d599e7a
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions xmca/array.py
Original file line number Diff line number Diff line change
Expand Up @@ -631,8 +631,6 @@ def _get_pcs(
self, n=None, scaling='None', phase_shift=0, original=False):

U = self._get_U(n, original=original)
n_max_mode = U['left'].shape[1]
sqrt_svals = np.sqrt(self._get_svals(n_max_mode))

for k in self._keys:
# apply phase shift
Expand All @@ -643,7 +641,8 @@ def _get_pcs(
pass
# by eigenvalues
elif scaling == 'eigen':
U[k] *= sqrt_svals
norm = self._get_norm(n, sorted=True)
U[k] *= norm[k]
# by maximum value
elif scaling == 'max':
U[k] /= np.nanmax(abs(U[k].real), axis=0)
Expand Down Expand Up @@ -1199,8 +1198,8 @@ def predict(
if scaling == 'None':
pass
elif scaling == 'eigen':
norm = self._get_norm(sorted=True)
pcs *= sqrt_svals[:n] * norm[k][:n]
norm = self._get_norm(n, sorted=True)
pcs *= norm[k]
# by maximum value
elif scaling == 'max':
original_pcs = self._get_pcs(n, 'None', phase_shift)
Expand Down

0 comments on commit d599e7a

Please sign in to comment.