def _custom_traits(self): ''' Create creates for the atomic size (using the covalent radius) and atom colors (using the common `Jmol`_ color scheme). Note that that data is present in the static data (see :mod:`~exa.relational.isotope`). .. _Jmol: http://jmol.sourceforge.net/jscolors/ ''' self._set_categories() grps = self.groupby('frame') symbols = grps.apply(lambda g: g['symbol'].cat.codes.values) # Pass integers rather than string symbols symbols = Unicode(symbols.to_json(orient='values')).tag(sync=True) symmap = {i: v for i, v in enumerate(self['symbol'].cat.categories)} sym2rad = symbol_to_radius() radii = sym2rad[self['symbol'].unique()] radii = Dict({i: radii[v] for i, v in symmap.items()}).tag(sync=True) # (Int) symbol radii sym2col = symbol_to_color() colors = sym2col[self['symbol'].unique()] # Same thing for colors colors = Dict({i: colors[v] for i, v in symmap.items()}).tag(sync=True) try: atom_set = grps.apply(lambda g: g['set'].values).to_json(orient='values') atom_set = Unicode(atom_set).tag(sync=True) except KeyError: atom_set = Unicode().tag(sync=True) # Note that position traits (atom_x, atom_y, atom_z) are created automatically # since we have defined _traits = ['x', 'y', 'z'] above. return {'atom_symbols': symbols, 'atom_radii': radii, 'atom_colors': colors, 'atom_set': atom_set}
def _update_custom_traits(self): sgto = self.groupby('frame').apply(lambda x: x.groupby('l').apply( lambda y: y['ml'].values)) sgto = Unicode(sgto.to_json(orient='values')).tag(sync=True) return {'sphericalgtforder_ml': sgto}
def _update_custom_traits(self): coefs = self.groupby('frame').apply(lambda x: x.pivot('basis_function', 'orbital', 'coefficient').fillna(value=0).values) coefs = Unicode(coefs.to_json(orient='values')).tag(sync=True) #coefs = Unicode('[' + sq.groupby(by=sq.columns, axis=1).apply( # lambda x: x[x.columns[0]].values).to_json(orient='values') + ']').tag(sync=True) return {'momatrix_coefficient': coefs}