@@ -803,20 +803,12 @@ class XmfEntry:
803803 twod : Optional [str ]
804804 coord_filepattern : str
805805 coord_shape : tuple [int , ...]
806- ncores : int
806+ range_yin : range
807+ range_yang : range
807808 fields : Mapping [str , tuple [int , tuple [int , ...]]]
808809
809- def _last_core_yin (self ) -> int :
810- return self .ncores // (2 if self .yin_yang else 1 )
811-
812- def _range_core_yin (self ) -> range :
813- return range (self ._last_core_yin ())
814-
815- def _range_core_yang (self ) -> range :
816- return range (self ._last_core_yin () + 1 , self .ncores )
817-
818810 def coord_files_yin (self , path_root : Path ) -> Iterator [Path ]:
819- for icore in self ._range_core_yin () :
811+ for icore in self .range_yin :
820812 yield path_root / self .coord_filepattern .format (icore = icore + 1 )
821813
822814 def _fsub (self , path_root : Path , name : str , icore : int , yang : bool ) -> FieldSub :
@@ -834,9 +826,9 @@ def _fsub(self, path_root: Path, name: str, icore: int, yang: bool) -> FieldSub:
834826 def field_subdomains (self , path_root : Path , name : str ) -> Iterator [FieldSub ]:
835827 if name not in self .fields :
836828 return
837- for icore in self ._range_core_yin () :
829+ for icore in self .range_yin :
838830 yield self ._fsub (path_root , name , icore , False )
839- for icore in self ._range_core_yang () :
831+ for icore in self .range_yang :
840832 yield self ._fsub (path_root , name , icore , True )
841833
842834
@@ -899,17 +891,25 @@ def _data(self) -> Mapping[int, XmfEntry]:
899891 data_text = _try_text (self .path , elt_data )
900892 h5file , group = data_text .strip ().split (":/" , 1 )
901893 isnap = int (group [- 5 :])
894+ i0_yin = int (group [- 11 :- 6 ]) - 1
902895 ifile = int (h5file [- 14 :- 9 ])
903896 fields_info [name ] = (ifile , shape )
904897
905- ncores = 0
898+ i1_yin = i0_yin
899+ i0_yang = 0
900+ i1_yang = 0
906901 for elt_subdomain in snap .findall ("Grid" ):
907902 elt_name = _try_get (self .path , elt_subdomain , "Name" )
908903 if elt_name .startswith ("meshYang" ):
909904 yin_yang = True
910- ncores *= 2
905+ elt_fvar = _try_find (self .path , elt_subdomain , "Attribute" )
906+ elt_data = _try_find (self .path , elt_fvar , "DataItem" )
907+ data_text = _try_text (self .path , elt_data )
908+ _ , group = data_text .strip ().split (":/" , 1 )
909+ i0_yang = int (group [- 11 :- 6 ]) - 1
910+ i1_yang = i0_yang + (i1_yin - i0_yin )
911911 break
912- ncores += 1
912+ i1_yin += 1
913913
914914 data [isnap ] = XmfEntry (
915915 isnap = isnap ,
@@ -920,7 +920,8 @@ def _data(self) -> Mapping[int, XmfEntry]:
920920 twod = twod ,
921921 coord_filepattern = coord_filepattern ,
922922 coord_shape = coord_shape ,
923- ncores = ncores ,
923+ range_yin = range (i0_yin , i1_yin ),
924+ range_yang = range (i0_yang , i1_yang ),
924925 fields = fields_info ,
925926 )
926927 return data
0 commit comments