<s> """<STR_LIT>""" <EOL> import sys <EOL> import numpy as np <EOL> from . . pakbase import Package <EOL> from . . utils import Util2d , Util3d , read1d <EOL> from flopy . modflow . mfpar import ModflowPar as mfpar <EOL> class ModflowLpf ( Package ) : <EOL> """<STR_LIT>""" <EOL> '<STR_LIT>' <EOL> def __init__ ( self , model , laytyp = <NUM_LIT:0> , layavg = <NUM_LIT:0> , chani = <NUM_LIT:1.0> , layvka = <NUM_LIT:0> , <EOL> laywet = <NUM_LIT:0> , ipakcb = <NUM_LIT> , hdry = - <NUM_LIT> , iwdflg = <NUM_LIT:0> , wetfct = <NUM_LIT:0.1> , <EOL> iwetit = <NUM_LIT:1> , ihdwet = <NUM_LIT:0> , hk = <NUM_LIT:1.0> , hani = <NUM_LIT:1.0> , vka = <NUM_LIT:1.0> , ss = <NUM_LIT> , <EOL> sy = <NUM_LIT> , vkcb = <NUM_LIT:0.0> , wetdry = - <NUM_LIT> , storagecoefficient = False , <EOL> constantcv = False , thickstrt = False , nocvcorrection = False , <EOL> novfc = False , extension = '<STR_LIT>' , unitnumber = <NUM_LIT:15> ) : <EOL> Package . __init__ ( self , model , extension , '<STR_LIT>' , <EOL> unitnumber ) <EOL> self . heading = '<STR_LIT>' <EOL> self . url = '<STR_LIT>' <EOL> nrow , ncol , nlay , nper = self . parent . nrow_ncol_nlay_nper <EOL> if ipakcb != <NUM_LIT:0> : <EOL> self . ipakcb = <NUM_LIT> <EOL> else : <EOL> self . ipakcb = <NUM_LIT:0> <EOL> self . hdry = hdry <EOL> self . nplpf = <NUM_LIT:0> <EOL> self . laytyp = Util2d ( model , ( nlay , ) , np . int , laytyp , name = '<STR_LIT>' ) <EOL> self . layavg = Util2d ( model , ( nlay , ) , np . int , layavg , name = '<STR_LIT>' ) <EOL> self . chani = Util2d ( model , ( nlay , ) , np . float32 , chani , name = '<STR_LIT>' ) <EOL> self . layvka = Util2d ( model , ( nlay , ) , np . int , layvka , name = '<STR_LIT>' ) <EOL> self . laywet = Util2d ( model , ( nlay , ) , np . int , laywet , name = '<STR_LIT>' ) <EOL> self . wetfct = wetfct <EOL> self . iwetit = iwetit <EOL> self . ihdwet = ihdwet <EOL> self . options = '<STR_LIT:U+0020>' <EOL> if storagecoefficient : <EOL> self . options = self . options + '<STR_LIT>' <EOL> if constantcv : self . options = self . options + '<STR_LIT>' <EOL> if thickstrt : self . options = self . options + '<STR_LIT>' <EOL> if nocvcorrection : self . options = self . options + '<STR_LIT>' <EOL> if novfc : self . options = self . options + '<STR_LIT>' <EOL> self . hk = Util3d ( model , ( nlay , nrow , ncol ) , np . float32 , hk , name = '<STR_LIT>' , <EOL> locat = self . unit_number [ <NUM_LIT:0> ] ) <EOL> self . hani = Util3d ( model , ( nlay , nrow , ncol ) , np . float32 , hani , <EOL> name = '<STR_LIT>' , locat = self . unit_number [ <NUM_LIT:0> ] ) <EOL> keys = [ ] <EOL> for k in range ( nlay ) : <EOL> key = '<STR_LIT>' <EOL> if self . layvka [ k ] != <NUM_LIT:0> : <EOL> key = '<STR_LIT>' <EOL> keys . append ( key ) <EOL> self . vka = Util3d ( model , ( nlay , nrow , ncol ) , np . float32 , vka , <EOL> name = keys , locat = self . unit_number [ <NUM_LIT:0> ] ) <EOL> tag = '<STR_LIT>' <EOL> if storagecoefficient : <EOL> tag = '<STR_LIT>' <EOL> self . ss = Util3d ( model , ( nlay , nrow , ncol ) , np . float32 , ss , name = tag , <EOL> locat = self . unit_number [ <NUM_LIT:0> ] ) <EOL> self . sy = Util3d ( model , ( nlay , nrow , ncol ) , np . float32 , sy , name = '<STR_LIT>' , <EOL> locat = self . unit_number [ <NUM_LIT:0> ] ) <EOL> self . vkcb = Util3d ( model , ( nlay , nrow , ncol ) , np . float32 , vkcb , <EOL> name = '<STR_LIT>' , locat = self . unit_number [ <NUM_LIT:0> ] ) <EOL> self . wetdry = Util3d ( model , ( nlay , nrow , ncol ) , np . float32 , wetdry , <EOL> name = '<STR_LIT>' , locat = self . unit_number [ <NUM_LIT:0> ] ) <EOL> self . parent . add_package ( self ) <EOL> return <EOL> def write_file ( self , check = True ) : <EOL> """<STR_LIT>""" <EOL> if check : <EOL> self . check ( f = '<STR_LIT>' . format ( self . name [ <NUM_LIT:0> ] ) , verbose = self . parent . verbose , level = <NUM_LIT:1> ) <EOL> nrow , ncol , nlay , nper = self . parent . nrow_ncol_nlay_nper <EOL> f = open ( self . fn_path , '<STR_LIT:w>' ) <EOL> f . write ( '<STR_LIT>' % self . heading ) <EOL> f . write ( '<STR_LIT>' . format ( self . ipakcb , <EOL> self . hdry , <EOL> self . nplpf , <EOL> self . options ) ) <EOL> f . write ( self . laytyp . string ) <EOL> f . write ( self . layavg . string ) <EOL> f . write ( self . chani . string ) <EOL> f . write ( self . layvka . string ) <EOL> f . write ( self . laywet . string ) <EOL> iwetdry = self . laywet . sum ( ) <EOL> if iwetdry > <NUM_LIT:0> : <EOL> f . write ( '<STR_LIT>' . format ( self . wetfct , <EOL> self . iwetit , <EOL> self . ihdwet ) ) <EOL> transient = not self . parent . get_package ( '<STR_LIT>' ) . steady . all ( ) <EOL> for k in range ( nlay ) : <EOL> f . write ( self . hk [ k ] . get_file_entry ( ) ) <EOL> if self . chani [ k ] < <NUM_LIT:1> : <EOL> f . write ( self . hani [ k ] . get_file_entry ( ) ) <EOL> f . write ( self . vka [ k ] . get_file_entry ( ) ) <EOL> if transient == True : <EOL> f . write ( self . ss [ k ] . get_file_entry ( ) ) <EOL> if self . laytyp [ k ] != <NUM_LIT:0> : <EOL> f . write ( self . sy [ k ] . get_file_entry ( ) ) <EOL> if self . parent . get_package ( '<STR_LIT>' ) . laycbd [ k ] > <NUM_LIT:0> : <EOL> f . write ( self . vkcb [ k ] . get_file_entry ( ) ) <EOL> if ( self . laywet [ k ] != <NUM_LIT:0> and self . laytyp [ k ] != <NUM_LIT:0> ) : <EOL> f . write ( self . wetdry [ k ] . get_file_entry ( ) ) <EOL> f . close ( ) <EOL> return <EOL> '''<STR_LIT>''' <EOL> @ staticmethod <EOL> def load ( f , model , ext_unit_dict = None , check = True ) : <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> nrow , ncol , nlay , nper = model . get_nrow_ncol_nlay_nper ( ) <EOL> if model . verbose : <EOL> print ( '<STR_LIT>' ) <EOL> t = line . strip ( ) . split ( ) <EOL> ipakcb , hdry , nplpf = int ( t [ <NUM_LIT:0> ] ) , float ( t [ <NUM_LIT:1> ] ) , int ( t [ <NUM_LIT:2> ] ) <EOL> if ipakcb != <NUM_LIT:0> : <EOL> model . add_pop_key_list ( ipakcb ) <EOL> ipakcb = <NUM_LIT> <EOL> storagecoefficient = False <EOL> constantcv = False <EOL> thickstrt = False <EOL> nocvcorrection = False <EOL> novfc = False <EOL> if len ( t ) > <NUM_LIT:3> : <EOL> for k in range ( <NUM_LIT:3> , len ( t ) ) : <EOL> if '<STR_LIT>' in t [ k ] . upper ( ) : <EOL> storagecoefficient = True <EOL> elif '<STR_LIT>' in t [ k ] . upper ( ) : <EOL> constantcv = True <EOL> elif '<STR_LIT>' in t [ k ] . upper ( ) : <EOL> thickstrt = True <EOL> elif '<STR_LIT>' in t [ k ] . upper ( ) : <EOL> nocvcorrection = True <EOL> elif '<STR_LIT>' in t [ k ] . upper ( ) : <EOL> novfc = True <EOL> if model . verbose : <EOL> print ( '<STR_LIT>' ) <EOL> laytyp = np . empty ( ( nlay ) , dtype = np . int ) <EOL> laytyp = read1d ( f , laytyp ) <EOL> if model . verbose : <EOL> print ( '<STR_LIT>' ) <EOL> layavg = np . empty ( ( nlay ) , dtype = np . int ) <EOL> layavg = read1d ( f , layavg ) <EOL> if model . verbose : <EOL> print ( '<STR_LIT>' ) <EOL> chani = np . empty ( ( nlay ) , dtype = np . float32 ) <EOL> chani = read1d ( f , chani ) <EOL> if model . verbose : <EOL> print ( '<STR_LIT>' ) <EOL> layvka = np . empty ( ( nlay ) , dtype = np . float32 ) <EOL> layvka = read1d ( f , layvka ) <EOL> if model . verbose : <EOL> print ( '<STR_LIT>' ) <EOL> laywet = np . empty ( ( nlay ) , dtype = np . int ) <EOL> laywet = read1d ( f , laywet ) <EOL> wetfct , iwetit , ihdwet = None , None , None <EOL> iwetdry = laywet . sum ( ) <EOL> if iwetdry > <NUM_LIT:0> : <EOL> if model . verbose : <EOL> print ( '<STR_LIT>' ) <EOL> line = f . readline ( ) <EOL> t = line . strip ( ) . split ( ) <EOL> wetfct , iwetit , ihdwet = float ( t [ <NUM_LIT:0> ] ) , int ( t [ <NUM_LIT:1> ] ) , int ( t [ <NUM_LIT:2> ] ) <EOL> par_types = [ ] <EOL> if nplpf > <NUM_LIT:0> : <EOL> par_types , parm_dict = mfpar . load ( f , nplpf , model . verbose ) <EOL> transient = not model . get_package ( '<STR_LIT>' ) . steady . all ( ) <EOL> hk = [ <NUM_LIT:0> ] * nlay <EOL> hani = [ <NUM_LIT:0> ] * nlay <EOL> vka = [ <NUM_LIT:0> ] * nlay <EOL> ss = [ <NUM_LIT:0> ] * nlay <EOL> sy = [ <NUM_LIT:0> ] * nlay <EOL> vkcb = [ <NUM_LIT:0> ] * nlay <EOL> wetdry = [ <NUM_LIT:0> ] * nlay <EOL> for k in range ( nlay ) : <EOL> if model . verbose : <EOL> print ( '<STR_LIT>' . format ( k + <NUM_LIT:1> ) ) <EOL> if '<STR_LIT>' not in par_types : <EOL> t = Util2d . load ( f , model , ( nrow , ncol ) , np . float32 , '<STR_LIT>' , <EOL> ext_unit_dict ) <EOL> else : <EOL> line = f . readline ( ) <EOL> t = mfpar . parameter_fill ( model , ( nrow , ncol ) , '<STR_LIT>' , parm_dict , findlayer = k ) <EOL> hk [ k ] = t <EOL> if chani [ k ] < <NUM_LIT:0> : <EOL> if model . verbose : <EOL> print ( '<STR_LIT>' . format ( k + <NUM_LIT:1> ) ) <EOL> if '<STR_LIT>' not in par_types : <EOL> t = Util2d . load ( f , model , ( nrow , ncol ) , np . float32 , '<STR_LIT>' , <EOL> ext_unit_dict ) <EOL> else : <EOL> line = f . readline ( ) <EOL> t = mfpar . parameter_fill ( model , ( nrow , ncol ) , '<STR_LIT>' , parm_dict , findlayer = k ) <EOL> hani [ k ] = t <EOL> if model . verbose : <EOL> print ( '<STR_LIT>' . format ( k + <NUM_LIT:1> ) ) <EOL> key = '<STR_LIT>' <EOL> if layvka [ k ] != <NUM_LIT:0> : <EOL> key = '<STR_LIT>' <EOL> if '<STR_LIT>' not in par_types and '<STR_LIT>' not in par_types : <EOL> t = Util2d . load ( f , model , ( nrow , ncol ) , np . float32 , key , <EOL> ext_unit_dict ) <EOL> else : <EOL> line = f . readline ( ) <EOL> key = '<STR_LIT>' <EOL> if '<STR_LIT>' in par_types : <EOL> key = '<STR_LIT>' <EOL> t = mfpar . parameter_fill ( model , ( nrow , ncol ) , key , parm_dict , findlayer = k ) <EOL> vka [ k ] = t <EOL> if transient : <EOL> if model . verbose : <EOL> print ( '<STR_LIT>' . format ( k + <NUM_LIT:1> ) ) <EOL> if '<STR_LIT>' not in par_types : <EOL> t = Util2d . load ( f , model , ( nrow , ncol ) , np . float32 , '<STR_LIT>' , <EOL> ext_unit_dict ) <EOL> else : <EOL> line = f . readline ( ) <EOL> t = mfpar . parameter_fill ( model , ( nrow , ncol ) , '<STR_LIT>' , parm_dict , findlayer = k ) <EOL> ss [ k ] = t <EOL> if laytyp [ k ] != <NUM_LIT:0> : <EOL> if model . verbose : <EOL> print ( '<STR_LIT>' . format ( k + <NUM_LIT:1> ) ) <EOL> if '<STR_LIT>' not in par_types : <EOL> t = Util2d . load ( f , model , ( nrow , ncol ) , np . float32 , '<STR_LIT>' , <EOL> ext_unit_dict ) <EOL> else : <EOL> line = f . readline ( ) <EOL> t = mfpar . parameter_fill ( model , ( nrow , ncol ) , '<STR_LIT>' , parm_dict , findlayer = k ) <EOL> sy [ k ] = t <EOL> if model . get_package ( '<STR_LIT>' ) . laycbd [ k ] > <NUM_LIT:0> : <EOL> if model . verbose : <EOL> print ( '<STR_LIT>' . format ( k + <NUM_LIT:1> ) ) <EOL> if '<STR_LIT>' not in par_types : <EOL> t = Util2d . load ( f , model , ( nrow , ncol ) , np . float32 , '<STR_LIT>' , <EOL> ext_unit_dict ) <EOL> else : <EOL> line = f . readline ( ) <EOL> t = mfpar . parameter_fill ( model , ( nrow , ncol ) , '<STR_LIT>' , parm_dict , findlayer = k ) <EOL> vkcb [ k ] = t <EOL> if ( laywet [ k ] != <NUM_LIT:0> and laytyp [ k ] != <NUM_LIT:0> ) : <EOL> if model . verbose : <EOL> print ( '<STR_LIT>' . format ( k + <NUM_LIT:1> ) ) <EOL> t = Util2d . load ( f , model , ( nrow , ncol ) , np . float32 , '<STR_LIT>' , <EOL> ext_unit_dict ) <EOL> wetdry [ k ] = t <EOL> lpf = ModflowLpf ( model , ipakcb = ipakcb , laytyp = laytyp , layavg = layavg , chani = chani , <EOL> layvka = layvka , laywet = laywet , hdry = hdry , iwdflg = iwetdry , <EOL> wetfct = wetfct , iwetit = iwetit , ihdwet = ihdwet , <EOL> hk = hk , hani = hani , vka = vka , ss = ss , sy = sy , vkcb = vkcb , <EOL> wetdry = wetdry , storagecoefficient = storagecoefficient , <EOL> constantcv = constantcv , thickstrt = thickstrt , novfc = novfc ) <EOL> if check : <EOL> lpf . check ( f = '<STR_LIT>' . format ( lpf . name [ <NUM_LIT:0> ] ) , verbose = lpf . parent . verbose , level = <NUM_LIT:0> ) <EOL> return lpf </s>
