base_vars = { 'type': 'd', 'name': dataset['name'].astype(str), 'theory': dataset['theory'].astype(str), 'z': dataset['z'], 'R': R, 'E': E, 'F': F, } base_vars['md5'] = io.dataset_md5(base_vars) subset_file_name = '%s_%s.npz' % ( os.path.splitext(os.path.basename(dataset_path))[0], s, ) file_exists = os.path.isfile(subset_file_name) if file_exists and args.overwrite: print(ui.info_str('[INFO]') + ' Overwriting existing model file.') if not file_exists or args.overwrite: np.savez_compressed(subset_file_name, **base_vars) ui.progr_toggle(is_done=True, disp_str='Extracted %s dataset saved to \'%s\'' % (s, subset_file_name)) else: print( ui.warn_str('[WARN]') + ' %s dataset \'%s\' already exists.' % (s.capitalize(), subset_file_name) + '\n Run \'python %s -o %s %s\' to overwrite.\n' % (os.path.basename(__file__), model_path, dataset_path)) sys.exit()
base_vars = { 'type': 'd', 'name': dataset['name'].astype(str), 'theory': dataset['theory'].astype(str), 'z': dataset['z'], 'R': R, 'E': E, 'F': F, } base_vars['md5'] = io.dataset_md5(base_vars) subset_file_name = '%s_%s.npz' % ( os.path.splitext(os.path.basename(dataset_path))[0], s, ) file_exists = os.path.isfile(subset_file_name) if file_exists and args.overwrite: print(ui.info_str('[INFO]') + ' Overwriting existing model file.') if not file_exists or args.overwrite: np.savez_compressed(subset_file_name, **base_vars) ui.progr_toggle(is_done=True, disp_str='Extracted %s dataset saved to \'%s\'' % (s, subset_file_name)) else: print( ui.warn_str('[WARN]') + ' %s dataset \'%s\' already exists.' % (s.capitalize(), subset_file_name) + '\n Run \'python %s -o %s %s\' to overwrite.\n' % (os.path.basename(__file__), model_path, dataset_path) ) sys.exit()
' Dataset \'%s\' already exists.' % dataset_file_name) print 'Reading geometries...' R, z = read_concat_xyz(geometries) print 'Reading forces...' F, _ = read_concat_xyz(forces) print 'Reading energies from column %d...' % energy_col E = read_out_file(energies, energy_col) # Prune all arrays to same length. n_mols = min(min(R.shape[0], F.shape[0]), E.shape[0]) if n_mols != R.shape[0] or n_mols != F.shape[0] or n_mols != E.shape[0]: print 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] print ui.info_str( '[INFO]') + ' Geometries, forces and energies must have consistent units.' R_conv_fact = raw_input_float('Unit conversion factor for geometries: ') R = R * R_conv_fact F_conv_fact = raw_input_float('Unit conversion factor for forces: ') F = F * F_conv_fact E_conv_fact = raw_input_float('Unit conversion factor for energies: ') E = E * E_conv_fact # Base variables contained in every model file.