Commit 56439762 authored by Martin Kuban's avatar Martin Kuban
Browse files

fixes for section_dos_fingerprint

parent dbf6b623
Pipeline #76615 failed with stages
in 4 minutes and 55 seconds
......@@ -1219,7 +1219,7 @@ class section_dos_fingerprint(MSection):
a_legacy=LegacyDefinition(name='bins'))
indices = Quantity(
type=int,
type=np.dtype(np.int16),
shape=['first_index_of_DOS_grid', 'last_index_of_DOS_grid'],
description='''
Indices used to compare DOS fingerprints of different energy ranges.
......@@ -1238,7 +1238,7 @@ class section_dos_fingerprint(MSection):
type=np.dtype(np.float64),
shape=[],
description='''
Proportion of '1' bins in the DOS fingerprint.
Proportion of 1 bins in the DOS fingerprint.
''',
a_legacy=LegacyDefinition(name='filling_factor'))
......@@ -1249,7 +1249,6 @@ class section_dos_fingerprint(MSection):
Similarity can only be calculated if the same grid was used for both fingerprints.
''',
a_legacy=LegacyDefinition(name='grid_id'))
class section_dos(MSection):
'''
......@@ -1383,7 +1382,10 @@ class section_dos(MSection):
''',
a_legacy=LegacyDefinition(name='number_of_dos_values'))
dos_fingerprint = SubSection(section_dos_fingerprint, repeats=False)
section_dos_fingerprint = SubSection(
sub_section = SectionProxy('section_dos_fingerprint'),
repeats=False,
a_legacy=LegacyDefinition(name='section_dos_fingerprint'))
class section_eigenvalues(MSection):
......
......@@ -13,10 +13,10 @@
# limitations under the License.
from .normalizer import Normalizer
from nomad.datamodel.metainfo.public import section_dos_fingerprint
import numpy as np
from nomad_dos_fingerprints import DOSFingerprint
import json
class DosNormalizer(Normalizer):
......@@ -73,7 +73,7 @@ class DosNormalizer(Normalizer):
scc_url = '/section_run/0/section_single_configuration_calculation/%d/section_dos/0' % scc.m_parent_index
self._backend.openContext(scc_url)
dos.dos_values_normalized = dos_normed
sec_dos_fingerprint = dos.m_create("section_dos_fingerprint")
sec_dos_fingerprint = dos.m_create(section_dos_fingerprint)
sec_dos_fingerprint.bins = dos_fingerprint.bins
sec_dos_fingerprint.indices = dos_fingerprint.indices
sec_dos_fingerprint.stepsize = dos_fingerprint.stepsize
......
......@@ -18,7 +18,8 @@ from tests.test_parsing import parse_file
from tests.normalizing.conftest import run_normalize
from nomad_dos_fingerprints import DOSFingerprint, tanimoto_similarity
import json
import matplotlib.pyplot as plt
vasp_parser_dos = (
'parsers/vasp', 'tests/data/parsers/vasp/vasp_dos.xml')
......@@ -40,9 +41,14 @@ def test_dos_normalizer():
assert np.allclose(last_value, expected)
# Check if DOS fingerprint was created
backend_dos_fingerprint = backend.get_value('dos_fingerprint')
dos_fingerprint = DOSFingerprint().from_dict(json.loads(backend_dos_fingerprint))
backend_dos_fingerprint = backend['section_dos_fingerprint'][0]
dos_fingerprint = DOSFingerprint().from_dict(dict(
bins = backend_dos_fingerprint.bins,
indices = backend_dos_fingerprint.indices,
grid_id = backend_dos_fingerprint.grid_id,
stepsize = backend_dos_fingerprint.stepsize,
filling_factor = backend_dos_fingerprint.filling_factor))
assert tanimoto_similarity(dos_fingerprint, dos_fingerprint) == 1
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment