def load_CorSer(self,source): """ load CorSer file for simulation Parameters ---------- source : name of simulation file to be loaded """ if isinstance(source.B,Body): B=[source.B] elif isinstance(source.B,list): B=source.B elif isinstance(source.B,dict): B=source.B.values() else: raise AttributeError('CorSer.B must be a list or a Body') self.L=source.L self.traj = tr.Trajectories() self.traj.Lfilename=self.L.filename for b in B: self.dpersons.update({b.name: b}) self._tmin = b.time[0] self._tmax = b.time[-1] self.time = b.time self.traj.append(b.traj) for ap in source.din: techno,ID=ap.split(':') if techno == 'HKB': techno = 'hikob' if techno == 'TCR': techno = 'tcr' if techno == 'BS': techno = 'bespoon' self.dap.update({ap: {'pos': source.din[ap]['p'], 'ant': source.din[ap]['ant'], 'T': source.din[ap]['T'], 'name': techno } }) self.ctime = np.nan self.Nag = len(B) self.Nap = len(source.din) self.corser = source
def load_simul(self, source): """ load a simultraj configuration file Parameters ---------- source : string name of simulation file to be loaded """ self.filetraj = source if not os.path.isfile(source): raise AttributeError('Trajectory file' + source + 'has not been found.\ Please make sure you have run a simulnet simulation before runining simultraj.' ) # get the trajectory traj = tr.Trajectories() traj.loadh5(self.filetraj) # get the layout self.L = Layout(traj.Lfilename) # resample trajectory for ut, t in enumerate(traj): if t.typ == 'ag': person = Body(t.name + '.ini') tt = t.time() self.dpersons.update({t.name: person}) self._tmin = tt[0] self._tmax = tt[-1] self.time = tt else: pos = np.array([t.x[0], t.y[0], t.z[0]]) self.dap.update({ t.ID: { 'pos': pos, 'ant': antenna.Antenna(), 'name': t.name } }) self.ctime = np.nan self.Nag = len(self.dpersons.keys()) self.Nap = len(self.dap.keys()) self.traj = traj