@@ -470,6 +470,10 @@ def _build_index(self):
470470 header = self ._get_header ()
471471 self .nrow = header ["nrow" ]
472472 self .ncol = header ["ncol" ]
473+ self .text_bytes = header ["text" ]
474+ self .text = (
475+ self .text_bytes .decode ("ascii" ).strip ().lower ().replace (" " , "_" )
476+ )
473477 if header ["ilay" ] > self .nlay :
474478 self .nlay = header ["ilay" ]
475479
@@ -488,8 +492,12 @@ def _build_index(self):
488492 while ipos < self .totalbytes :
489493 header = self ._get_header ()
490494 self .recordarray .append (header )
491- if self .text .upper () not in header ["text" ]:
492- continue
495+ if header ["text" ] != self .text_bytes :
496+ warnings .warn (
497+ "inconsistent text headers changing from "
498+ f"{ self .text_bytes !r} to { header ['text' ]!r} " ,
499+ UserWarning ,
500+ )
493501 if ipos == 0 :
494502 self .times .append (header ["totim" ])
495503 self .kstpkper .append ((header ["kstp" ], header ["kper" ]))
@@ -501,6 +509,8 @@ def _build_index(self):
501509 ipos = self .file .tell ()
502510 self .iposarray .append (ipos )
503511 databytes = self .get_databytes (header )
512+ if ipos + databytes > self .totalbytes :
513+ raise EOFError (f"attempting to seek { ipos + databytes } " )
504514 self .file .seek (databytes , 1 )
505515 ipos = self .file .tell ()
506516
@@ -617,14 +627,13 @@ class HeadFile(BinaryLayerFile):
617627 ----------
618628 filename : str or PathLike
619629 Path of the head file.
620- text : string
621- Name of the text string in the head file. Default is 'head'.
622- precision : string
623- Precision of floating point head data in the value. Accepted
624- values are 'auto', 'single' or 'double'. Default is 'auto',
625- which enables automatic detection of precision.
626- verbose : bool
627- Toggle logging output. Default is False.
630+ text : str
631+ Ignored.
632+ precision : {'auto', 'single', 'double'}
633+ Precision of floating point head data in the value. Default
634+ 'auto' enables automatic detection of precision.
635+ verbose : bool, default False
636+ Toggle logging output.
628637
629638 Examples
630639 --------
@@ -634,7 +643,7 @@ class HeadFile(BinaryLayerFile):
634643 >>> hdobj.list_records()
635644 >>> rec = hdobj.get_data(kstpkper=(0, 49))
636645
637- >>> ddnobj = bf.HeadFile('model.ddn', text='drawdown', precision='single')
646+ >>> ddnobj = bf.HeadFile('model.ddn', precision='single')
638647 >>> ddnobj.list_records()
639648 >>> rec = ddnobj.get_data(totim=100.)
640649
@@ -643,12 +652,11 @@ class HeadFile(BinaryLayerFile):
643652 def __init__ (
644653 self ,
645654 filename : Union [str , os .PathLike ],
646- text = "head" ,
655+ text = "head" , # noqa ARG002
647656 precision = "auto" ,
648657 verbose = False ,
649658 ** kwargs ,
650659 ):
651- self .text = text .encode ()
652660 if precision == "auto" :
653661 precision = get_headfile_precision (filename )
654662 if precision == "unknown" :
@@ -749,14 +757,15 @@ class UcnFile(BinaryLayerFile):
749757
750758 Parameters
751759 ----------
752- filename : string
753- Name of the concentration file
754- text : string
755- Name of the text string in the ucn file. Default is 'CONCENTRATION'
756- precision : string
757- 'auto', 'single' or 'double'. Default is 'auto'.
758- verbose : bool
759- Write information to the screen. Default is False.
760+ filename : str or PathLike
761+ Path of the concentration file.
762+ text : str
763+ Ignored.
764+ precision : {'auto', 'single', 'double'}
765+ Precision of floating point values. Default 'auto' enables automatic
766+ detection of precision.
767+ verbose : bool, default False
768+ Write information to the screen.
760769
761770 Attributes
762771 ----------
@@ -792,12 +801,11 @@ class UcnFile(BinaryLayerFile):
792801 def __init__ (
793802 self ,
794803 filename ,
795- text = "concentration" ,
804+ text = "concentration" , # noqa ARG002
796805 precision = "auto" ,
797806 verbose = False ,
798807 ** kwargs ,
799808 ):
800- self .text = text .encode ()
801809 if precision == "auto" :
802810 precision = get_headfile_precision (filename )
803811 if precision == "unknown" :
@@ -821,14 +829,13 @@ class HeadUFile(BinaryLayerFile):
821829 ----------
822830 filename : str or PathLike
823831 Path of the head file
824- text : string
825- Name of the text string in the head file. Default is 'headu'.
826- precision : string
827- Precision of the floating point head data in the file. Accepted
828- values are 'auto', 'single' or 'double'. Default is 'auto', which
829- enables precision to be automatically detected.
830- verbose : bool
831- Toggle logging output. Default is False.
832+ text : str
833+ Ignored.
834+ precision : {'auto', 'single', 'double'}
835+ Precision of floating point values. Default 'auto' enables automatic
836+ detection of precision.
837+ verbose : bool, default False
838+ Toggle logging output.
832839
833840 Notes
834841 -----
@@ -859,15 +866,14 @@ class HeadUFile(BinaryLayerFile):
859866 def __init__ (
860867 self ,
861868 filename : Union [str , os .PathLike ],
862- text = "headu" ,
869+ text = "headu" , # noqa ARG002
863870 precision = "auto" ,
864871 verbose = False ,
865872 ** kwargs ,
866873 ):
867874 """
868875 Class constructor
869876 """
870- self .text = text .encode ()
871877 if precision == "auto" :
872878 precision = get_headfile_precision (filename )
873879 if precision == "unknown" :
@@ -990,11 +996,11 @@ class CellBudgetFile:
990996 ----------
991997 filename : str or PathLike
992998 Path of the cell budget file.
993- precision : string
994- Precision of floating point budget data in the file. Accepted
995- values are 'single' or 'double'. Default is 'single' .
996- verbose : bool
997- Toggle logging output. Default is False.
999+ precision : {'auto', 'single', 'double'}
1000+ Precision of floating point values. Default 'auto' enables automatic
1001+ detection of precision .
1002+ verbose : bool, default False
1003+ Toggle logging output.
9981004
9991005 Examples
10001006 --------
@@ -2217,7 +2223,6 @@ def reverse(self, filename: Optional[os.PathLike] = None):
22172223
22182224 Parameters
22192225 ----------
2220-
22212226 filename : str or PathLike, optional
22222227 Path of the new reversed binary cell budget file to create.
22232228 """
0 commit comments