Returns a slab with the adsorbates removed
424150
def cleaned_up_slab(self):
        
        ads_strs = list(self.ads_entries_dict.keys())
        cleaned = self.structure.copy()
        cleaned.remove_species(ads_strs)
        return cleaned
646714
def clean(self: 'TSelf', *, atol: float=1e-9) -> 'TSelf':
        """"""
        negligible = [v for v, c in self._terms.items() if abs(c) <= atol]
        for v in negligible:
            del self._terms[v]
        return self
1109396
def _get_struct_bevelfilter(self):
        """"""
        obj = _make_object("BevelFilter")
        obj.ShadowColor = self._get_struct_rgba()
        obj.HighlightColor = self._get_struct_rgba()
        obj.BlurX = unpack_fixed16(self._src)
        obj.BlurY = unpack_fixed16(self._src)
        obj.Angle = unpack_fixed16(self._src)
        obj.Distance = unpack_fixed16(self._src)
        obj.Strength = unpack_fixed8(self._src)
        bc = BitConsumer(self._src)
        obj.InnerShadow = bc.u_get(1)
        obj.Knockout = bc.u_get(1)
        obj.CompositeSource = bc.u_get(1)
        obj.OnTop = bc.u_get(1)
        obj.Passes = bc.u_get(4)
        return obj
1124600
def mw_wo_sw(mol, ndigits=2):
    
    cp = clone(mol)  # Avoid modification of original object
    remover.remove_water(cp)
    remover.remove_salt(cp)
    return round(sum(a.mw() for _, a in cp.atoms_iter()), ndigits)
1064688
def filter(self):
        

        val = {"geometryType":self.geometryType,
                "geometry": json.dumps(self._geomObject.asDictionary),
                "spatialRel": self.spatialRelation,
                "inSR" : self._geomObject.spatialReference['wkid']}
        if self._buffer is not None and \
           self._units is not None:
            val['buffer'] = self._buffer
            val['units'] = self._units
        return val
145098
def _apply_BCs(self):
        
        """
        if 'pore.bc_rate' in self.keys():
            # Update b
            ind = np.isfinite(self['pore.bc_rate'])
            self.b[ind] = self['pore.bc_rate'][ind]
        if 'pore.bc_value' in self.keys():
            f = np.abs(self.A.data).mean()
            # Update b (impose bc values)
            ind = np.isfinite(self['pore.bc_value'])
            self.b[ind] = self['pore.bc_value'][ind] * f
            # Update b (substract quantities from b to keep A symmetric)
            x_BC = np.zeros(self.b.shape)
            x_BC[ind] = self['pore.bc_value'][ind]
            self.b[~ind] -= (self.A.tocsr() * x_BC)[~ind]
            # Update A
            P_bc = self.toindices(ind)
            indrow = np.isin(self.A.row, P_bc)
            indcol = np.isin(self.A.col, P_bc)
            self.A.data[indrow] = 0  # Remove entries from A for all BC rows
            self.A.data[indcol] = 0  # Remove entries from A for all BC cols
            datadiag = self.A.diagonal()  # Add diagonal entries back into A
            datadiag[P_bc] = np.ones_like(P_bc, dtype=np.float64) * f
            self.A.setdiag(datadiag)
            self.A.eliminate_zeros()
1318069
def nextindx(self):
        '''
        
        '''
        indx = 0
        with s_lmdbslab.Scan(self.slab, self.db) as curs:
            last_key = curs.last_key()
            if last_key is not None:
                indx = s_common.int64un(last_key) + 1
        return indx
673070
def src_filter(self):
        
        oq = self.oqparam
        self.hdf5cache = self.datastore.hdf5cache()
        sitecol = self.sitecol.complete if self.sitecol else None
        if 'ucerf' in oq.calculation_mode:
            return UcerfFilter(sitecol, oq.maximum_distance, self.hdf5cache)
        return SourceFilter(sitecol, oq.maximum_distance, self.hdf5cache)
1353529
def to_pb(self):
        
        interleave = data_v2_pb2.RowFilter.Interleave(
            filters=[row_filter.to_pb() for row_filter in self.filters]
        )
        return data_v2_pb2.RowFilter(interleave=interleave)
1025781
def get_SZ(self, psd, geometry):
        
        if (self._S_table is None) or (self._Z_table is None):
            raise AttributeError(
                "Initialize or load the scattering table first.")

        if (not isinstance(psd, PSD)) or self._previous_psd != psd:
            self._S_dict = {}
            self._Z_dict = {}
            psd_w = psd(self._psd_D)

            for geom in self.geometries:
                self._S_dict[geom] = \
                    trapz(self._S_table[geom] * psd_w, self._psd_D)
                self._Z_dict[geom] = \
                    trapz(self._Z_table[geom] * psd_w, self._psd_D)

            self._previous_psd = psd

        return (self._S_dict[geometry], self._Z_dict[geometry])
433372
def organize(**kwargs):
    """"""

    # do argument wrangling  before turning it into an obect
    # since namedtuples are immutable
    if len(kwargs['adsorbates']) == 0:
        print("""Warning: no adsorbates specified,
        can't pick up reaction reaction energies.""")
        print("         Enter adsorbates like so --adsorbates CO,O,CO2")
        print("         [Comma-separated list without spaces.]")
    kwargs['adsorbates'] = list(map(
        lambda x: (''.join(sorted(string2symbols(x)))),
        kwargs['adsorbates'].split(','),
    ))
    if kwargs['energy_corrections']:
        e_c_dict = {}
        for e_c in kwargs['energy_corrections'].split(','):
            key, value = e_c.split('=')
            e_c_dict.update({key: float(value)})
        kwargs['energy_corrections'] = e_c_dict

    options = collections.namedtuple(
        'options',
        kwargs.keys()
    )(**kwargs)
    _organize.main(options=options)
