@@ -724,14 +724,6 @@ def _try_get(file: Path, elt: Element, key: str) -> str:
724724 return att
725725
726726
727- def _try_find (file : Path , elt : Element , key : str ) -> Element :
728- """Try finding a sub-element or raise a ParsingError."""
729- subelt = elt .find (key )
730- if subelt is None :
731- raise ParsingError (file , f"Element { elt } has no sub-element { key !r} " )
732- return subelt
733-
734-
735727def _try_text (file : Path , elt : Element ) -> str :
736728 """Try getting text of element or raise a ParsingError."""
737729 text = elt .text
@@ -746,41 +738,6 @@ def _get_dim(xdmf_file: Path, data_item: Element) -> Tuple[int, ...]:
746738 return tuple (map (int , dims .split ()))
747739
748740
749- def _get_field (xdmf_file : Path , data_item : Element ) -> Tuple [int , ndarray ]:
750- """Extract field from data item."""
751- shp = _get_dim (xdmf_file , data_item )
752- data_text = _try_text (xdmf_file , data_item )
753- h5file , group = data_text .strip ().split (":/" , 1 )
754- # Field on yin is named <var>_XXXXX_YYYYY, on yang is <var>2XXXXX_YYYYY.
755- numeral_part = group [- 11 :]
756- icore = int (numeral_part .split ("_" )[- 2 ]) - 1
757- fld = None
758- try :
759- fld = _read_group_h5 (xdmf_file .parent / h5file , group ).reshape (shp )
760- except KeyError :
761- # test previous/following snapshot files as their numbers can get
762- # slightly out of sync between cores
763- h5file_parts = h5file .split ("_" )
764- fnum = int (h5file_parts [- 2 ])
765- if fnum > 0 :
766- h5file_parts [- 2 ] = f"{ fnum - 1 :05d} "
767- h5f = xdmf_file .parent / "_" .join (h5file_parts )
768- try :
769- fld = _read_group_h5 (h5f , group ).reshape (shp )
770- except (OSError , KeyError ):
771- pass
772- if fld is None :
773- h5file_parts [- 2 ] = f"{ fnum + 1 :05d} "
774- h5f = xdmf_file .parent / "_" .join (h5file_parts )
775- try :
776- fld = _read_group_h5 (h5f , group ).reshape (shp )
777- except (OSError , KeyError ):
778- pass
779- if fld is None :
780- raise
781- return icore , fld
782-
783-
784741@dataclass (frozen = True )
785742class FieldSub :
786743 file : Path
0 commit comments