Skip to content

Instantly share code, notes, and snippets.

@stetie
Created October 9, 2017 08:52
Show Gist options
  • Save stetie/6c0931def740815236ab0a8330598247 to your computer and use it in GitHub Desktop.
Save stetie/6c0931def740815236ab0a8330598247 to your computer and use it in GitHub Desktop.
postpic error
---------------------------------------------------------------------------
KeyError Traceback (most recent call last)
postpic/postpic/particles/particles.py in _readatomic(self, key)
115 try:
--> 116 ret = self._dumpreader.getSpecies(self.species, key)
117 except(KeyError):
postpic/postpic/datareader/epochsdf.py in getSpecies(self, species, attrib)
173 try:
--> 174 ret = options[attribid](species)
175 except(IndexError):
postpic/postpic/datareader/epochsdf.py in <lambda>(s)
170 10: lambda s: self['Particles/ID/' + s].data,
--> 171 11: lambda s: self['Particles/Mass/' + s].data,
172 12: lambda s: self['Particles/Charge/' + s].data}
postpic/postpic/datareader/epochsdf.py in __getitem__(self, key)
76 def __getitem__(self, key):
---> 77 return self._data[key]
78
KeyError: 'Particles/Mass/Proton'
During handling of the above exception, another exception occurred:
KeyError Traceback (most recent call last)
<ipython-input-19-cc8238eb6e52> in <module>()
1 pas = [MS(dump, s) for s in dump.listSpecies()]
2 for pa in pas:
----> 3 numberdensity = pa.createField('x', 'y', weights='Ekin_MeV')
4 p = plotter.plotField(numberdensity)
postpic/postpic/particles/particles.py in createField(self, *scalarf, **kwargs)
1218 return self.createHistgramField1d(*scalarf, **kwargs)
1219 elif len(scalarf) == 2:
-> 1220 return self.createHistgramField2d(*scalarf, **kwargs)
1221 elif len(scalarf) == 3:
1222 return self.createHistgramField3d(*scalarf, **kwargs)
postpic/postpic/particles/particles.py in createHistgramField2d(self, spx, spy, name, title, **kwargs)
1142 if 'weights' in kwargs:
1143 name = _findscalarattr(kwargs['weights'], 'name')
-> 1144 h, xedges, yedges = self._createHistgram2d(spx, spy, **kwargs)
1145 ret = Field(h, xedges, yedges)
1146 ret.axes[0].grid_node = xedges
postpic/postpic/particles/particles.py in _createHistgram2d(self, spx, spy, optargsh, simextent, simgrid, rangex, rangey, weights, force)
995 if rangey is None:
996 rangey = [np.min(ydata), np.max(ydata)]
--> 997 w = self('weight * ({})'.format(weights)) # Particle Size * additional weights
998 h, xedges, yedges = histogramdd((xdata, ydata),
999 weights=w, range=[rangex, rangey],
postpic/postpic/particles/particles.py in __call__(self, expr)
545 # create temporary ScalarProperty object
546 sp = particle_scalars(expr)
--> 547 return self.__call_sp(sp)
548 else:
549 return self.__call_func(expr)
postpic/postpic/particles/particles.py in __call_sp(self, sp)
561 return np.array([])
562 data = (ssdata(ss) for ss in self._ssas)
--> 563 return np.hstack(data)
564
565 def __call_func(self, func):
/usr/lib/python3/dist-packages/numpy/core/shape_base.py in hstack(tup)
273
274 """
--> 275 arrs = [atleast_1d(_m) for _m in tup]
276 # As a special case, dimension 0 of 1-dimensional arrays is "horizontal"
277 if arrs[0].ndim == 1:
/usr/lib/python3/dist-packages/numpy/core/shape_base.py in <listcomp>(.0)
273
274 """
--> 275 arrs = [atleast_1d(_m) for _m in tup]
276 # As a special case, dimension 0 of 1-dimensional arrays is "horizontal"
277 if arrs[0].ndim == 1:
postpic/postpic/particles/particles.py in <genexpr>(.0)
560 # ignore_missing_species = True.
561 return np.array([])
--> 562 data = (ssdata(ss) for ss in self._ssas)
563 return np.hstack(data)
564
postpic/postpic/particles/particles.py in ssdata(ss)
552 # sp MUST be ScalarProperty
553 def ssdata(ss):
--> 554 a = ss(sp)
555 if a.shape is ():
556 a = np.repeat(a, len(ss))
postpic/postpic/particles/particles.py in __call__(self, sp, _vars)
258 if not isinstance(sp, ScalarProperty):
259 raise TypeError('Argument must be a ScalarProperty object')
--> 260 return self._eval_single_sp(sp, _vars=_vars)
261
262
postpic/postpic/particles/particles.py in _eval_single_sp(self, sp, _vars)
243 continue
244 if name in particle_scalars: # the public list of scalar values
--> 245 _vars[name] = self._eval_single_sp(particle_scalars[name], _vars=_vars)
246 continue
247 for source in [np, scipy.constants]:
/postpic/postpic/particles/particles.py in _eval_single_sp(self, sp, _vars)
243 continue
244 if name in particle_scalars: # the public list of scalar values
--> 245 _vars[name] = self._eval_single_sp(particle_scalars[name], _vars=_vars)
246 continue
247 for source in [np, scipy.constants]:
postpic/postpic/particles/particles.py in _eval_single_sp(self, sp, _vars)
243 continue
244 if name in particle_scalars: # the public list of scalar values
--> 245 _vars[name] = self._eval_single_sp(particle_scalars[name], _vars=_vars)
246 continue
247 for source in [np, scipy.constants]:
postpic/postpic/particles/particles.py in _eval_single_sp(self, sp, _vars)
243 continue
244 if name in particle_scalars: # the public list of scalar values
--> 245 _vars[name] = self._eval_single_sp(particle_scalars[name], _vars=_vars)
246 continue
247 for source in [np, scipy.constants]:
postpic/postpic/particles/particles.py in _eval_single_sp(self, sp, _vars)
240 continue
241 if fullname in self._atomicprops:
--> 242 _vars[name] = getattr(self, fullname)()
243 continue
244 if name in particle_scalars: # the public list of scalar values
postpic/postpic/particles/particles.py in ret(_self)
87 def makefunc(_self, key):
88 def ret(_self):
---> 89 return _self._readatomic(key)
90 return ret
91 for key in self._atomicprops:
postpic/postpic/particles/particles.py in _readatomic(self, key)
118 # in the special case of mass or charge try to deduce mass or charge
119 # from the species name.
--> 120 self._idfy = identifyspecies(self.species)
121 ret = self._idfy[key]
122 else:
postpic/postpic/helper.py in identifyspecies(cls, species)
270 if regexdict['elem']:
271 ret['mass'] = float(cls._masslistelement[regexdict['elem']]) * \
--> 272 1836.2 * cls.me
273 if regexdict['elem_c'] == '':
274 ret['charge'] = 0
KeyError: 'Pr'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment