How to use the flopy.utils.Util2d function in flopy

To help you get started, we’ve selected a few flopy examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github modflowpy / flopy / flopy / mt3d / mtbtn.py View on Github external
name='nstp',
                               locat=self.unit_number[0])

        if tsmult is not None:
            self.tsmult = Util2d(self.parent, (nper,), np.float32, tsmult,
                                 name='tsmult',
                                 locat=self.unit_number[0])
        else:
            self.tsmult = Util2d(self.parent, (nper,), np.float32,
                                 mf.dis.tsmult.get_value(),
                                 name='tsmult',
                                 locat=self.unit_number[0])

        self.laycon = None
        if laycon is not None:
            self.laycon = Util2d(self.parent, (nlay,), np.int32, laycon,
                                 name='laycon',
                                 locat=self.unit_number[0])
        else:
            flow_package = mf.get_package('BCF6')
            if flow_package is not None:
                self.laycon = Util2d(self.parent, (nlay,), np.int32,
                                     flow_package.laycon.get_value(),
                                     name='laycon',
                                     locat=self.unit_number[0])
            else:
                flow_package = mf.get_package('LPF')
                if flow_package is not None:
                    self.laycon = Util2d(self.parent, (nlay,),
                                         np.int32,
                                         flow_package.laytyp.get_value(),
                                         name='laycon',
github modflowpy / flopy / flopy / mt3d / mtbtn.py View on Github external
locat=self.unit_number[0],
                               array_free_format=False)

        if delc is not None:
            self.delc = Util2d(self.parent, (nrow,), np.float32, delc,
                               name='delc',
                               locat=self.unit_number[0])
        else:
            self.delc = Util2d(self.parent, (nrow,), np.float32,
                               mf.dis.delc.get_value(),
                               name='delc',
                               locat=self.unit_number[0],
                               array_free_format=False)

        if htop is not None:
            self.htop = Util2d(self.parent, (nrow, ncol), np.float32, htop,
                               name='htop',
                               locat=self.unit_number[0],
                               array_free_format=False)
        else:
            self.htop = Util2d(self.parent, (nrow, ncol), np.float32,
                               mf.dis.top.get_value(),
                               name='htop',
                               locat=self.unit_number[0],
                               array_free_format=False)

        if dz is not None:
            self.dz = Util3d(self.parent, (nlay, nrow, ncol), np.float32, dz,
                             name='dz',
                             locat=self.unit_number[0],
                             array_free_format=False)
        else:
github modflowpy / flopy / flopy / modflow / mfsubwt.py View on Github external
self.ivoid = int(ivoid)
        self.istpcs = int(istpcs)
        self.icrcc = int(icrcc)

        self.izcfl = int(izcfl)
        self.izcfm = int(izcfm)
        self.iglfl = int(iglfl)
        self.iglfm = int(iglfm)
        self.iestfl = int(iestfl)
        self.iestfm = int(iestfm)
        self.ipcsfl = int(ipcsfl)
        self.ipcsfm = int(ipcsfm)
        self.istfl = int(istfl)
        self.istfm = int(istfm)

        self.lnwt = Util2d(model,(self.nsystm,),np.int,lnwt,name="lnwt",
                           locat=self.unit_number[0])
        self.gl0 = Util2d(model,(nrow,ncol),np.float32,gl0,name="gl0",
                          locat=self.unit_number[0])
        self.sgs = Util2d(model,(nrow,ncol),np.float32,sgs,name="sgs",
                          locat=self.unit_number[0])
        self.sgm = Util2d(model,(nrow,ncol),np.float32,sgm,name="sgm",
                          locat=self.unit_number[0])

        if isinstance(thick,list):
            assert len(thick) == self.nsystm
        else:
            thick = [thick] * self.nsystm
        self.thick = [Util2d(model,(nrow,ncol),np.float32,t,name="thick_nsy{0}"\
                             .format(i),locat=self.unit_number[0])\
                      for i,t in enumerate(thick)]
github modflowpy / flopy / flopy / modflow / mfupw.py View on Github external
unit_number=units, extra=extra, filenames=fname)

        self.heading = '# {} package for '.format(self.name[0]) + \
                       ' {}, '.format(model.version_types[model.version]) + \
                       'generated by Flopy.'
        self.url = 'upw_upstream_weighting_package.htm'

        nrow, ncol, nlay, nper = self.parent.nrow_ncol_nlay_nper
        # item 1
        self.ipakcb = ipakcb
        # Head in cells that are converted to dry during a simulation
        self.hdry = hdry
        # number of UPW parameters
        self.npupw = 0
        self.iphdry = iphdry
        self.laytyp = Util2d(model, (nlay,), np.int32, laytyp, name='laytyp')
        self.layavg = Util2d(model, (nlay,), np.int32, layavg, name='layavg')
        self.chani = Util2d(model, (nlay,), np.float32, chani, name='chani')
        self.layvka = Util2d(model, (nlay,), np.int32, layvka, name='vka')
        self.laywet = Util2d(model, (nlay,), np.int32, laywet, name='laywet')

        self.options = ' '
        if noparcheck: self.options = self.options + 'NOPARCHECK  '

        self.hk = Util3d(model, (nlay, nrow, ncol), np.float32, hk, name='hk',
                         locat=self.unit_number[0])
        self.hani = Util3d(model, (nlay, nrow, ncol), np.float32, hani,
                           name='hani', locat=self.unit_number[0])
        keys = []
        for k in range(nlay):
            key = 'vka'
            if self.layvka[k] != 0:
