@@ -470,6 +470,10 @@ def _build_index(self):
470
470
header = self ._get_header ()
471
471
self .nrow = header ["nrow" ]
472
472
self .ncol = header ["ncol" ]
473
+ self .text_bytes = header ["text" ]
474
+ self .text = (
475
+ self .text_bytes .decode ("ascii" ).strip ().lower ().replace (" " , "_" )
476
+ )
473
477
if header ["ilay" ] > self .nlay :
474
478
self .nlay = header ["ilay" ]
475
479
@@ -488,8 +492,12 @@ def _build_index(self):
488
492
while ipos < self .totalbytes :
489
493
header = self ._get_header ()
490
494
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
+ )
493
501
if ipos == 0 :
494
502
self .times .append (header ["totim" ])
495
503
self .kstpkper .append ((header ["kstp" ], header ["kper" ]))
@@ -501,6 +509,8 @@ def _build_index(self):
501
509
ipos = self .file .tell ()
502
510
self .iposarray .append (ipos )
503
511
databytes = self .get_databytes (header )
512
+ if ipos + databytes > self .totalbytes :
513
+ raise EOFError (f"attempting to seek { ipos + databytes } " )
504
514
self .file .seek (databytes , 1 )
505
515
ipos = self .file .tell ()
506
516
@@ -617,14 +627,13 @@ class HeadFile(BinaryLayerFile):
617
627
----------
618
628
filename : str or PathLike
619
629
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.
628
637
629
638
Examples
630
639
--------
@@ -634,7 +643,7 @@ class HeadFile(BinaryLayerFile):
634
643
>>> hdobj.list_records()
635
644
>>> rec = hdobj.get_data(kstpkper=(0, 49))
636
645
637
- >>> ddnobj = bf.HeadFile('model.ddn', text='drawdown', precision='single')
646
+ >>> ddnobj = bf.HeadFile('model.ddn', precision='single')
638
647
>>> ddnobj.list_records()
639
648
>>> rec = ddnobj.get_data(totim=100.)
640
649
@@ -643,12 +652,11 @@ class HeadFile(BinaryLayerFile):
643
652
def __init__ (
644
653
self ,
645
654
filename : Union [str , os .PathLike ],
646
- text = "head" ,
655
+ text = "head" , # noqa ARG002
647
656
precision = "auto" ,
648
657
verbose = False ,
649
658
** kwargs ,
650
659
):
651
- self .text = text .encode ()
652
660
if precision == "auto" :
653
661
precision = get_headfile_precision (filename )
654
662
if precision == "unknown" :
@@ -749,14 +757,15 @@ class UcnFile(BinaryLayerFile):
749
757
750
758
Parameters
751
759
----------
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.
760
769
761
770
Attributes
762
771
----------
@@ -792,12 +801,11 @@ class UcnFile(BinaryLayerFile):
792
801
def __init__ (
793
802
self ,
794
803
filename ,
795
- text = "concentration" ,
804
+ text = "concentration" , # noqa ARG002
796
805
precision = "auto" ,
797
806
verbose = False ,
798
807
** kwargs ,
799
808
):
800
- self .text = text .encode ()
801
809
if precision == "auto" :
802
810
precision = get_headfile_precision (filename )
803
811
if precision == "unknown" :
@@ -821,14 +829,13 @@ class HeadUFile(BinaryLayerFile):
821
829
----------
822
830
filename : str or PathLike
823
831
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.
832
839
833
840
Notes
834
841
-----
@@ -859,15 +866,14 @@ class HeadUFile(BinaryLayerFile):
859
866
def __init__ (
860
867
self ,
861
868
filename : Union [str , os .PathLike ],
862
- text = "headu" ,
869
+ text = "headu" , # noqa ARG002
863
870
precision = "auto" ,
864
871
verbose = False ,
865
872
** kwargs ,
866
873
):
867
874
"""
868
875
Class constructor
869
876
"""
870
- self .text = text .encode ()
871
877
if precision == "auto" :
872
878
precision = get_headfile_precision (filename )
873
879
if precision == "unknown" :
@@ -990,11 +996,11 @@ class CellBudgetFile:
990
996
----------
991
997
filename : str or PathLike
992
998
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.
998
1004
999
1005
Examples
1000
1006
--------
@@ -2217,7 +2223,6 @@ def reverse(self, filename: Optional[os.PathLike] = None):
2217
2223
2218
2224
Parameters
2219
2225
----------
2220
-
2221
2226
filename : str or PathLike, optional
2222
2227
Path of the new reversed binary cell budget file to create.
2223
2228
"""
0 commit comments