157
def get_labels(self, plt, label_fontsize=10):
        

        # center of vacuum and bulk region
        if len(self.slab_regions) > 1:
            label_in_vac = (self.slab_regions[0][1] + self.slab_regions[1][0])/2
            if abs(self.slab_regions[0][0]-self.slab_regions[0][1]) > \
                    abs(self.slab_regions[1][0]-self.slab_regions[1][1]):
                label_in_bulk = self.slab_regions[0][1]/2
            else:
                label_in_bulk = (self.slab_regions[1][1] + self.slab_regions[1][0]) / 2
        else:
            label_in_bulk = (self.slab_regions[0][0] + self.slab_regions[0][1])/2
            if self.slab_regions[0][0] > 1-self.slab_regions[0][1]:
                label_in_vac = self.slab_regions[0][0] / 2
            else:
                label_in_vac = (1 + self.slab_regions[0][1]) / 2

        plt.plot([0, 1], [self.vacuum_locpot]*2, 'b--', zorder=-5, linewidth=1)
        xy = [label_in_bulk, self.vacuum_locpot+self.ave_locpot*0.05]
        plt.annotate(r"$V_{vac}=%.2f$" %(self.vacuum_locpot), xy=xy,
                     xytext=xy, color='b', fontsize=label_fontsize)

        # label the fermi energy
        plt.plot([0, 1], [self.efermi]*2, 'g--',
                 zorder=-5, linewidth=3)
        xy = [label_in_bulk, self.efermi+self.ave_locpot*0.05]
        plt.annotate(r"$E_F=%.2f$" %(self.efermi), xytext=xy,
                     xy=xy, fontsize=label_fontsize, color='g')

        # label the bulk-like locpot
        plt.plot([0, 1], [self.ave_bulk_p]*2, 'r--', linewidth=1., zorder=-1)
        xy = [label_in_vac, self.ave_bulk_p + self.ave_locpot * 0.05]
        plt.annotate(r"$V^{interior}_{slab}=%.2f$" % (self.ave_bulk_p),
                     xy=xy, xytext=xy, color='r', fontsize=label_fontsize)

        # label the work function as a barrier
        plt.plot([label_in_vac]*2, [self.efermi, self.vacuum_locpot],
                 'k--', zorder=-5, linewidth=2)
        xy = [label_in_vac, self.efermi + self.ave_locpot * 0.05]
        plt.annotate(r"$\Phi=%.2f$" %(self.work_function),
                     xy=xy, xytext=xy, fontsize=label_fontsize)

        return plt
958165
def _apply_2d(self, func, axis):
        
        ndim = self.ndim
        axis = [self._get_axis_number(a) for a in axis]

        # construct slabs, in 2-d this is a DataFrame result
        indexer_axis = list(range(ndim))
        for a in axis:
            indexer_axis.remove(a)
        indexer_axis = indexer_axis[0]

        slicer = [slice(None, None)] * ndim
        ax = self._get_axis(indexer_axis)

        results = []
        for i, e in enumerate(ax):
            slicer[indexer_axis] = i
            sliced = self.iloc[tuple(slicer)]

            obj = func(sliced)
            results.append((e, obj))

        return self._construct_return_type(dict(results))
1070962
def pruneToAtoms(self, atoms):
        """"""
        _atoms = self.atoms[:]
        for atom in _atoms:
            if atom not in atoms:
                self.remove_atom(atom)
525741
def tile(self, z_x_y):
        
        (z, x, y) = z_x_y
        logger.debug(_("tile method called with %s") % ([z, x, y]))

        output = self.cache.read((z, x, y))
        if output is None:
            output = self.reader.tile(z, x, y)
            # Blend layers
            if len(self._layers) > 0:
                logger.debug(_("Will blend %s layer(s)") % len(self._layers))
                output = self._blend_layers(output, (z, x, y))
            # Apply filters
            for f in self._filters:
                image = f.process(self._tile_image(output))
                output = self._image_tile(image)
            # Save result to cache
            self.cache.save(output, (z, x, y))

            self.rendered += 1
        return output
538353
def _get_struct_glowfilter(self):
        """"""
        obj = _make_object("GlowFilter")
        obj.GlowColor = self._get_struct_rgba()
        obj.BlurX = unpack_fixed16(self._src)
        obj.BlurY = unpack_fixed16(self._src)
        obj.Strength = unpack_fixed8(self._src)
        bc = BitConsumer(self._src)
        obj.InnerGlow = bc.u_get(1)
        obj.Knockout = bc.u_get(1)
        obj.CompositeSource = bc.u_get(1)
        obj.Passes = bc.u_get(5)
        return obj
44562
def deconstruct(self):
        """"""
        return (
            self.__class__.__name__,
            [],
            {
                'process': self.process,
                'field': self._raw_field,
                'new_field': self.new_field,
            }
        )