3 from mayavi
import mlab
4 from os.path
import join
6 from argparse
import ArgumentParser
11 parser = ArgumentParser()
12 parser.add_argument(
"results_path")
13 parser.add_argument(
"--contours", nargs=
"+", type=float)
14 parser.add_argument(
"--id", nargs=
'?', default=
"tmp")
15 args = parser.parse_args()
21 from sumatra.projects
import load_project
22 output_dir = os.path.join(os.path.abspath(load_project().data_store.root), args.id)
26 if not os.path.exists(output_dir):
27 os.makedirs(output_dir)
33 if atom_meta[counter][
"type"] == 1:
35 elif atom_meta[counter][
"type"] == 8:
39 mlab.points3d(atom[0], atom[1], atom[2],
48 atoms_data_file = h5py.File(join(args.results_path,
"results.h5"))
49 atom_meta = atoms_data_file.get(
"atomMeta")[:]
50 atoms = atoms_data_file.get(
"state")[:]
51 atoms_data_file.close()
54 contours = args.contours
56 contours = linspace(0.001,0.9,10).tolist()
59 for density_file_name
in glob(os.path.join(args.results_path,
"orbital_density_*.h5")):
60 density_file = h5py.File(density_file_name)
61 data = density_file.get(
"dataset")[:]
64 print "Data min,max:",data.min(),data.max()
66 X,Y,Z = mgrid[-3:3:1j*data.shape[0], -3:3:1j*data.shape[1], -3:3:1j*data.shape[2]]
68 mlab.figure(bgcolor=(0, 0, 0), size=(1280, 720))
71 data_max_min_diff = (data.max() - data.min())
72 iso = mlab.contour3d(X, Y, Z, data, vmin=contours[0], vmax=contours[-1], opacity=0.5, contours=contours)
74 mlab.savefig(os.path.join(output_dir,
"orbital_density_" + str(counter) +
".png"))
75 mlab.savefig(os.path.join(output_dir,
"orbital_density_" + str(counter) +
".x3d"))