How to use the flopy.utils.flopy_io.line_parse 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 / modflow / mfsfr2.py View on Github external
def _parse_6bc(line, icalc, nstrm, isfropt, reachinput, per=0):
    """Parse Data Set 6b for SFR2 package.
    See http://water.usgs.gov/nrp/gwsoftware/modflow2000/MFDOC/index.html?sfr.htm for more info

    Parameters
    ----------
    line : str
        line read from SFR package input file

    Returns
    -------
        a list of length 9 containing all variables for Data Set 6b
    """
    na = 0
    # line = [s for s in line.strip().split() if s.isnumeric()]
    nvalues = sum([_isnumeric(s) for s in line_parse(line)])
    line = _get_dataset(line, [0] * nvalues)

    hcond, thickm, elevupdn, width, depth, thts, thti, eps, uhc = [0.0] * 9

    if isfropt in [0, 4, 5] and icalc <= 0:
        hcond = line.pop(0)
        thickm = line.pop(0)
        elevupdn = line.pop(0)
        width = line.pop(0)
        depth = line.pop(0)
    elif isfropt in [0, 4, 5] and icalc == 1:
        hcond = line.pop(0)
        if isfropt in [4,5] and per > 0:
            pass
        else:
            thickm = line.pop(0)
github modflowpy / flopy / flopy / modflow / mfrch.py View on Github external
pak_parms = None
        if npar > 0:
            pak_parms = mfparbc.loadarray(f, npar, model.verbose)

        if nper is None:
            nrow, ncol, nlay, nper = model.get_nrow_ncol_nlay_nper()
        # read data for every stress period
        rech = {}
        irch = None
        if nrchop == 2:
            irch = {}
        current_rech = []
        current_irch = []
        for iper in range(nper):
            line = f.readline()
            t = line_parse(line)
            inrech = int(t[0])
            if nrchop == 2:
                inirch = int(t[1])
            if inrech >= 0:
                if npar == 0:
                    if model.verbose:
                        txt = 3 * ' ' + 'loading rech stress ' + \
                              'period {0:3d}...'.format(iper + 1)
                        print(txt)
                    t = Util2d.load(f, model, (nrow, ncol), np.float32, 'rech',
                                    ext_unit_dict)
                else:
                    parm_dict = {}
                    for ipar in range(inrech):
                        line = f.readline()
                        t = line.strip().split()
github modflowpy / flopy / flopy / modflow / mfmnw2.py View on Github external
def _parse_2(f):
    """

    Parameters
    ----------
    f

    Returns
    -------

    """
    # dataset 2a
    line = line_parse(get_next_line(f))
    if len(line) > 2:
        warnings.warn('MNW2: {}\n'.format(line) +
                      'Extra items in Dataset 2a!' +
                      'Check for WELLIDs with space ' +
                      'but not enclosed in quotes.')
    wellid = pop_item(line).lower()
    nnodes = pop_item(line, int)
    # dataset 2b
    line = line_parse(get_next_line(f))
    losstype = pop_item(line)
    pumploc = pop_item(line, int)
    qlimit = pop_item(line, int)
    ppflag = pop_item(line, int)
    pumpcap = pop_item(line, int)

    # dataset 2c
github modflowpy / flopy / flopy / modflow / mfhfb.py View on Github external
if model.verbose:
            sys.stdout.write('loading hfb6 package file...\n')

        openfile = not hasattr(f, 'read')
        if openfile:
            filename = f
            f = open(filename, 'r')

        # dataset 0 -- header
        while True:
            line = f.readline()
            if line[0] != '#':
                break
        # dataset 1
        t = line_parse(line)
        nphfb = int(t[0])
        mxfb = int(t[1])
        nhfbnp = int(t[2])
        # check for no-print suppressor
        options = []
        aux_names = []
        if len(t) > 2:
            it = 2
            while it < len(t):
                toption = t[it]
                # print it, t[it]
                if toption.lower() == 'noprint':
                    options.append(toption)
                elif 'aux' in toption.lower():
                    options.append(' '.join(t[it:it + 2]))
                    aux_names.append(t[it + 1].lower())
