@@ -176,45 +176,55 @@ def get_entry_reference(archive, f_name):
176176
177177
178178class NexusIdentifiers (ArchiveSection ):
179- NeXus_identifiers = SubSection (
179+ Nexus_identifiers = SubSection (
180180 section_def = AnchoredReference ,
181181 repeats = True ,
182182 description = "These are the NOMAD references correspond to NeXus identifierNAME fields." ,
183183 )
184184
185185 def normalize (self , archive , logger ):
186186 # Consider multiple identifiers exists in the same group/section
187- def generate_anchored_reference_and_normalize (value , idname ):
187+ def generate_anchored_reference_and_normalize (
188+ attr_obj , id_value , idname , is_full_storage = False
189+ ):
188190 """Generate anchored reference, connect to m quantities, and normalize."""
189191 field_n = idname .split ("__field" )[0 ]
190- logger .info (f"Lab id { value } to be created" )
191- nx_id = AnchoredReference (lab_id = value , name = field_n )
192- nx_id .m_set_section_attribute (
193- "m_nx_data_path" ,
194- self .m_get_quantity_attribute (idname , "m_nx_data_path" ),
195- )
196- nx_id .m_set_section_attribute (
197- "m_nx_data_file" ,
198- self .m_get_quantity_attribute (idname , "m_nx_data_file" ),
199- )
192+ logger .info (f"Lab id { id_value } to be created" )
193+ nx_id = AnchoredReference (lab_id = id_value , name = field_n )
194+ if not is_full_storage :
195+ nx_data_path = attr_obj .m_get_quantity_attribute (
196+ idname , "m_nx_data_path"
197+ )
198+ nx_data_file = attr_obj .m_get_quantity_attribute (
199+ idname , "m_nx_data_file"
200+ )
201+ else :
202+ nx_data_path = attr_obj .attributes .get ("m_nx_data_path" )
203+ nx_data_file = attr_obj .attributes .get ("m_nx_data_file" )
204+
205+ nx_id .m_set_section_attribute ("m_nx_data_path" , nx_data_path )
206+ nx_id .m_set_section_attribute ("m_nx_data_file" , nx_data_file )
207+
208+ self .Nexus_identifiers .append (nx_id )
200209 nx_id .normalize (archive , logger )
201- self .NeXus_identifiers .append (nx_id )
202210
203211 identifiers = [
204212 key
205213 for key in self .__dict__ .keys ()
206214 if key .startswith ("identifier" ) and key .endswith ("__field" )
207215 ]
208216 if identifiers :
209- self .NeXus_identifiers = []
217+ self .Nexus_identifiers = []
210218 for identifier in identifiers :
211219 if not (val := getattr (self , identifier )):
212220 continue
213221 if isinstance (val , dict ):
214222 for idname , idobj in val .items ():
215- generate_anchored_reference_and_normalize (idobj .value , idname )
223+ generate_anchored_reference_and_normalize (
224+ idobj , idobj .value , idname , True
225+ )
216226 else :
217- generate_anchored_reference_and_normalize (val , identifier )
227+ generate_anchored_reference_and_normalize (self , val , identifier )
218228 super ().normalize (archive , logger )
219229
220230
0 commit comments