Skip to content

Commit

Permalink
Fixed a save glitch, PCA updates
Browse files Browse the repository at this point in the history
  • Loading branch information
alsinmr committed Mar 22, 2024
1 parent 217ce35 commit 0beb1a0
Show file tree
Hide file tree
Showing 6 changed files with 1,295 additions and 3 deletions.
Binary file modified .temp.xtc_offsets.npz
Binary file not shown.
4 changes: 4 additions & 0 deletions Fitting/fit.py
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,7 @@ def model_free(data,nz:int=None,fixz:list=None,fixA:list=None,Niter:int=None,inc


op_in_rho=not(data.source.Type=='NMR') #Order parameter adds to detector responses (order parameter in rho)
# op_in_rho=False
if op_in_rho and np.any(data.sens.rhoz[:,-1]>0.99):
op_loc=np.argwhere(data.sens.rhoz[:,-1]>0.99)[0,-1]
else:
Expand Down Expand Up @@ -398,9 +399,11 @@ def model_free(data,nz:int=None,fixz:list=None,fixA:list=None,Niter:int=None,inc
A00.append((pinv.T*DelR).sum(1))
A00[-1][A00[-1]<0]=0
A00[-1][A00[-1]>1]=1

err.append(((DelR.T-m.T*A00[-1])**2).sum(0))
err=np.array(err)
i=err.argmin(0)

A00=np.array(A00).T
A[k]=np.array([A00[k][i0] for k,i0 in enumerate(i)])
z[k]=zswp[i]
Expand Down Expand Up @@ -433,6 +436,7 @@ def model_free(data,nz:int=None,fixz:list=None,fixA:list=None,Niter:int=None,inc
Rc+=(linear_ex(data.sens.z,data.sens.rhoz.T,z[m]).T*A[m]).T
z,A=np.array(z),np.array(A)
if op_in_rho:
A[:,A.sum(0)>1]/=A[:,A.sum(0)>1].sum(0)
Rc+=np.atleast_2d((1-A.sum(0))).T@np.atleast_2d(data.sens.rhoz[:,-1])

out=copy(data)
Expand Down
8 changes: 6 additions & 2 deletions PCA/PCAsubs.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,12 @@ def tc_avg(self):
DESCRIPTION.
"""

if self._tcavg is None:
dt=self.t[1]
i=np.argmax(self.Ct<0,axis=1)
self._tcavg=np.array([(Ct[:i0]).sum() for Ct,i0 in zip(self.Ct,i)],dtype=np.float64)
self._tcavg+=np.arange(len(self._tcavg))*1e-12
self._tcavg=np.array([(Ct[:i0]).sum()*dt for Ct,i0 in zip(self.Ct,i)],dtype=np.float64)
self._tcavg+=np.arange(len(self._tcavg))*1e-12 #Enforce unique values
return self._tcavg

@property
Expand Down Expand Up @@ -1027,6 +1029,8 @@ def _find(self,key,status='proc'):
def _raw(self,key):
"""
Exports a matrix of correlation functions to a data object
Parameters
----------
Expand Down
4 changes: 4 additions & 0 deletions PCA/testPCA.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@
traj_files='/Users/albertsmith/Documents/Dynamics/MDsims.nosync/Y1/apo1.xtc',
step=1,t0=5900,tf=19150)

select=pyDR.MolSelect(topo='/Volumes/My Book/Y1/apo/prot.pdb',
traj_files='/Volumes/My Book/Y1/apo/apo1.xtc',
step=1,t0=5900,tf=19150)


pca=PCA(select)
pca.select_bond('15N')
Expand Down
6 changes: 5 additions & 1 deletion Project/Project.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,11 @@ def save(self,i='all',include_rawMD=False):
src_fname=os.path.abspath(src_data)
else:
if src_data in self.data_objs:
src_fname=os.path.join(self.directory,self.saved_files[self.data_objs.index(src_data)])
file=self.saved_files[self.data_objs.index(src_data)]
if file is None:
src_fname=None
else:
src_fname=os.path.join(self.directory,)
else:
src_fname=None

Expand Down
Loading

0 comments on commit 0beb1a0

Please sign in to comment.