github modflowpy / flopy / flopy / modflow / mfsfr2.py View on Github external
def _get_dataset(line, dataset):
    tmp = []
    # interpret number supplied with decimal points as floats, rest as ints
    # this could be a bad idea (vs. explicitly formatting values for each dataset)
    for i, s in enumerate(line_parse(line)):
        try:
            n = int(s)
        except:
            try:
                n = float(s)
            except:
                break
        dataset[i] = n
    return dataset
github modflowpy / flopy / flopy / modflow / mfdis.py View on Github external
'botm', ext_unit_dict)
        else:
            botm = Util3d.load(f, model, (nlay, nrow, ncol), np.float32,
                               'botm',
                               ext_unit_dict)
        # dataset 7 -- stress period info
        if model.verbose:
            print('   loading stress period data...')
            print('       for {} stress periods'.format(nper))
        perlen = []
        nstp = []
        tsmult = []
        steady = []
        for k in range(nper):
            line = f.readline()
            a1, a2, a3, a4 = line_parse(line)[0:4]
            a1 = float(a1)
            a2 = int(a2)
            a3 = float(a3)
            if a4.upper() == 'TR':
                a4 = False
            else:
                a4 = True
            perlen.append(a1)
            nstp.append(a2)
            tsmult.append(a3)
            steady.append(a4)

        if openfile:
            f.close()

        # set package unit number
github modflowpy / flopy / flopy / modflow / mfsfr2.py View on Github external
def _get_dataset(line, dataset):
    tmp = []
    # interpret number supplied with decimal points as floats, rest as ints
    # this could be a bad idea (vs. explicitly formatting values for each dataset)
    for i, s in enumerate(line_parse(line)):
        try:
            n = int(s)
        except:
            try:
                n = float(s)
            except:
                break
        dataset[i] = n
    return dataset
github modflowpy / flopy / flopy / modflow / mfmnwi.py View on Github external
f = open(filename, 'r')

        # dataset 1
        line = line_parse(next(f))
        wel1flag, qsumflag, byndflag = map(int, line)
        if wel1flag > 0:
            model.add_pop_key_list(wel1flag)
        if qsumflag > 0:
            model.add_pop_key_list(qsumflag)
        if byndflag > 0:
            model.add_pop_key_list(byndflag)


        # dataset 2
        unique_units = []
        mnwobs = pop_item(line_parse(next(f)), int)
        wellid_unit_qndflag_qhbflag_concflag = []
        if mnwobs > 0:
            for i in range(mnwobs):
                # dataset 3
                line = line_parse(next(f))
                wellid = pop_item(line, str)
                unit = pop_item(line, int)
                qndflag = pop_item(line, int)
                qbhflag = pop_item(line, int)
                tmp = [wellid, unit, qndflag, qbhflag]
                if gwt and len(line) > 0:
                    tmp.append(pop_item(line, int))
                wellid_unit_qndflag_qhbflag_concflag.append(tmp)
                if unit not in unique_units:
                    unique_units.append(unit)
github modflowpy / flopy / flopy / modflow / mfmnw2.py View on Github external
line = line_parse(get_next_line(f))
        if pumploc > 0:
            pumplay = pop_item(line, int)
            pumprow = pop_item(line, int)
            pumpcol = pop_item(line, int)
        else:
            zpump = pop_item(line, float)
    # dataset 2f
    hlim = None
    qcut = None
    qfrcmx = None
    qfrcmn = None
    if qlimit > 0:
        # Only specify dataset 2f if the value of Qlimit in dataset 2b is positive.
        # Do not enter fractions as percentages.
        line = line_parse(get_next_line(f))
        hlim = pop_item(line, float)
        qcut = pop_item(line, int)
        if qcut != 0:
            qfrcmn = pop_item(line, float)
            qfrcmx = pop_item(line, float)
    # dataset 2g
    hlift = None
    liftq0 = None
    liftqmax = None
    hwtol = None
    if pumpcap > 0:
        # The number of additional data points on the curve (and lines in dataset 2h)
        # must correspond to the value of PUMPCAP for this well (where PUMPCAP <= 25).
        line = line_parse(get_next_line(f))
        hlift = pop_item(line, float)
        liftq0 = pop_item(line, float)