def update_system_details(self, h5f):
        """
        Updates system element list, sources list, and entries
        in hdf5.

        Args:
            h5f: h5py object.
        """
        entries = np.asarray(self.entries)

        energy_indices = np.asarray([float(x) for x in entries[:, -1]])
        entries = entries[np.lexsort((energy_indices, entries[:, 3]))]
        entries = np.asarray([b';'.join(line) for line in entries])
        sources = np.string_(self.sources)
        write_to_group(h5f,
                       'system',
                       {'sys_elements': np.string_(self.sys_elements)}, {
                           'collated_entries': entries,
                           'collated_sources': sources
                       },
                       dset_types={
                           'collated_entries': entries.dtype,
                           'collated_sources': sources.dtype
                       },
                       maxshape=(None, ))
        self.summary()
    def to_file(self, filename):
        """
        Write preprocessed fingerprints to file.

        Args:
            filename (str): Output file (e.g. preprocessed.h5).
        """
        assert self.standards  # ensure preprocess_fingerprints() completed
        libver = self.settings['libver']
        with h5py.File(filename, 'w', libver=libver) as h5f:
            energies = np.asarray(self.m_energies)
            element_counts = np.asarray(self.m_element_counts)
            m_names = np.string_(self.m_names.tolist())
            write_to_group(h5f,
                           'preprocessed', {}, {
                               'energies': energies,
                               'element_counts': element_counts,
                               'all': self.all,
                               'm_names': m_names
                           },
                           dset_types={
                               'energies': energies.dtype,
                               'element_counts': element_counts.dtype,
                               'all': self.all.dtype,
                               'm_names': m_names.dtype
                           })

            scaling_standards = {
                'standard_{}'.format(j): standard
                for j, standard in enumerate(self.standards)
            }
            write_to_group(h5f, 'system',
                           {'sys_elements': np.string_(self.sys_elements)},
                           scaling_standards)
    def to_file(self, h5o, path):
        """
        Save collated molecule to file.

        Args:
            h5o: h5py object for writing.
            path (str): Path to molecule subgroup.
                e.g. 'molecules/au55.1.2'
        """
        write_to_group(h5o, path, self.attrs_dict, self.dsets_dict)
        data = [
            np.string_(path.split('/')[-1]),
            np.string_(str(np.sum(self.element_counts))),
            np.string_('-'.join([str(x) for x in self.element_counts])),
            np.string_(str(self.periodic)),
            np.string_(str(self.coords.shape).replace(',', '-')),
            np.string_(self.energy_val)
        ]
        return data
    def update_system_details(self, h5f):
        """
        Updates system element list, descriptor parameters, and entries
        in hdf5.

        Args:
            h5f: h5py object.
        """
        entries = np.asarray([b';'.join(entry) for entry in self.entries])
        write_to_group(h5f, 'system',
                       {'sys_elements': np.string_(self.sys_elements)}, {
                           'pair_params': self.parameters[0],
                           'triplet_params': self.parameters[1]
                       })

        write_to_group(h5f,
                       'system', {}, {'fingerprint_entries': entries},
                       dset_types={'fingerprint_entries': entries.dtype},
                       maxshape=(None, ))
        self.summary()
    def to_file(self, h5o, path):
        """
        Save fingerprint to file.

        Args:
            h5o: h5py object for writing.
            path (str): Path to molecule subgroup
                e.g. 'fingerprints/Au55.1.2'
        """
        write_to_group(h5o, path, self.attrs_dict, self.dsets_dict)
        data = [
            np.string_(path.split('/')[-1]),
            np.string_(str(self.natoms)),
            np.string_('-'.join(self.elements_set)),
            np.string_('-'.join([str(x) for x in self.element_counts])),
            self.fingerprint_shapes,
            np.string_(self.energy_val)
        ]

        return data