def e(self): '''Calculate eccentricity of an object's orbit''' val = 1.+2.*self.eps()*Merc.mag(self.h())**2./self.gm()**2. if ((val < 0) & (-val < tol)): val = 0 e = sqrt(val) return(np.array(e))
def i(self): '''Calculate inclination of an object's orbit. Takes mks, returns degrees''' i = arccos(self.h()[2]/Merc.mag(self.h()))*180./pi return(np.array(i))
def v(self): return(Merc.mag(self.vel))
def dr(self,other): '''Distance between two objects.''' x1 = self.pos x2 = other.pos dr = Merc.mag(x1-x2) return(dr)
def r(self): return(Merc.mag( self.pos))
# calculate minimum pericenter, last time it happens, and final i for ind, l in enumerate([0, 1, 2]): # get basic stats of this sim dr = d vrs = vers[l] tf = t[l][-1] aBf = aB[l][-1] eBf = eB[l][-1] pBf = aBf * (1 - eBf) apBf = aBf * (1 + eBf) aCf = aC[l][-1] eCf = eC[l][-1] pCf = aCf * (1 - eCf) apCf = aCf * (1 + eCf) minpB = min(pB[l]) mintB = t[l][Merc.which(pB[l], minpB)] if not all(np.isnan(pC[l])): minpC = min(pC[l]) mintC = t[l][Merc.which(pC[l], minpC)] elif l == 1: minpC, mintC = np.nan, np.array([np.nan]) else: print('Warning: pC = nan, but vers not B-2!') iMf = iM[l][-1] rtrf = rtr[l][-1] rpf = rtrf / pBf rpm = rtrf / minpB # add to summary # line = np.array([[dr,vrs,tf, aBf,eBf,pBf,apBf, # aCf,eCf,pCf,apCf, # minpB,max(mintB),minpC,max(mintC),iMf,rtrf]])
thisdir = pd.read_csv('TimeData/TimeData-' + simID + '.txt', delim_whitespace=True) # Calculate non-time-dependent stats for this sim, and add to summary dr = d vrs = s tf = thisdir.t.iloc[-1] aBf = thisdir.aB.iloc[-1] eBf = thisdir.eB.iloc[-1] pBf = aBf * (1 - eBf) apBf = aBf * (1 + eBf) aCf = thisdir.aC.iloc[-1] eCf = thisdir.eC.iloc[-1] pCf = aCf * (1 - eCf) apCf = aCf * (1 + eCf) minpB = min(thisdir.pB) mintB = max(thisdir.t.iloc[Merc.which(thisdir.pB, minpB)]) if not all(np.isnan(thisdir.pC)): minpC = min(thisdir.pC) mintC = max(thisdir.t.iloc[Merc.which(thisdir.pC, minpC)]) elif '2' in s: minpC, mintC = np.nan, np.nan else: print( 'Warning: pC = nan, but subdir is {}, not a disk binary!'. format(s)) iMf = thisdir.iC.iloc[-1] - thisdir.iB.iloc[-1] rtrf = thisdir.rtr.iloc[-1] rpf = rtrf / pBf rpm = rtrf / minpB # make a dictionary of these stats, to enter as one line in the dataframe
# calculate minimum pericenter, last time it happens, and final i for ind,l in enumerate([0,1,2]): # get basic stats of this sim dr = d vrs = vers[l] tf = t[l][-1] aBf = aB[l][-1] eBf = eB[l][-1] pBf = aBf*(1-eBf) apBf = aBf*(1+eBf) aCf = aC[l][-1] eCf = eC[l][-1] pCf = aCf*(1-eCf) apCf = aCf*(1+eCf) minpB = min(pB[l]) mintB = t[l][Merc.which(pB[l],minpB)] if not all(np.isnan(pC[l])): minpC = min(pC[l]) mintC = t[l][Merc.which(pC[l],minpC)] elif l==1: minpC, mintC = np.nan, np.array([np.nan]) else: print('Warning: pC = nan, but vers not B-2!') iMf = iM[l][-1] rtrf = rtr[l][-1] rpf = rtrf/pBf rpm = rtrf/minpB # add to summary # line = np.array([[dr,vrs,tf, aBf,eBf,pBf,apBf, # aCf,eCf,pCf,apCf, # minpB,max(mintB),minpC,max(mintC),iMf,rtrf]])
simID = d+'-'+s thisdir = pd.read_csv('TimeData/TimeData-'+simID+'.txt',delim_whitespace=True) # Calculate non-time-dependent stats for this sim, and add to summary dr = d vrs = s tf = thisdir.t.iloc[-1] aBf = thisdir.aB.iloc[-1] eBf = thisdir.eB.iloc[-1] pBf = aBf*(1-eBf) apBf = aBf*(1+eBf) aCf = thisdir.aC.iloc[-1] eCf = thisdir.eC.iloc[-1] pCf = aCf*(1-eCf) apCf = aCf*(1+eCf) minpB = min(thisdir.pB) mintB = max(thisdir.t.iloc[Merc.which(thisdir.pB,minpB)]) if not all(np.isnan(thisdir.pC)): minpC = min(thisdir.pC) mintC = max(thisdir.t.iloc[Merc.which(thisdir.pC,minpC)]) elif '2' in s: minpC, mintC = np.nan, np.nan else: print('Warning: pC = nan, but subdir is {}, not a disk binary!'.format(s)) iMf = thisdir.iC.iloc[-1]-thisdir.iB.iloc[-1] rtrf = thisdir.rtr.iloc[-1] rpf = rtrf/pBf rpm = rtrf/minpB # make a dictionary of these stats, to enter as one line in the dataframe line = {} for c in cols: