예제 #1
0
    def plot(self,
             key=None,
             names=None,
             kper=0,
             filename_base=None,
             file_extension=None,
             mflay=None,
             **kwargs):
        """
        Plot stress period boundary condition (MfList) data for a specified
        stress period

        Parameters
        ----------
        key : str
            MfList dictionary key. (default is None)
        names : list
            List of names for figure titles. (default is None)
        kper : int
            MODFLOW zero-based stress period number to return. (default is zero)
        filename_base : str
            Base file name that will be used to automatically generate file
            names for output image files. Plots will be exported as image
            files if file_name_base is not None. (default is None)
        file_extension : str
            Valid matplotlib.pyplot file extension for savefig(). Only used
            if filename_base is not None. (default is 'png')
        mflay : int
            MODFLOW zero-based layer number to return.  If None, then all
            all layers will be included. (default is None)
        **kwargs : dict
            axes : list of matplotlib.pyplot.axis
                List of matplotlib.pyplot.axis that will be used to plot
                data for each layer. If axes=None axes will be generated.
                (default is None)
            pcolor : bool
                Boolean used to determine if matplotlib.pyplot.pcolormesh
                plot will be plotted. (default is True)
            colorbar : bool
                Boolean used to determine if a color bar will be added to
                the matplotlib.pyplot.pcolormesh. Only used if pcolor=True.
                (default is False)
            inactive : bool
                Boolean used to determine if a black overlay in inactive
                cells in a layer will be displayed. (default is True)
            contour : bool
                Boolean used to determine if matplotlib.pyplot.contour
                plot will be plotted. (default is False)
            clabel : bool
                Boolean used to determine if matplotlib.pyplot.clabel
                will be plotted. Only used if contour=True. (default is False)
            grid : bool
                Boolean used to determine if the model grid will be plotted
                on the figure. (default is False)
            masked_values : list
                List of unique values to be excluded from the plot.

        Returns
        ----------
        out : list
            Empty list is returned if filename_base is not None. Otherwise
            a list of matplotlib.pyplot.axis is returned.

        See Also
        --------

        Notes
        -----

        Examples
        --------
        >>> import flopy
        >>> ml = flopy.modflow.Modflow.load('test.nam')
        >>> ml.wel.stress_period_data.plot(ml.wel, kper=1)

        """

        import flopy.plot.plotutil as pu

        if file_extension is not None:
            fext = file_extension
        else:
            fext = 'png'

        filenames = None
        if filename_base is not None:
            if mflay is not None:
                i0 = int(mflay)
                if i0 + 1 >= self.model.nlay:
                    i0 = self.model.nlay - 1
                i1 = i0 + 1
            else:
                i0 = 0
                i1 = self.model.nlay
            # build filenames
            pn = self.package.name[0].upper()
            filenames = [
                '{}_{}_StressPeriod{}_Layer{}.{}'.format(
                    filename_base, pn, kper + 1, k + 1, fext)
                for k in range(i0, i1)
            ]
        if names is None:
            if key is None:
                names = [
                    '{} location stress period: {} layer: {}'.format(
                        self.package.name[0], kper + 1, k + 1)
                    for k in range(self.model.nlay)
                ]
            else:
                names = [
                    '{} {} stress period: {} layer: {}'.format(
                        self.package.name[0], key, kper + 1, k + 1)
                    for k in range(self.model.nlay)
                ]

        if key is None:
            axes = pu._plot_bc_helper(self.package,
                                      kper,
                                      names=names,
                                      filenames=filenames,
                                      mflay=mflay,
                                      **kwargs)
        else:
            arr_dict = self.to_array(kper, mask=True)

            try:
                arr = arr_dict[key]
            except:
                p = 'Cannot find key to plot\n'
                p += '  Provided key={}\n  Available keys='.format(key)
                for name, arr in arr_dict.items():
                    p += '{}, '.format(name)
                p += '\n'
                raise Exception(p)

            axes = pu._plot_array_helper(arr,
                                         model=self.model,
                                         names=names,
                                         filenames=filenames,
                                         mflay=mflay,
                                         **kwargs)
        return axes