github modflowpy / flopy / flopy / modflow / mfdisu.py View on Github external
if self.ivsd == 1:
            if ivc is None:
                raise Exception('ivc must be provided if ivsd is 1.')
            self.ivc = Util2d(model, (self.njag,), np.int32,
                              ivc, name='ivc', locat=self.unit_number[0])

        # Connection lengths
        if idsymrd == 1:
            njags = int((njag - nodes) / 2)
            if cl1 is None:
                raise Exception('idsymrd is 1 but cl1 was not specified.')
            if cl2 is None:
                raise Exception('idsymrd is 1 but cl2 was not specified.')
            self.cl1 = Util2d(model, (njags,), np.float32,
                              cl1, name='cl1', locat=self.unit_number[0])
            self.cl2 = Util2d(model, (njags,), np.float32,
                              cl2, name='cl2', locat=self.unit_number[0])

        if idsymrd == 0:
            if cl12 is None:
                raise Exception('idsymrd is 0 but cl12 was not specified')
            self.cl12 = Util2d(model, (self.njag,), np.float32,
                               cl12, name='cl12', locat=self.unit_number[0])

        # Flow area (set size of array to njag or njags depending on idsymrd)
        if fahl is None:
            raise Exception('fahl must be provided')
        if idsymrd == 1:
            n = njags
        elif idsymrd == 0:
            n = self.njag
        self.fahl = Util2d(model, (n,), np.float32,
github modflowpy / flopy / flopy / mt3d / mtdsp.py View on Github external
print('   loading DMCOEFF...')
        kwargs = {}
        dmcoef = []
        if multiDiff:
            dmcoef = Util3d.load(f, model, (nlay, nrow, ncol), np.float32,
                                 'dmcoef1', ext_unit_dict, array_format="mt3d")
            if model.mcomp > 1:
                for icomp in range(2, model.mcomp + 1):
                    name = "dmcoef" + str(icomp)
                    u3d = Util3d.load(f, model, (nlay, nrow, ncol), np.float32,
                                      name, ext_unit_dict, array_format="mt3d")
                    kwargs[name] = u3d


        else:
            dmcoef = Util2d.load(f, model, (nlay,), np.float32,
                                 'dmcoef1', ext_unit_dict, array_format="mt3d")
            # if model.mcomp > 1:
            #     for icomp in range(2, model.mcomp + 1):
            #         name = "dmcoef" + str(icomp + 1)
            #         u2d = Util2d.load(f, model, (nlay,), np.float32, name,
            #                     ext_unit_dict, array_format="mt3d")
            #         kwargs[name] = u2d

        if openfile:
            f.close()

        # set package unit number
        unitnumber = None
        filenames = [None]
        if ext_unit_dict is not None:
            unitnumber, filenames[0] = \
github modflowpy / flopy / flopy / modflow / mflpf.py View on Github external
if model.verbose:
                    print('   loading vkcb layer {0:3d}...'.format(k + 1))
                if 'vkcb' not in par_types:
                    t = Util2d.load(f, model, (nrow, ncol), np.float32, 'vkcb',
                                    ext_unit_dict)
                else:
                    line = f.readline()
                    t = mfpar.parameter_fill(model, (nrow, ncol), 'vkcb',
                                             parm_dict, findlayer=k)
                vkcb[k] = t

            # wetdry
            if (laywet[k] != 0 and laytyp[k] != 0):
                if model.verbose:
                    print('   loading wetdry layer {0:3d}...'.format(k + 1))
                t = Util2d.load(f, model, (nrow, ncol), np.float32, 'wetdry',
                                ext_unit_dict)
                wetdry[k] = t

        if openfile:
            f.close()

        # set package unit number
        unitnumber = None
        filenames = [None, None]
        if ext_unit_dict is not None:
            unitnumber, filenames[0] = \
                model.get_ext_dict_attr(ext_unit_dict,
                                        filetype=ModflowLpf.ftype())
            if ipakcb > 0:
                iu, filenames[1] = \
                    model.get_ext_dict_attr(ext_unit_dict, unit=ipakcb)
github modflowpy / flopy / flopy / modflow / mfdis.py View on Github external
'generated by Flopy.'
        self.laycbd = Util2d(model, (self.nlay,), np.int32, laycbd,
                             name='laycbd')
        self.laycbd[-1] = 0  # bottom layer must be zero
        self.delr = Util2d(model, (self.ncol,), np.float32, delr, name='delr',
                           locat=self.unit_number[0])
        self.delc = Util2d(model, (self.nrow,), np.float32, delc, name='delc',
                           locat=self.unit_number[0])
        self.top = Util2d(model, (self.nrow, self.ncol), np.float32,
                          top, name='model_top', locat=self.unit_number[0])
        self.botm = Util3d(model, (self.nlay + sum(self.laycbd),
                                   self.nrow, self.ncol), np.float32, botm,
                           'botm', locat=self.unit_number[0])
        self.perlen = Util2d(model, (self.nper,), np.float32, perlen,
                             name='perlen')
        self.nstp = Util2d(model, (self.nper,), np.int32, nstp, name='nstp')
        self.tsmult = Util2d(model, (self.nper,), np.float32, tsmult,
                             name='tsmult')
        self.steady = Util2d(model, (self.nper,), np.bool,
                             steady, name='steady')

        try:
            self.itmuni = int(itmuni)
        except:
            self.itmuni = ITMUNI[itmuni.lower()[0]]
        try:
            self.lenuni = int(lenuni)
        except:
            self.lenuni = LENUNI[lenuni.lower()[0]]

        self.parent.add_package(self)
        self.itmuni_dict = {0: "undefined", 1: "seconds", 2: "minutes",
github modflowpy / flopy / flopy / modflow / mflpf.py View on Github external
unit_number=units, extra=extra, filenames=fname)

        self.heading = '# {} package for '.format(self.name[0]) + \
                       ' {}, '.format(model.version_types[model.version]) + \
                       'generated by Flopy.'
        self.url = 'lpf.htm'
        nrow, ncol, nlay, nper = self.parent.nrow_ncol_nlay_nper

        # item 1
        self.ipakcb = ipakcb
        self.hdry = hdry  # Head in cells that are converted to dry during a simulation
        self.nplpf = 0  # number of LPF parameters
        self.laytyp = Util2d(model, (nlay,), np.int32, laytyp, name='laytyp')
        self.layavg = Util2d(model, (nlay,), np.int32, layavg, name='layavg')
        self.chani = Util2d(model, (nlay,), np.float32, chani, name='chani')
        self.layvka = Util2d(model, (nlay,), np.int32, layvka, name='layvka')
        self.laywet = Util2d(model, (nlay,), np.int32, laywet, name='laywet')
        # Factor that is included in the calculation of the head when a cell is
        # converted from dry to wet
        self.wetfct = wetfct
        # Iteration interval for attempting to wet cells
        self.iwetit = iwetit
        # Flag that determines which equation is used to define the initial
        # head at cells that become wet
        self.ihdwet = ihdwet
        self.options = ' '
        if storagecoefficient:
            self.options = self.options + 'STORAGECOEFFICIENT '
        if constantcv: self.options = self.options + 'CONSTANTCV '
        if thickstrt: self.options = self.options + 'THICKSTRT '
        if nocvcorrection: self.options = self.options + 'NOCVCORRECTION '
        if novfc: self.options = self.options + 'NOVFC '
github modflowpy / flopy / flopy / modflow / mflpf.py View on Github external
Package.__init__(self, model, extension=extension, name=name,
                         unit_number=units, extra=extra, filenames=fname)

        self.heading = '# {} package for '.format(self.name[0]) + \
                       ' {}, '.format(model.version_types[model.version]) + \
                       'generated by Flopy.'
        self.url = 'lpf.htm'
        nrow, ncol, nlay, nper = self.parent.nrow_ncol_nlay_nper

        # item 1
        self.ipakcb = ipakcb
        self.hdry = hdry  # Head in cells that are converted to dry during a simulation
        self.nplpf = 0  # number of LPF parameters
        self.laytyp = Util2d(model, (nlay,), np.int32, laytyp, name='laytyp')
        self.layavg = Util2d(model, (nlay,), np.int32, layavg, name='layavg')
        self.chani = Util2d(model, (nlay,), np.float32, chani, name='chani')
        self.layvka = Util2d(model, (nlay,), np.int32, layvka, name='layvka')
        self.laywet = Util2d(model, (nlay,), np.int32, laywet, name='laywet')
        # Factor that is included in the calculation of the head when a cell is
        # converted from dry to wet
        self.wetfct = wetfct
        # Iteration interval for attempting to wet cells
        self.iwetit = iwetit
        # Flag that determines which equation is used to define the initial
        # head at cells that become wet
        self.ihdwet = ihdwet
        self.options = ' '
        if storagecoefficient:
            self.options = self.options + 'STORAGECOEFFICIENT '
        if constantcv: self.options = self.options + 'CONSTANTCV '
        if thickstrt: self.options = self.options + 'THICKSTRT '
        if nocvcorrection: self.options = self.options + 'NOCVCORRECTION '