def fetch(self, sim="current", type="default", unit="default"): if sim=="current": sim=SimBuffer.get_current_sim() elif isinstance(sim,int): sim=SimBuffer.get_sim_no(sim) iterator = SimBuffer.get_sim_iterator(sim) results = map(lambda snap: self._function(snap,type=type,unit=unit,**self._kwargs),iterator) if isinstance(results[0],list) or isinstance(results[0],tuple): results_zipped = zip(*results) values = np.asarray(results_zipped[1]) return results_zipped[0][0], values, results_zipped[2][0], results_zipped[3][0] else: values=np.asarray(results) if isinstance(self.scaling_factor,basestring): try: unitobj=getattr(sim.simunits, self.scaling_factor) if unit=="default": unit=unitobj.outunit scaling_factor=unitobj.OutputScale(unit) self.unitinfo.name=unit self.unitinfo.label=unitobj.LatexLabel(unit) except AttributeError: raise AttributeError("Sorry, we do not know the unit " + self.scaling_factor) else: scaling_factor=float(self.scaling_factor) self.unitinfo.label=self.unitlabel self.unitinfo.name=self.unitname return self.unitinfo, values, scaling_factor, self.label
def get_sim(self): '''Retrieves from the buffer the desidered sim''' sim = SimBuffer.get_sim_no(self.sim) if not sim.setup: raise Exception("""Error: this simulation has not been set up! / If you have set all the relevant parameters initial conditions, / please run the setupsim command to set it up.""") return sim
def get_sim(self): '''Retrieves from the buffer the desidered sim''' sim = SimBuffer.get_sim_no(self.sim) if not sim.setup: raise Exception("""Error: this simulation has not been set up! / If you have set all the relevant parameters initial conditions, / please run the setupsim command to set it up.""") return sim
def fetch(self, sim="current", type="default", unit="default"): if sim=="current": sim=SimBuffer.get_current_sim() elif isinstance(sim,int): sim=SimBuffer.get_sim_no(sim) iterator = SimBuffer.get_sim_iterator(sim) results = map(lambda snap: self._function(snap,*self._args,type=type,unit=unit,**self._kwargs),iterator) results_zipped = zip(*results) values = np.asarray(results_zipped[1]) return results_zipped[0][0], values, results_zipped[2][0], results_zipped[3][0]
def fetch(self, sim="current", type="default", unit="default"): if sim == "current": sim = SimBuffer.get_current_sim() elif isinstance(sim, int): sim = SimBuffer.get_sim_no(sim) iterator = SimBuffer.get_sim_iterator(sim) results = map( lambda snap: self._function( snap, type=type, unit=unit, **self._kwargs), iterator) if isinstance(results[0], list) or isinstance(results[0], tuple): results_zipped = zip(*results) values = np.asarray(results_zipped[1]) return results_zipped[0][0], values, results_zipped[2][ 0], results_zipped[3][0] else: values = np.asarray(results) if isinstance(self.scaling_factor, basestring): try: unitobj = getattr(sim.simunits, self.scaling_factor) if unit == "default": unit = unitobj.outunit scaling_factor = unitobj.OutputScale(unit) self.unitinfo.name = unit self.unitinfo.label = unitobj.LatexLabel(unit) except AttributeError: raise AttributeError("Sorry, we do not know the unit " + self.scaling_factor) else: scaling_factor = float(self.scaling_factor) self.unitinfo.label = self.unitlabel self.unitinfo.name = self.unitname return self.unitinfo, values, scaling_factor, self.label