<s> """<STR_LIT>""" <EOL> import sys <EOL> import numpy as np <EOL> from . . pakbase import Package <EOL> from . . utils import Util2d <EOL> class ModflowUzf1 ( Package ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , model , nuztop = <NUM_LIT:1> , iuzfopt = <NUM_LIT:0> , irunflg = <NUM_LIT:0> , ietflg = <NUM_LIT:0> , iuzfcb1 = <NUM_LIT> , iuzfcb2 = <NUM_LIT:0> , ntrail2 = <NUM_LIT:10> , nsets = <NUM_LIT:20> , nuzgag = <NUM_LIT:0> , <EOL> surfdep = <NUM_LIT:1.0> , iuzfbnd = <NUM_LIT:1> , irunbnd = <NUM_LIT:0> , vks = <NUM_LIT> , eps = <NUM_LIT> , thts = <NUM_LIT> , thtr = <NUM_LIT> , thti = <NUM_LIT> , row_col_iftunit_iuzopt = [ ] , specifythtr = <NUM_LIT:0> , specifythti = <NUM_LIT:0> , nosurfleak = <NUM_LIT:0> , finf = <NUM_LIT> , pet = <NUM_LIT> , extdp = <NUM_LIT> , extwc = <NUM_LIT:0.1> , uzfbud_ext = [ ] , extension = '<STR_LIT>' , unitnumber = <NUM_LIT> ) : <EOL> Package . __init__ ( self , model , extension , [ '<STR_LIT>' ] , <EOL> unitnumber ) <EOL> if self . parent . get_package ( '<STR_LIT>' ) != None or self . parent . get_package ( '<STR_LIT>' ) != None : <EOL> print ( '<STR_LIT>' ) <EOL> if self . parent . version == '<STR_LIT>' : <EOL> print ( '<STR_LIT>' ) <EOL> nrow , ncol , nlay , nper = self . parent . nrow_ncol_nlay_nper <EOL> self . heading = '<STR_LIT>' <EOL> self . url = '<STR_LIT>' <EOL> self . specifythtr = specifythtr <EOL> self . specifythti = specifythti <EOL> self . nosurfleak = nosurfleak <EOL> self . nuztop = nuztop <EOL> self . iuzfopt = iuzfopt <EOL> self . irunflg = irunflg <EOL> self . ietflg = ietflg <EOL> self . iuzfcb1 = iuzfcb1 <EOL> self . iuzfcb2 = iuzfcb2 <EOL> class_nam = [ '<STR_LIT>' ] <EOL> if ( not isinstance ( unitnumber , list ) ) : <EOL> unitnumber = [ unitnumber ] <EOL> if ( not isinstance ( extension , list ) ) : <EOL> extension = [ extension ] <EOL> if iuzfcb1 > <NUM_LIT:0> and iuzfcb2 < <NUM_LIT:1> : <EOL> unitnumber . append ( iuzfcb1 ) <EOL> extension . append ( extension [ <NUM_LIT:0> ] + '<STR_LIT>' ) <EOL> class_nam += [ '<STR_LIT>' ] <EOL> elif iuzfcb1 < <NUM_LIT:1> and iuzfcb2 > <NUM_LIT:0> : <EOL> unitnumber . append ( iuzfcb2 ) <EOL> extension . append ( extension [ <NUM_LIT:0> ] + '<STR_LIT>' ) <EOL> class_nam += [ '<STR_LIT>' ] <EOL> elif iuzfcb1 > <NUM_LIT:0> and iuzfcb2 > <NUM_LIT:0> : <EOL> unitnumber . append ( iuzfcb1 ) <EOL> extension . append ( extension [ <NUM_LIT:0> ] + '<STR_LIT>' ) <EOL> unitnumber . append ( iuzfcb2 ) <EOL> extension . append ( extension [ <NUM_LIT:0> ] + '<STR_LIT>' ) <EOL> class_nam += [ '<STR_LIT>' , '<STR_LIT>' ] <EOL> if iuzfopt > <NUM_LIT:0> : <EOL> self . ntrail2 = ntrail2 <EOL> self . nsets = nsets <EOL> self . nuzgag = nuzgag <EOL> self . surfdep = surfdep <EOL> self . iuzfbnd = Util2d ( model , ( nrow , ncol ) , np . int , iuzfbnd , name = '<STR_LIT>' ) <EOL> if irunflg > <NUM_LIT:0> : <EOL> self . irunbnd = Util2d ( model , ( nrow , ncol ) , np . int , irunbnd , name = '<STR_LIT>' ) <EOL> if abs ( iuzfopt ) == <NUM_LIT:1> : <EOL> self . vks = Util2d ( model , ( nrow , ncol ) , np . float32 , vks , name = '<STR_LIT>' ) <EOL> if iuzfopt > <NUM_LIT:0> : <EOL> self . eps = Util2d ( model , ( nrow , ncol ) , np . float32 , eps , name = '<STR_LIT>' ) <EOL> self . thts = Util2d ( model , ( nrow , ncol ) , np . float32 , thts , name = '<STR_LIT>' ) <EOL> if self . specifythtr > <NUM_LIT:0> : <EOL> self . thtr = Util2d ( model , ( nrow , ncol ) , np . float32 , thtr , name = '<STR_LIT>' ) <EOL> self . thti = Util2d ( model , ( nrow , ncol ) , np . float32 , thti , name = '<STR_LIT>' ) <EOL> if len ( row_col_iftunit_iuzopt ) != nuzgag : <EOL> print ( "<STR_LIT>" ) <EOL> self . nuzgag = <NUM_LIT:0> <EOL> self . row_col_iftunit_iuzopt = [ ] <EOL> else : <EOL> self . row_col_iftunit_iuzopt = row_col_iftunit_iuzopt <EOL> i = <NUM_LIT:0> <EOL> for l in row_col_iftunit_iuzopt : <EOL> unitnumber . append ( abs ( l [ <NUM_LIT:0> ] [ <NUM_LIT:2> ] ) ) <EOL> if uzfbud_ext == [ ] : <EOL> extension . append ( extension [ <NUM_LIT:0> ] + '<STR_LIT:b>' + str ( i ) ) <EOL> else : <EOL> extension . append ( uzfbud_ext [ i ] ) <EOL> i += <NUM_LIT:1> <EOL> Package . __init__ ( self , model , extension , class_nam + nuzgag * [ '<STR_LIT>' ] , unit_number = unitnumber ) <EOL> self . finf = [ ] <EOL> if ( not isinstance ( finf , list ) ) : <EOL> finf = [ finf ] <EOL> for i , a in enumerate ( finf ) : <EOL> b = Util2d ( model , ( nrow , ncol ) , np . float32 , a , name = '<STR_LIT>' + str ( i + <NUM_LIT:1> ) ) <EOL> self . finf . append ( b ) <EOL> if ietflg > <NUM_LIT:0> : <EOL> self . pet = [ ] <EOL> if ( not isinstance ( pet , list ) ) : <EOL> pet = [ pet ] <EOL> for i , a in enumerate ( pet ) : <EOL> b = Util2d ( model , ( nrow , ncol ) , np . float32 , a , name = '<STR_LIT>' + str ( i + <NUM_LIT:1> ) ) <EOL> self . pet . append ( b ) <EOL> self . extdp = [ ] <EOL> if ( not isinstance ( extdp , list ) ) : <EOL> extdp = [ extdp ] <EOL> for i , a in enumerate ( extdp ) : <EOL> b = Util2d ( model , ( nrow , ncol ) , np . float32 , a , name = '<STR_LIT>' + str ( i + <NUM_LIT:1> ) ) <EOL> self . extdp . append ( b ) <EOL> if iuzfopt > <NUM_LIT:0> : <EOL> self . extwc = [ ] <EOL> if ( not isinstance ( extwc , list ) ) : <EOL> extwc = [ extwc ] <EOL> for i , a in enumerate ( extwc ) : <EOL> b = Util2d ( model , ( nrow , ncol ) , np . float32 , a , name = '<STR_LIT>' + str ( i + <NUM_LIT:1> ) ) <EOL> self . extwc . append ( b ) <EOL> self . parent . add_package ( self ) <EOL> def ncells ( self ) : <EOL> nrow , ncol , nlay , nper = self . parent . nrow_ncol_nlay_nper <EOL> return ( nrow * ncol ) <EOL> def write_file ( self ) : <EOL> """<STR_LIT>""" <EOL> nrow , ncol , nlay , nper = self . parent . nrow_ncol_nlay_nper <EOL> f_uzf = open ( self . fn_path , '<STR_LIT:w>' ) <EOL> f_uzf . write ( '<STR_LIT>' . format ( self . heading ) ) <EOL> specify_temp = '<STR_LIT>' <EOL> if self . specifythtr > <NUM_LIT:0> : <EOL> specify_temp += '<STR_LIT>' <EOL> if self . specifythti > <NUM_LIT:0> : <EOL> specify_temp += '<STR_LIT>' <EOL> if self . nosurfleak > <NUM_LIT:0> : <EOL> specify_temp += '<STR_LIT>' <EOL> if ( self . specifythtr + self . specifythti + self . nosurfleak ) > <NUM_LIT:0> : <EOL> f_uzf . write ( '<STR_LIT>' % specify_temp ) <EOL> del specify_temp <EOL> if self . iuzfopt > <NUM_LIT:0> : <EOL> comment = '<STR_LIT>' <EOL> f_uzf . write ( '<STR_LIT>' . format ( self . nuztop , self . iuzfopt , self . irunflg , self . ietflg , self . iuzfcb1 , self . iuzfcb2 , self . ntrail2 , self . nsets , self . nuzgag , self . surfdep , comment ) ) <EOL> else : <EOL> comment = '<STR_LIT>' <EOL> f_uzf . write ( '<STR_LIT>' . format ( self . nuztop , self . iuzfopt , self . irunflg , self . ietflg , self . iuzfcb1 , self . iuzfcb2 , self . nuzgag , self . surfdep , comment ) ) <EOL> f_uzf . write ( self . iuzfbnd . get_file_entry ( ) ) <EOL> if self . irunflg > <NUM_LIT:0> : <EOL> f_uzf . write ( self . irunbnd . get_file_entry ( ) ) <EOL> if abs ( self . iuzfopt ) == <NUM_LIT:1> : <EOL> f_uzf . write ( self . vks . get_file_entry ( ) ) <EOL> if self . iuzfopt > <NUM_LIT:0> : <EOL> f_uzf . write ( self . eps . get_file_entry ( ) ) <EOL> f_uzf . write ( self . thts . get_file_entry ( ) ) <EOL> if self . specifythtr > <NUM_LIT:0.0> : <EOL> f_uzf . write ( self . thtr . get_file_entry ( ) ) <EOL> if not self . parent . get_package ( '<STR_LIT>' ) . steady [ <NUM_LIT:0> ] or self . specifythti > <NUM_LIT:0.0> : <EOL> f_uzf . write ( self . thti . get_file_entry ( ) ) <EOL> if self . nuzgag > <NUM_LIT:0> : <EOL> for n in range ( self . nuzgag ) : <EOL> if self . row_col_iftunit_iuzopt [ n ] [ <NUM_LIT:0> ] [ <NUM_LIT:2> ] > <NUM_LIT:0> : <EOL> comment = '<STR_LIT>' <EOL> f_uzf . write ( '<STR_LIT>' % ( tuple ( self . row_col_iftunit_iuzopt [ n ] [ <NUM_LIT:0> ] + [ comment ] ) ) ) <EOL> else : <EOL> comment = '<STR_LIT>' <EOL> f_uzf . write ( '<STR_LIT>' % ( tuple ( [ self . row_col_iftunit_iuzopt [ n ] [ <NUM_LIT:0> ] [ <NUM_LIT:2> ] ] + [ comment ] ) ) ) <EOL> for n in range ( nper ) : <EOL> comment = '<STR_LIT>' + str ( n + <NUM_LIT:1> ) <EOL> if ( n < len ( self . finf ) ) : <EOL> nuzf1 = <NUM_LIT:1> <EOL> else : <EOL> nuzf1 = - <NUM_LIT:1> <EOL> f_uzf . write ( '<STR_LIT>' . format ( nuzf1 , comment ) ) <EOL> comment = '<STR_LIT>' + str ( n + <NUM_LIT:1> ) <EOL> if ( n < len ( self . finf ) ) : <EOL> f_uzf . write ( self . finf [ n ] . get_file_entry ( ) ) <EOL> comment = '<STR_LIT>' + str ( n + <NUM_LIT:1> ) <EOL> if self . ietflg > <NUM_LIT:0> : <EOL> if ( n < len ( self . pet ) ) : <EOL> nuzf2 = <NUM_LIT:1> <EOL> else : <EOL> nuzf2 = - <NUM_LIT:1> <EOL> f_uzf . write ( '<STR_LIT>' . format ( nuzf2 , comment ) ) <EOL> comment = '<STR_LIT>' + str ( n + <NUM_LIT:1> ) <EOL> if ( n < len ( self . pet ) ) : <EOL> f_uzf . write ( self . pet [ n ] . get_file_entry ( ) ) <EOL> comment = '<STR_LIT>' + str ( n + <NUM_LIT:1> ) <EOL> if ( n < len ( self . extdp ) ) : <EOL> nuzf3 = <NUM_LIT:1> <EOL> else : <EOL> nuzf3 = - <NUM_LIT:1> <EOL> f_uzf . write ( '<STR_LIT>' . format ( nuzf3 , comment ) ) <EOL> comment = '<STR_LIT>' + str ( n + <NUM_LIT:1> ) <EOL> if ( n < len ( self . extdp ) ) : <EOL> f_uzf . write ( self . extdp [ n ] . get_file_entry ( ) ) <EOL> comment = '<STR_LIT>' + str ( n + <NUM_LIT:1> ) <EOL> if self . iuzfopt > <NUM_LIT:0> : <EOL> if ( n < len ( self . extwc ) ) : <EOL> nuzf4 = <NUM_LIT:1> <EOL> else : <EOL> nuzf4 = - <NUM_LIT:1> <EOL> f_uzf . write ( '<STR_LIT>' . format ( nuzf4 , comment ) ) <EOL> comment = '<STR_LIT>' + str ( n + <NUM_LIT:1> ) <EOL> if ( n < len ( self . extwc ) ) : <EOL> f_uzf . write ( self . extwc [ n ] . get_file_entry ( ) ) <EOL> f_uzf . close ( ) <EOL> @ staticmethod <EOL> def load ( f , model , ext_unit_dict = None ) : <EOL> """<STR_LIT>""" <EOL> if model . verbose : <EOL> sys . stdout . write ( '<STR_LIT>' ) <EOL> if not hasattr ( f , '<STR_LIT>' ) : <EOL> filename = f <EOL> f = open ( filename , '<STR_LIT:r>' ) <EOL> while True : <EOL> line = f . readline ( ) <EOL> if line [ <NUM_LIT:0> ] != '<STR_LIT:#>' : <EOL> break <EOL> print ( '<STR_LIT>' ) <EOL> f . close ( ) <EOL> uzf = ModflowUzf1 ( model ) <EOL> return uzf </s>
