args = parser.parse_args() dataset = args.dataset name = os.path.splitext(os.path.basename(dataset.name))[0] dataset_file_name = name + '.npz' dataset_exists = os.path.isfile(dataset_file_name) if dataset_exists and args.overwrite: print ui.info_str('[INFO]') + ' Overwriting existing dataset file.' if not dataset_exists or args.overwrite: print 'Writing dataset to \'%s\'...' % dataset_file_name else: sys.exit( ui.fail_str('[FAIL]') + ' Dataset \'%s\' already exists.' % dataset_file_name) R, z, E, F = read_concat_ext_xyz(dataset) # Base variables contained in every model file. base_vars = {'type': 'd',\ 'R': R,\ 'z': z,\ 'E': E[:,None],\ 'F': F,\ 'name': name,\ 'theory': 'unknown'} base_vars['md5'] = io.dataset_md5(base_vars) np.savez_compressed(dataset_file_name, **base_vars) print ui.pass_str('DONE')
ui.warn_str('[WARN]') + ' Incomplete output detected: Final dataset was pruned to %d points.' % n_mols) R = R[:n_mols, :, :] F = F[:n_mols, :, :] E = E[:n_mols] # Base variables contained in every model file. base_vars = { 'type': 'd', 'R': R, 'z': z, 'E': E[:, None], 'F': F, 'e_unit': 'kcal/mol', 'r_unit': 'Ang', 'name': name, 'theory': 'unknown', } base_vars['F_min'], base_vars['F_max'] = np.min(F.ravel()), np.max(F.ravel()) base_vars['F_mean'], base_vars['F_var'] = np.mean(F.ravel()), np.var(F.ravel()) base_vars['E_min'], base_vars['E_max'] = np.min(E), np.max(E) base_vars['E_mean'], base_vars['E_var'] = np.mean(E), np.var(E) base_vars['md5'] = io.dataset_md5(base_vars) np.savez_compressed(dataset_file_name, **base_vars) print(ui.pass_str('DONE'))
if not xyz_exists or args.overwrite: print('Writing dataset to \'%s\'...' % dataset_file_name) else: sys.exit( ui.fail_str('[FAIL]') + ' Dataset \'%s\' already exists.' % dataset_file_name ) z = dataset['z'] R = dataset['R'] F = dataset['F'] E = dataset['E'] n = R.shape[0] try: with open(dataset_file_name, 'w') as f: for i, r in enumerate(R): f.write(str(len(r)) + '\n' + str(np.squeeze(E[i]))) for j, atom in enumerate(r): f.write('\n' + io._z_to_z_str_dict[z[j]] + '\t') f.write('\t'.join(str(x) for x in atom) + '\t') f.write('\t'.join(str(x) for x in F[i][j])) f.write('\n') progr = float(i) / (n - 1) ui.progr_bar(i, n - 1, disp_str='Exporting %d data points...' % n) except IOError: sys.exit("ERROR: Writing xyz file failed.") print('\n' + ui.pass_str('DONE'))