Exemplo n.º 1
0
 def write_pov(filename, atoms, run_povray=False, **parameters):
     p = {}
     for key in ['rotation', 'show_unit_cell', 'radii',
                 'bbox', 'colors', 'scale']:
         if key in parameters:
             p[key] = parameters[key]
     write_png(filename[:-3] + 'png', atoms, **p)
Exemplo n.º 2
0
 def write_pov(filename, atoms, run_povray=False, **parameters):
     p = {}
     for key in ['rotation', 'show_unit_cell', 'radii',
                 'bbox', 'colors', 'scale']:
         if key in parameters:
             p[key] = parameters[key]
     write_png(filename[:-3] + 'png', atoms, **p)
Exemplo n.º 3
0
def atoms2png(atoms, filename):
    if atoms:
        size = atoms.positions.ptp(0)
        i = size.argmin()
        rotation = ['-90y', '90x', ''][i]
        size[i] = 0.0
        scale = min(50, 200 / max(1, size.max()))
    else:
        scale = 20
        rotation = ''
    write_png(filename, atoms, rotation=rotation, scale=scale)
Exemplo n.º 4
0
def atoms2png(atoms, filename):
    if atoms:
        size = atoms.positions.ptp(0)
        i = size.argmin()
        rotation = ['-90y', '90x', ''][i]
        size[i] = 0.0
        scale = min(50, 200 / max(1, size.max()))
    else:
        scale = 20
        rotation = ''
    write_png(filename, atoms, show_unit_cell=1,
              rotation=rotation, scale=scale)
Exemplo n.º 5
0
Arquivo: plot.py Projeto: uu1477/MyAse
def atoms2png(atoms, filename):
    if atoms:
        size = atoms.positions.ptp(0)
        i = size.argmin()
        rotation = ['-90y', '90x', ''][i]
        size[i] = 0.0
        scale = min(20, 20 / size.max() * 10.0)
    else:
        scale = 20
        rotation = ''
    write_png(filename,
              atoms,
              show_unit_cell=1,
              rotation=rotation,
              scale=scale)
Exemplo n.º 6
0
        def write_pov(filename,
                      atoms,
                      povray_settings={},
                      isosurface_data=None,
                      **generic_projection_settings):

            write_png(
                Path(filename).with_suffix('.png'), atoms,
                **generic_projection_settings)

            class DummyRenderer:
                def render(self):
                    pass

            return DummyRenderer()
Exemplo n.º 7
0
def image(name):
    path = os.path.join(tmpdir, name).encode()
    if not os.path.isfile(path):
        id = int(name[:-4])
        atoms = db.get_atoms(id)
        if atoms:
            size = atoms.positions.ptp(0)
            i = size.argmin()
            rotation = ["-90y", "90x", ""][i]
            size[i] = 0.0
            scale = min(20, 20 / size.max() * 10.0)
        else:
            scale = 20
            rotation = ""
        write_png(path, atoms, show_unit_cell=1, rotation=rotation, scale=scale)
    return send_from_directory(tmpdir, name)
Exemplo n.º 8
0
def image(name):
    path = os.path.join(tmpdir, name).encode()
    if not os.path.isfile(path):
        id = int(name[:-4])
        atoms = connection.get_atoms(id)
        if atoms:
            size = atoms.positions.ptp(0)
            i = size.argmin()
            rotation = ['-90y', '90x', ''][i]
            size[i] = 0.0
            scale = min(20, 20 / size.max() * 10.0)
        else:
            scale = 20
            rotation = ''
        write_png(path,
                  atoms,
                  show_unit_cell=1,
                  rotation=rotation,
                  scale=scale)
    return send_from_directory(tmpdir, name)
Exemplo n.º 9
0
 def png(self, name):
     if not os.path.isfile(name):
         id = int(name[:-4])
         a = self.table.connection.get_atoms(id)
         write_png(name, a, show_unit_cell=1)
     return [open(name, 'rb').read()]