Package empro :: Package toolkit :: Package results
[frames] | no frames]

Source Code for Package empro.toolkit.results

 1  # Copyright 1983-2017 Keysight Technologies, Inc  
 2   
3 -class UnavailableError(RuntimeError):
4 - def __init__(self, msg=""):
5 RuntimeError.__init__(self,msg)
6 7
8 -class Results(object):
9 - def __init__(self, project=None, simulation=None):
10 self._proj = project 11 if not self._proj: 12 import empro 13 self._proj = empro.activeProject.rootDir 14 self._sim = '%06d' % simulation if isinstance(simulation, int) else simulation 15 self._availableExcitationsToRun = None 16 self._engine = None 17 try: 18 import empro.toolkit.dataset 19 rawResult = empro.toolkit.dataset.getResult(self._proj, sim=self._sim, run='Run0001', object='System', timeDependence='SteadyState', result='NetInputPower') 20 simOutput = rawResult.query.getSimulation() 21 metaData = simOutput.metadata() 22 self._engine =metaData.engine() 23 except: 24 pass
25
26 - def _needsSimulation(func):
27 ''' 28 decorator to check for a simulation 29 ''' 30 def op(self, *args, **kwargs): 31 if not self._sim: 32 raise RuntimeError("No simulation specified") 33 return func(self, *args, **kwargs)
34 op.__name__ == func.__name__ 35 op.__doc__ == func.__doc__ 36 return op
37
38 - def availableExcitations(self):
39 import empro 40 sim = empro.toolkit._getCircuitMatrix(sim=self._sim) 41 excitations = [] 42 for i in range(sim.nbPorts()): 43 excitations.append(sim.portName(i)) 44 return excitations
45
46 - def _extractAvailableExcitationToRun(self, baseQuery):
47 if self._availableExcitationsToRun: 48 return 49 self._availableExcitationsToRun = {} 50 simOutput = baseQuery.getSimulation() 51 metaData= simOutput.metadata() 52 for i in range(metaData.numberOfRuns()): 53 portNames = metaData.activePortNames(i) 54 for portName in portNames: 55 self._availableExcitationsToRun[portName] = i
56
57 - def system(self, *args, **kwargs):
58 import system 59 if self._engine=="FemEngine": 60 return system.FemSystem(self, *args, **kwargs) 61 if self._engine=="FdtdEngine": 62 return system.FdtdSystem(self, *args, **kwargs) 63 raise UnavailableError("Unknown simulator")
64
65 - def sar(self, *args, **kwargs):
66 import sar 67 return sar.Sar(self,*args,**kwargs)
68
69 - def farField(self, sensorName, excitation):
70 """ 71 farField(sensorName, excitation) -> returns the farfield for the given sensor and circuit excitation 72 73 arguments: 74 @type sensorName: string 75 @param sensorName: the name of the farfield sensor 76 @type excitation: a map from string to voltage or current excitation 77 @param excitation: a map from port name to voltage or current excitation (example: {"p1": excitation.VoltageSource(V=1,load=excitation.ParallelRLC(50))} 78 """ 79 import far_field 80 return far_field.FarField(self, sensorName=sensorName, excitation=excitation)
81
82 - def nearField(self, *args, **kwargs):
83 import near_field 84 if self._engine=="FemEngine": 85 return near_field.FemNearField(self, *args, **kwargs) 86 raise UnavailableError("Unsupported simulator")
87
88 - def network(self):
89 """ 90 network() -> returns the network parameters 91 """ 92 import network 93 return network.Network(self)
94