예제 #2
0
    def plot(self, key=None, names=None, kper=0,
             filename_base=None, file_extension=None, mflay=None,
             **kwargs):
        """
        Plot stress period boundary condition (MfList) data for a specified
        stress period

        Parameters
        ----------
        key : str
            MfList dictionary key. (default is None)
        names : list
            List of names for figure titles. (default is None)
        kper : int
            MODFLOW zero-based stress period number to return. (default is zero)
        filename_base : str
            Base file name that will be used to automatically generate file
            names for output image files. Plots will be exported as image
            files if file_name_base is not None. (default is None)
        file_extension : str
            Valid matplotlib.pyplot file extension for savefig(). Only used
            if filename_base is not None. (default is 'png')
        mflay : int
            MODFLOW zero-based layer number to return.  If None, then all
            all layers will be included. (default is None)
        **kwargs : dict
            axes : list of matplotlib.pyplot.axis
                List of matplotlib.pyplot.axis that will be used to plot
                data for each layer. If axes=None axes will be generated.
                (default is None)
            pcolor : bool
                Boolean used to determine if matplotlib.pyplot.pcolormesh
                plot will be plotted. (default is True)
            colorbar : bool
                Boolean used to determine if a color bar will be added to
                the matplotlib.pyplot.pcolormesh. Only used if pcolor=True.
                (default is False)
            inactive : bool
                Boolean used to determine if a black overlay in inactive
                cells in a layer will be displayed. (default is True)
            contour : bool
                Boolean used to determine if matplotlib.pyplot.contour
                plot will be plotted. (default is False)
            clabel : bool
                Boolean used to determine if matplotlib.pyplot.clabel
                will be plotted. Only used if contour=True. (default is False)
            grid : bool
                Boolean used to determine if the model grid will be plotted
                on the figure. (default is False)
            masked_values : list
                List of unique values to be excluded from the plot.

        Returns
        ----------
        out : list
            Empty list is returned if filename_base is not None. Otherwise
            a list of matplotlib.pyplot.axis is returned.

        See Also
        --------

        Notes
        -----

        Examples
        --------
        >>> import flopy
        >>> ml = flopy.modflow.Modflow.load('test.nam')
        >>> ml.wel.stress_period_data.plot(ml.wel, kper=1)

        """

        import flopy.plot.plotutil as pu

        if file_extension is not None:
            fext = file_extension
        else:
            fext = 'png'

        filenames = None
        if filename_base is not None:
            if mflay is not None:
                i0 = int(mflay)
                if i0 + 1 >= self.model.nlay:
                    i0 = self.model.nlay - 1
                i1 = i0 + 1
            else:
                i0 = 0
                i1 = self.model.nlay
            # build filenames
            pn = self.package.name[0].upper()
            filenames = [
                '{}_{}_StressPeriod{}_Layer{}.{}'.format(filename_base, pn,
                                                         kper + 1, k + 1, fext)
                for k in range(i0, i1)]
        if names is None:
            if key is None:
                names = ['{} location stress period: {} layer: {}'.format(
                    self.package.name[0], kper + 1, k + 1)
                         for k in range(self.model.nlay)]
            else:
                names = ['{} {} stress period: {} layer: {}'.format(
                    self.package.name[0], key, kper + 1, k + 1)
                         for k in range(self.model.nlay)]

        if key is None:
            axes = pu._plot_bc_helper(self.package, kper,
                                      names=names, filenames=filenames,
                                      mflay=mflay, **kwargs)
        else:
            arr_dict = self.to_array(kper)

            try:
                arr = arr_dict[key]
            except:
                p = 'Cannot find key to plot\n'
                p += '  Provided key={}\n  Available keys='.format(key)
                for name, arr in arr_dict.items():
                    p += '{}, '.format(name)
                p += '\n'
                raise Exception(p)

            axes = pu._plot_array_helper(arr, model=self.model,
                                         names=names, filenames=filenames,
                                         mflay=mflay, **kwargs)
        return axes