@staticmethod
    def load(f, model, nper=None, ext_unit_dict=None):
        """
        Load an existing package.

        Parameters
        ----------
        f : filename or file handle
            File to load.
        model : model object
            The model object (of type :class:`flopy.modflow.mf.Modflow`) to
            which this package will be added.
        nper : int
            The number of stress periods.  If nper is None, then nper will be
            obtained from the model object. (default is None).
        ext_unit_dict : dictionary, optional
            If the arrays in the file are specified using EXTERNAL,
            or older style array control records, then `f` should be a file
            handle.  In this case ext_unit_dict is required, which can be
            constructed using the function
            :class:`flopy.utils.mfreadnam.parsenamefile`.

        Returns
        -------
        oc : ModflowOc object
            ModflowOc object.

        Examples
        --------

        >>> import flopy
        >>> m = flopy.modflow.Modflow()
        >>> oc = flopy.modflow.ModflowOc.load('test.oc', m)

        """

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

        if nper is None:
            nrow, ncol, nlay, nper = model.get_nrow_ncol_nlay_nper()

        # initialize
        ihedfm = 0
        iddnfm = 0
        ihedun = 0
        iddnun = 0
        compact = False
        chedfm = None
        cddnfm = None
        words = []
        wordrec = []

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

        # process each line
        for line in f:
            lnlst = line.strip().split()
            if line[0] == '#':
                continue

            # added by JJS 12/12/14 to avoid error when there is a blank line in the OC file
            if lnlst == []:
                continue
            # end add

            # dataset 1 values
            elif ('HEAD' in lnlst[0].upper() and
                          'PRINT' in lnlst[1].upper() and
                          'FORMAT' in lnlst[2].upper()
                  ):
                ihedfm = int(lnlst[3])
            elif ('HEAD' in lnlst[0].upper() and
                          'SAVE' in lnlst[1].upper() and
                          'FORMAT' in lnlst[2].upper()
                  ):
                chedfm = lnlst[3]
            elif ('HEAD' in lnlst[0].upper() and
                          'SAVE' in lnlst[1].upper() and
                          'UNIT' in lnlst[2].upper()
                  ):
                ihedun = int(lnlst[3])
            elif ('DRAWDOWN' in lnlst[0].upper() and
                          'PRINT' in lnlst[1].upper() and
                          'FORMAT' in lnlst[2].upper()
                  ):
                iddnfm = int(lnlst[3])
            elif ('DRAWDOWN' in lnlst[0].upper() and
                          'SAVE' in lnlst[1].upper() and
                          'FORMAT' in lnlst[2].upper()
                  ):
                cddnfm = lnlst[3]
            elif ('DRAWDOWN' in lnlst[0].upper() and
                          'SAVE' in lnlst[1].upper() and
                          'UNIT' in lnlst[2].upper()
                  ):
                iddnun = int(lnlst[3])
            elif ('IBOUND' in lnlst[0].upper() and
                          'SAVE' in lnlst[1].upper() and
                          'FORMAT' in lnlst[2].upper()
                  ):
                cboufm = lnlst[3]
            elif ('IBOUND' in lnlst[0].upper() and
                          'SAVE' in lnlst[1].upper() and
                          'UNIT' >= lnlst[2].upper()
                  ):
                ibouun = int(lnlst[3])
            elif 'COMPACT' in lnlst[0].upper():
                compact = True

            # dataset 2
            elif 'PERIOD' in lnlst[0].upper():
                if len(wordrec) > 3:
                    words.append(wordrec)
                iperoc = int(lnlst[1])
                itsoc = int(lnlst[3])
                wordrec = [iperoc, itsoc]

            # dataset 3
            elif 'PRINT' in lnlst[0].upper() and 'HEAD' in lnlst[1].upper():
                wordrec.append('PHEAD')
            elif ('PRINT' in lnlst[0].upper() and
                          'DRAWDOWN' in lnlst[1].upper()):
                wordrec.append('PDRAWDOWN')
            elif 'PRINT' in lnlst[0].upper() and 'BUDGET' in lnlst[1].upper():
                wordrec.append('PBUDGET')
            elif 'SAVE' in lnlst[0].upper() and 'HEAD' in lnlst[1].upper():
                wordrec.append('HEAD')
            elif ('SAVE' in lnlst[0].upper() and
                          'DRAWDOWN' in lnlst[1].upper()):
                wordrec.append('DRAWDOWN')
            elif 'SAVE' in lnlst[0].upper() and 'IBOUND' in lnlst[1].upper():
                wordrec.append('IBOUND')
            elif 'SAVE' in lnlst[0].upper() and 'BUDGET' in lnlst[1].upper():
                wordrec.append('BUDGET')
            else:
                print('Old style oc files not supported for import.')
                print('Convert to words.')
                return ModflowOc88(model)

        # store the last record in word
        if len(wordrec) > 3:
            words.append(wordrec)

        # reset unit numbers
        unitnumber = [14, 51, 52, 53]
        if ihedun > 0:
            model.add_pop_key_list(ihedun)
            # unitnumber[1] = ihedun
        if iddnun > 0:
            model.add_pop_key_list(iddnun)
            # unitnumber[2] = iddnun

        # create instance of oc class
        oc = ModflowOc88(model, ihedfm=ihedfm, iddnfm=iddnfm,
                         extension=['oc', 'hds', 'ddn', 'cbc'],
                         unitnumber=unitnumber, words=words, compact=compact,
                         chedfm=chedfm, cddnfm=cddnfm)

        return oc
dataset/ETHPy150Open modflowpy/flopy/flopy/modflow/mfoc88.py/ModflowOc88.load/operator `in` -> `>=`