@staticmethod
    def load(f, model, nper=None, ext_unit_dict=None):

        if model.verbose:
            sys.stdout.write('loading vdf package file...\n')

        # Open file, if necessary
        if not hasattr(f, 'read'):
            filename = f
            f = open(filename, 'r')

        # Dataset 0 -- comment line
        while True:
            line = f.readline()
            if line[0] != '#':
                break

        # Determine problem dimensions
        nrow, ncol, nlay, nper = model.mf.get_nrow_ncol_nlay_nper()

        # Item 1: MT3DRHOFLG MFNADVFD NSWTCPL IWTABLE - line already read above
        if model.verbose:
            print('   loading MT3DRHOFLG MFNADVFD NSWTCPL IWTABLE...')
        t = line.strip().split()
        mt3drhoflg = int(t[0])
        mfnadvfd = int(t[1])
        nswtcpl = int(t[2])
        iwtable = int(t[3])
        if model.verbose:
            print('   MT3DRHOFLG {}'.format(mt3drhoflg))
            print('   MFNADVFD {}'.format(mfnadvfd))
            print('   NSWTCPL {}'.format(nswtcpl))
            print('   IWTABLE {}'.format(iwtable))

        # Item 2 -- DENSEMIN DENSEMAX
        if model.verbose:
            print('   loading DENSEMIN DENSEMAX...')
        line = f.readline()
        t = line.strip().split()
        densemin = float(t[0])
        densemax = float(t[1])

        # Item 3 -- DNSCRIT
        if model.verbose:
            print('   loading DNSCRIT...')
        dnscrit = None
        if nswtcpl > 1 or nswtcpl == -1:
            line = f.readline()
            t = line.strip().split()
            dnscrit = float(t[0])

        # Item 4 -- DENSEREF DRHODC
        drhodprhd = None
        prhdref = None
        nsrhoeos = None
        mtrhospec = None
        crhoref = None
        if mt3drhoflg >= 0:
            if model.verbose:
                print('   loading DENSEREF DRHODC(1)...')
            line = f.readline()
            t = line.strip().split()
            denseref = float(t[0])
            drhodc = float(t[1])
        else:
            if model.verbose:
                print('   loading DENSEREF DRHODPRHD PRHDREF...')
            line = f.readline()
            t = line.strip().split()
            denseref = float(t[0])
            drhodprhd = float(t[1])
            prhdref = float(t[2])

            if model.verbose:
                print('   loading NSRHOEOS...')
            line = f.readline()
            t = line.strip().split()
            nsrhoeos = int(t[0])

            if model.verbose:
                print('    loading MTRHOSPEC DRHODC CRHOREF...')
            mtrhospec = []
            drhodc = []
            crhoref = []
            for i in range(nsrhoeos):
                line = f.readline()
                t = line.strip().split()
                mtrhospec.append(int(t[0]))
                drhodc.append(float(t[1]))
                crhoref.append(float(t[2]))

        # Item 5 -- FIRSTDT
        if model.verbose:
            print('   loading FIRSTDT...')
        line = f.readline()
        t = line.strip().split()
        firstdt = float(t[0])

        # Items 6 and 7 -- INDENSE DENSE
        indense = None
        dense = None
        if mt3drhoflg == 0:
            if model.verbose:
                print('   loading INDENSE...')
            line = f.readline()
            t = line.strip().split()
            indense = int(t[0])

            if indense > 0:
                dense = [0] * nlay
                for k in range(nlay):
                    if model.verbose:
                        print('   loading DENSE layer {0:3d}...'.format(k + 1))
                    t = Util2d.load(f, model.mf, (nrow, ncol), np.float32,
                                     'dense', ext_unit_dict)
                    dense[k] = t

        # Construct and return vdf package
        vdf = SeawatVdf(model, mt3drhoflg=mt3drhoflg, mfnadvfd=mfnadvfd,
                        nswtcpl=nswtcpl, iwtable=iwtable,
                        densemin=densemin, densemax=densemax,
                        dnscrit=dnscrit, denseref=denseref, drhodc=drhodc,
                        drhodprhd=drhodprhd, prhdref=prhdref,
                        nsrhoeos=nsrhoeos, mtrhospec=mtrhospec,
                        crhoref=crhoref, indense=indense, dense=dense)
        return vdf
Load an existing package.
dataset/ETHPy150Open modflowpy/flopy/flopy/seawat/swtvdf.py/SeawatVdf.load