diff --git a/postpic/_compat/functions.py b/postpic/_compat/functions.py index 8fcce24..c03a72c 100644 --- a/postpic/_compat/functions.py +++ b/postpic/_compat/functions.py @@ -24,7 +24,7 @@ import numpy as np import scipy as sp -import scipy.signal as sps +import scipy.signal.windows as sps import collections try: diff --git a/postpic/datahandling.py b/postpic/datahandling.py index 505b9b3..6d63a53 100644 --- a/postpic/datahandling.py +++ b/postpic/datahandling.py @@ -2016,10 +2016,10 @@ def fft(self, axes=None, exponential_signs='spatial', old_behaviour=False, **kwa dx = {i: self.axes[i].spacing for i in axes} # Unit volume of transform - dV = np.product(list(dx.values())) + dV = np.prod(list(dx.values())) # Number of grid cells of transform - N = np.product([self.shape[i] for i in axes]) + N = np.prod([self.shape[i] for i in axes]) # Total volume of transform V = dV*N diff --git a/postpic/particles/_routines.py b/postpic/particles/_routines.py index 2b77f53..8424941 100644 --- a/postpic/particles/_routines.py +++ b/postpic/particles/_routines.py @@ -189,13 +189,35 @@ def _specdict(mass, charge, ision): 'gold20': _specdict(1836.2 * 197, 20, True)} # unit: amu - _masslistelement = {'H': 1, 'He': 4, - 'Li': 6.9, 'C': 12, 'N': 14, 'O': 16, 'F': 19, 'Ne': 20.2, - 'Na': 23, 'Al': 27, 'Si': 28, 'S': 32, 'Cl': 35.5, 'Ar': 40, - 'Ti': 47.9, 'Cr': 52, 'Fe': 55.8, 'Cu': 63.5, 'Zn': 65.4, 'Kr': 83.8, - 'Rb': 85.5, 'Zr': 91.2, 'Pd': 106.4, 'Ag': 107.8, 'Sn': 118.7, - 'Xe': 131.3, - 'W': 183.8, 'Pt': 195, 'Au': 197, 'Hg': 200.6, 'Pb': 207.2} + _masslistelement = {'H': 1.008, 'He': 4.003, 'Li': 6.941, 'Be': 9.012, + 'B': 10.811, 'C': 12.011, 'N': 14.007, 'O': 15.999, + 'F': 18.998, 'Ne': 20.180, 'Na': 22.990, 'Mg': 24.305, + 'Al': 26.982, 'Si': 28.086, 'P': 30.974, 'S': 32.066, + 'Cl': 35.453, 'Ar': 39.948, 'K': 39.098, 'Ca': 40.078, + 'Sc': 44.956, 'Ti': 47.867, 'V': 50.942, 'Cr': 51.996, + 'Mn': 54.938, 'Ff': 55.845, 'Co': 58.933, 'Ni': 58.693, + 'Cu': 63.546, 'Zn': 65.38, 'Ga': 69.723, 'Ge': 72.631, + 'As': 74.922, 'Se': 78.971, 'Br': 79.904, 'Kr': 84.798, + 'Rb': 84.468, 'Sr': 87.62, 'Y': 88.906, 'Zr': 91.224, + 'Nb': 92.906, 'Mo': 95.95, 'Tc': 98.907, 'Ru': 101.07, + 'Rh': 102.906, 'Pd': 106.42, 'Ag': 107.868, 'Cd': 112.414, + 'In': 114.818, 'Sm': 118.711, 'Sb': 121.760, 'Te': 126.7, + 'I': 126.904, 'Xe': 131.294, 'Cs': 132.905, 'Ba': 137.328, + 'La': 138.905, 'Ce': 140.116, 'Pr': 140.908, 'Nd': 144.243, + 'Pm': 144.913, 'Sm': 150.36, 'Eu': 151.964, 'Gd': 157.25, + 'Tb': 158.925, 'Dy': 162.500, 'Ho': 164.930, 'Er': 167.259, + 'Tm': 168.934, 'Yb': 173.055, 'Lu': 174.967, 'Hf': 178.49, + 'Ta': 180.948, 'W': 183.84, 'Rr': 186.207, 'Os': 190.23, + 'Ir': 192.217, 'Pt': 195.085, 'Au': 196.967, 'Hg': 200.592, + 'Tl': 204.383, 'Pb': 207.2, 'Bi': 208.980, 'Po': 208.982, + 'At': 209.987, 'Rn': 222.081, 'Fr': 223.020, 'Ra': 226.025, + 'Ac': 227.028, 'Th': 232.038, 'Pa': 231.036, 'U': 238.029, + 'Np': 237, 'Pu': 244, 'Am': 243, 'Cm': 247, 'Bk': 247, + 'Ct': 251, 'Es': 252, 'Fm': 257, 'Md': 258, 'No': 259, + 'Lr': 262, 'Rf': 261, 'Db': 262, 'Sg': 266, 'Bh': 264, + 'Hs': 269, 'Mt': 268, 'Ds': 271, 'Rg': 272, 'Cn': 285, + 'Nh': 284, 'Fl': 289, 'Mc': 288, 'Lv': 292, 'Ts': 294, + 'Og': 294} @staticmethod def isejected(species): diff --git a/postpic/particles/particles.py b/postpic/particles/particles.py index c408cbc..e177f92 100644 --- a/postpic/particles/particles.py +++ b/postpic/particles/particles.py @@ -145,7 +145,7 @@ def _readatomic(self, key): ret = self._dumpreader.getSpecies(self.species, key) # now that we have got the data, check if compress was used and/or maybe cache value ret = np.int64(ret) if key == 'id' else np.float64(ret) - if ret.shape is (): # cache single scalars always + if ret.shape == (): # cache single scalars always self._cache[key] = ret elif self._compressboollist is not None: ret = ret[self._compressboollist] # avoid executing this line too often. @@ -227,7 +227,7 @@ def _compress_bool(self, condition): else: ret._compressboollist[ret._compressboollist] = condition for key in ret._cache: - if ret._cache[key].shape is not (): + if ret._cache[key].shape != (): ret._cache[key] = ret._cache[key][condition] return ret @@ -257,7 +257,7 @@ def __invert__(self): ret._cache = {} # clear cache if self._compressboollist is None: ret._compressboollist = np.asarray(False) - elif self._compressboollist.shape is () and bool(self._compressboollist) is False: + elif self._compressboollist.shape == () and bool(self._compressboollist) is False: ret._compressboollist = None else: ret._compressboollist = ~self._compressboollist @@ -267,7 +267,7 @@ def __invert__(self): # --- Only very basic functions def __len__(self): # = number of particles - # find a valid dataset to count number of paricles + # find a valid dataset to count number of particles # return 0 if no valid dataset can be found ret = 0 if self._compressboollist is not None: @@ -662,7 +662,7 @@ def __call_sp(self, sp): # sp MUST be ScalarProperty def ssdata(ss): a = ss(sp) - if a.shape is (): + if a.shape == (): a = np.repeat(a, len(ss)) return a if len(self._ssas) == 0: diff --git a/test/test_helper.py b/test/test_helper.py index 53e9358..0aeb63d 100755 --- a/test/test_helper.py +++ b/test/test_helper.py @@ -25,14 +25,14 @@ def checkion(self, data, m, c, eject, tracer, ision): def test_identifyspecies_ion(self): idfy = pp.identifyspecies self.checkion(idfy('proton'), 1, 1, False, False, True) - self.checkion(idfy('H1'), 1, 1, False, False, True) - self.checkion(idfy('tracer_O3'), 16, 3, False, True, True) - self.checkion(idfy('ejected_tracer_C4'), 12, 4, True, True, True) + self.checkion(idfy('H1'), 1.008, 1, False, False, True) + self.checkion(idfy('tracer_O3'), 15.999, 3, False, True, True) + self.checkion(idfy('ejected_tracer_C4'), 12.011, 4, True, True, True) self.checkion(idfy('ionm3c7'), 3, 7, False, False, True) self.checkion(idfy('ionm30c70xx5'), 30, 70, False, False, True) - self.checkion(idfy('tracer_ejected_Au27a'), 197, 27, True, True, True) - self.checkion(idfy('ejected_tracer_Au27'), 197, 27, True, True, True) - self.checkion(idfy('tracer_blahh_Au27x'), 197, 27, False, True, True) + self.checkion(idfy('tracer_ejected_Au27a'), 196.967, 27, True, True, True) + self.checkion(idfy('ejected_tracer_Au27'), 196.967, 27, True, True, True) + self.checkion(idfy('tracer_blahh_Au27x'), 196.967, 27, False, True, True) def test_identifyspecies_electron(self): idfy = pp.identifyspecies @@ -58,17 +58,17 @@ def test_identifyspecies_praefix(self): self.assertEqual(x['w'], True) self.assertEqual(x['33'], True) self.assertEqual(x['He5'], True) - self.checkion(x, 16,3, False, True, True) + self.checkion(x, 15.999,3, False, True, True) def test_identifyspecies_extendedsyntax(self): idfy = pp.identifyspecies - self.checkion(idfy('H'), 1, 0, False, False, True) - self.checkion(idfy('HPlus'), 1, 1, False, False, True) - self.checkion(idfy('H1Plus'), 1, 1, False, False, True) + self.checkion(idfy('H'), 1.008, 0, False, False, True) + self.checkion(idfy('HPlus'), 1.008, 1, False, False, True) + self.checkion(idfy('H1Plus'), 1.008, 1, False, False, True) #self.checkion(idfy('Hplus'), 1, 1, False, False, True) - self.checkion(idfy('HePlusPlus'), 4, 2, False, False, True) - self.checkion(idfy('He2Plus'), 4, 2, False, False, True) - self.checkion(idfy('HPlus'), 1, 1, False, False, True) + self.checkion(idfy('HePlusPlus'), 4.003, 2, False, False, True) + self.checkion(idfy('He2Plus'), 4.003, 2, False, False, True) + self.checkion(idfy('HPlus'), 1.008, 1, False, False, True) self.checke(idfy('HElectron'), 1, -1, False, False, False) self.checke(idfy('HElectrons'), 1, -1, False, False, False) self.checke(idfy('HElec'), 1, -1, False, False, False) @@ -81,10 +81,10 @@ def test_falsefriends(self): self.checke(idfy('HElectron'), 1, -1, False, False, False) self.checke(idfy('HeElectron'), 1, -1, False, False, False) self.checke(idfy('Heelectron'), 1, -1, False, False, False) - self.checkion(idfy('Helectron'), 4, 0, False, False, True) + self.checkion(idfy('Helectron'), 4.003, 0, False, False, True) # Tiny differences may decide about Ne or electrons self.checke(idfy('NElectron'), 1, -1, False, False, False) - self.checkion(idfy('Nelectron'), 20.2, 0, False, False, True) + self.checkion(idfy('Nelectron'), 20.180, 0, False, False, True) self.checke(idfy('Neelectron'), 1, -1, False, False, False)