Merge branch 'master' of git.mkray.de:mwtkrayer/suspendtools

This commit is contained in:
Michael Krayer 2021-12-03 10:39:00 +01:00
commit 1b46b2d188
1 changed files with 13 additions and 0 deletions

View File

@ -49,6 +49,19 @@ class Particles:
attr[key] = pp[col[key],:,0].squeeze()
return cls(num,time,attr,period)
@classmethod
def from_mat(cls,file,select_col=None):
from .helper import load_mat
pp = load_mat(file,'pp',cast_integer=False) # int casting is expensive and useless on potentially large array
col,time,ccinfo = load_mat(file,['colpy','time','ccinfo'],cast_integer=True)
period = [None,None,None]
if bool(ccinfo['xperiodic']): period[0]=ccinfo['b']
if bool(ccinfo['yperiodic']): period[1]=ccinfo['d']
if bool(ccinfo['zperiodic']): period[2]=ccinfo['f']
for key in col:
col[key]-=1
return cls.from_array(pp,col,time,period,select_col=select_col)
@classmethod
def from_position(cls,x,y,z,time,period):
assert x.ndim==1 and y.ndim==1 and z.ndim==1,\