Commit eb51f1cb authored by Lauri Himanen's avatar Lauri Himanen
Browse files

Migrated normalizers (EncyclopediaNormalizer, Normalizer) to primarily use...

Migrated normalizers (EncyclopediaNormalizer, Normalizer) to primarily use workflow information instead of frame sequences.
parent 2c2ec6ed
......@@ -47,6 +47,23 @@ class EncyclopediaNormalizer(Normalizer):
calc_enums = Calculation.calculation_type.type
calc_type = calc_enums.unavailable
# Primarily try to determine the calculation type from workflow
# information
try:
workflow = self.section_run.section_workflow
workflow_map = {
"molecular_dynamics": calc_enums.molecular_dynamics,
"geometry_optimization": calc_enums.geometry_optimization,
"phonon": calc_enums.phonon_calculation,
}
workflow_enum = workflow_map.get(workflow.workflow_type)
if workflow_enum is not None:
calc.calculation_type = calc_type
return calc_type
except Exception:
pass
# Fall back to old frame sequence data
try:
sccs = self.section_run.section_single_configuration_calculation
except Exception:
......
......@@ -93,22 +93,34 @@ class SystemBasedNormalizer(Normalizer, metaclass=ABCMeta):
system = None
scc = None
# Try to find workflow information and select the representative system
# based on it
workflow = self.section_run.section_workflow
if workflow:
try:
iscc = workflow.calculation_result_ref
system = scc.single_configuration_calculation_to_system_ref
if system is not None:
scc = iscc
except Exception:
pass
# Try to find a frame sequence, only first found is considered
try:
frame_seqs = self.section_run.section_frame_sequence
frame_seq = frame_seqs[0]
sec_sampling_method = frame_seq.frame_sequence_to_sampling_ref
sampling_method = sec_sampling_method.sampling_method
frames = frame_seq.frame_sequence_local_frames_ref
if sampling_method == "molecular_dynamics":
iscc = frames[0]
else:
iscc = frames[-1]
system = iscc.single_configuration_calculation_to_system_ref
if system is not None:
scc = iscc
except Exception:
pass
else:
try:
frame_seqs = self.section_run.section_frame_sequence
frame_seq = frame_seqs[0]
sec_sampling_method = frame_seq.frame_sequence_to_sampling_ref
sampling_method = sec_sampling_method.sampling_method
frames = frame_seq.frame_sequence_local_frames_ref
if sampling_method == "molecular_dynamics":
iscc = frames[0]
else:
iscc = frames[-1]
system = iscc.single_configuration_calculation_to_system_ref
if system is not None:
scc = iscc
except Exception:
pass
# If no frame sequences detected, try to find valid scc by looping all
# available in reverse order until a valid one is found.
......
Markdown is supported
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