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:
36 elif atom_meta[counter][
"type"] == 6:
39 elif atom_meta[counter][
"type"] == 8:
45 mlab.points3d(atom[0], atom[1], atom[2],
53 density_file_name = os.path.join(args.results_path,
"density.h5")
55 atoms_data_file = h5py.File(join(args.results_path,
"results.h5"))
56 atom_meta = atoms_data_file.get(
"atomMeta")[:]
57 atoms = atoms_data_file.get(
"state")[:]
58 atoms_data_file.close()
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(2, bgcolor=(1, 1, 1), size=(1280, 720))
71 data_max_min_diff = (data.max() - data.min())
73 contours = args.contours
75 contours = linspace(0.001,0.9,10).tolist()
76 iso = mlab.contour3d(X, Y, Z, data, vmin=contours[0], vmax=contours[-1], opacity=0.1013, contours=contours, colormap=
"GnBu", line_width=0.1)
78 mlab.savefig(os.path.join(output_dir,
"density.x3d"))
80 mlab.savefig(os.path.join(output_dir,
"density.png"))