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
def plot(self, axes=None, kstpkper=None, totim=None, mflay=None, filename_base=None, **kwargs): ''' Plot 3-D model output data in a specific location in LayerFile instance Parameters ---------- 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) kstpkper : tuple of ints A tuple containing the time step and stress period (kstp, kper). These are zero-based kstp and kper values. totim : float The simulation time. mflay : int MODFLOW zero-based layer number to return. If None, then all all layers will be included. (default is None) 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) **kwargs : dict 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) 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. file_extension : str Valid matplotlib.pyplot file extension for savefig(). Only used if filename_base is not None. (default is 'png') Returns ---------- None See Also -------- Notes ----- Examples -------- >>> import flopy >>> hdobj = flopy.utils.HeadFile('test.hds') >>> times = hdobj.get_times() >>> hdobj.plot(totim=times[-1]) ''' if 'file_extension' in kwargs: fext = kwargs.pop('file_extension') fext = fext.replace('.', '') else: fext = 'png' filenames = None if filename_base is not None: if mflay is not None: i0 = int(mflay) if i0+1 >= self.nlay: i0 = self.nlay - 1 i1 = i0 + 1 else: i0 = 0 i1 = self.nlay filenames = [] [filenames.append('{}_Layer{}.{}'.format(filename_base, k+1, fext)) for k in range(i0, i1)] # make sure we have a (lay,row,col) shape plotarray plotarray = np.atleast_3d(self.get_data(kstpkper=kstpkper, totim=totim, mflay=mflay) .transpose()).transpose() import flopy.plot.plotutil as pu return pu._plot_array_helper(plotarray, model=self.model, sr=self.sr, axes=axes, filenames=filenames, mflay=mflay, **kwargs)
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
def plot(self, axes=None, kstpkper=None, totim=None, mflay=None, filename_base=None, **kwargs): ''' Plot 3-D model output data in a specific location in LayerFile instance Parameters ---------- 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) kstpkper : tuple of ints A tuple containing the time step and stress period (kstp, kper). These are zero-based kstp and kper values. totim : float The simulation time. mflay : int MODFLOW zero-based layer number to return. If None, then all all layers will be included. (default is None) 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) **kwargs : dict 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) 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. file_extension : str Valid matplotlib.pyplot file extension for savefig(). Only used if filename_base is not None. (default is 'png') Returns ---------- None See Also -------- Notes ----- Examples -------- >>> import flopy >>> hdobj = flopy.utils.HeadFile('test.hds') >>> times = hdobj.get_times() >>> hdobj.plot(totim=times[-1]) ''' if 'file_extension' in kwargs: fext = kwargs.pop('file_extension') fext = fext.replace('.', '') else: fext = 'png' masked_values = kwargs.pop("masked_values", []) if self.model is not None: if self.model.bas6 is not None: masked_values.append(self.model.bas6.hnoflo) kwargs["masked_values"] = masked_values filenames = None if filename_base is not None: if mflay is not None: i0 = int(mflay) if i0 + 1 >= self.nlay: i0 = self.nlay - 1 i1 = i0 + 1 else: i0 = 0 i1 = self.nlay filenames = [] [filenames.append( '{}_Layer{}.{}'.format(filename_base, k + 1, fext)) for k in range(i0, i1)] # make sure we have a (lay,row,col) shape plotarray plotarray = np.atleast_3d(self.get_data(kstpkper=kstpkper, totim=totim, mflay=mflay) .transpose()).transpose() import flopy.plot.plotutil as pu return pu._plot_array_helper(plotarray, model=self.model, sr=self.sr, axes=axes, filenames=filenames, mflay=mflay, **kwargs)