From cc3f0b6b05f67a1d8433554cd7403e70415742df Mon Sep 17 00:00:00 2001 From: Julia Schumann Date: Tue, 15 Oct 2024 00:33:43 +0200 Subject: [PATCH] fix check for flow_rate to calculate concentration --- .../schema_packages/catalysis.py | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/nomad_catalysis/schema_packages/catalysis.py b/src/nomad_catalysis/schema_packages/catalysis.py index 22ce097..0787330 100644 --- a/src/nomad_catalysis/schema_packages/catalysis.py +++ b/src/nomad_catalysis/schema_packages/catalysis.py @@ -714,16 +714,17 @@ def normalize(self, archive, logger): # super().normalize(archive, logger) check_if_concentration_in_percentage(self, self.gas_concentration_in, logger) - - if ( - self.flow_rate - and self.m_parent - and getattr(self.m_parent, 'set_total_flow_rate', None) - and self.gas_concentration_in is None - ): - total_flow = getattr(self.m_parent, 'set_total_flow_rate', None) - self.gas_concentration_in = self.flow_rate / total_flow - + try: + if ( + not self.gas_concentration_in + and self.flow_rate + and self.m_parent + and getattr(self.m_parent, 'set_total_flow_rate', None) + ): + total_flow = getattr(self.m_parent, 'set_total_flow_rate', None) + self.gas_concentration_in = self.flow_rate / total_flow + except (TypeError, ValueError): # because truth value of array is ambiguous + pass if self.name is None: return if self.name in ['C5-1', 'C6-1', 'nC5', 'nC6', 'Unknown', 'inert', 'P>=5C']: