@@ -794,6 +794,7 @@ class XmfEntry:
794794 coord_filepattern : str
795795 coord_shape : tuple [int , ...]
796796 ncores : int
797+ fields : Mapping [str , tuple [int , tuple [int , ...]]]
797798
798799 def coord_files_yin (self , path_root : Path ) -> Iterator [Path ]:
799800 ncores = self .ncores // (2 if self .yin_yang else 1 )
@@ -828,8 +829,7 @@ def _maybe_get(
828829 def _data (self ) -> Mapping [int , XmfEntry ]:
829830 # Geometry stuff from surface field is not useful
830831 data = {}
831- # FIXME: get isnap from a field name
832- for isnap , snap in enumerate (self ._root [0 ][0 ]):
832+ for snap in self ._root [0 ][0 ]:
833833 time = self ._maybe_get (snap , "Time" , "Value" , float )
834834 mo_lambda = self ._maybe_get (snap , "mo_lambda" , "Value" , float )
835835 mo_thick_sol = self ._maybe_get (snap , "mo_thick_sol" , "Value" , float )
@@ -853,6 +853,17 @@ def _data(self) -> Mapping[int, XmfEntry]:
853853 coord_file_chunks [- 2 ] = "{icore:05d}"
854854 coord_filepattern = "_" .join (coord_file_chunks )
855855
856+ fields_info = {}
857+ for elt_fvar in elt_subdomain .findall ("Attribute" ):
858+ name = _try_get (self .path , elt_fvar , "Name" )
859+ elt_data = _try_find (self .path , elt_fvar , "DataItem" )
860+ shape = _get_dim (self .path , elt_data )
861+ data_text = _try_text (self .path , elt_data )
862+ h5file , group = data_text .strip ().split (":/" , 1 )
863+ isnap = int (group [- 5 :])
864+ ifile = int (h5file [- 14 :- 9 ])
865+ fields_info [name ] = (ifile , shape )
866+
856867 ncores = 0
857868 for elt_subdomain in snap .findall ("Grid" ):
858869 elt_name = _try_get (self .path , elt_subdomain , "Name" )
@@ -871,6 +882,7 @@ def _data(self) -> Mapping[int, XmfEntry]:
871882 coord_filepattern = coord_filepattern ,
872883 coord_shape = coord_shape ,
873884 ncores = ncores ,
885+ fields = fields_info ,
874886 )
875887 return data
876888
0 commit comments