Skip to content

Commit

Permalink
Merge pull request #82 from orionarcher/debug_polymer
Browse files Browse the repository at this point in the history
debugged error in residence time
  • Loading branch information
orionarcher authored Jan 11, 2023
2 parents ef921c3 + 7a650f2 commit 05cee19
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions solvation_analysis/residence.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,17 +240,23 @@ def _fit_exponential(auto_covariance, res_name):
@staticmethod
def _calculate_auto_covariance(adjacency_matrix):
auto_covariances = []
timesteps = adjacency_matrix.index.levels[0]

for solute_ix, solute_df in adjacency_matrix.groupby([SOLUTE_IX, SOLUTE_ATOM_IX]):
# this is needed to make sure auto-covariances can be concatenated later
if solute_df.index.levshape[0] != adjacency_matrix.index.levshape[0]:
solute_df = solute_df.droplevel([SOLUTE_IX, SOLUTE_ATOM_IX]).reindex(timesteps, fill_value=0)
non_zero_cols = solute_df.loc[:, (solute_df != 0).any(axis=0)]
auto_covariance_df = non_zero_cols.apply(
acovf,
axis=0,
result_type='expand',
demean=False,
unbiased=True,
adjusted=True,
fft=True
)
# timesteps with no binding are getting skipped, we need to make sure to include all timesteps
auto_covariances.append(auto_covariance_df.values)

auto_covariance = np.mean(np.concatenate(auto_covariances, axis=1), axis=1)
return auto_covariance

0 comments on commit 05cee19

Please sign in to comment.