crunchflow.output.SpatialProfile ================================ .. py:class:: crunchflow.output.SpatialProfile(fileprefix, folder='.', output_times=None, suffix='.tec', warnings=True) The SpatialProfile class for working with spatial_profile (.tec, .out and .dat) files. :Parameters: **fileprefix** : str file prefix of the tec file to read in, without the timestep number or ".tec" file ending. For example, if your files are "volume1.tec", "volume2.tec", etc., then fileprefix should be "volume". **folder** : str, optional folder in which the .tec files are located. The default is the current directory **output_times** : list of float, optional list of the actual output times at which the .tec files were output, in CrunchFlow time units **suffix** : str, optional file ending of the tec files to read in. This can vary depending on the version of CrunchTope used. The default is '.tec', but '.out' is also tried if '.tec' files are not found. :Attributes: **times** : list of int relative times at which .tec files were output, sorted **files** : list of str ordered list of all files matching fileprefix **columns** : list of str list of all vars included within each .tec file **nx** : int # of grid cells in the x direction. Typically only defined for 2D and 3D output **ny** : int # of grid cells in the y direction. Typically only defined for 2D and 3D output **nz** : int # of grid cells in the z direction. Typically only defined for 2D and 3D output **coords** : ndarray of float (nx*ny*nz, 2) array of x, y coordinates of each node. Typically only defined for 2D and 3D output **griddedX** : ndarray of float (ny, nx) array of x coordinates; used for plotting. Typically only defined for 2D and 3D output **griddedY** : ndarray of float (ny, nx) array of y coordinates; used for plotting. Typically only defined for 2D and 3D output .. rubric:: Methods ====================================================== ========== **__init__(fileprefix, folder, output_times, suffix)** Read in and get basic info about all .tec files matching `fileprefix`. For example, `tec('volume')` will read in all files matching 'volume[0-9]+.tec' **extract(variable, time)** Return the spatial profile of var at the given time. **plot(variable, time)** Plot .tec output from a single time step. **plot_series(variable)** Plot .tec output for a series of time steps. **outline(variable, value, time)** Get line segments that outline all the regions equal to the provided value. ====================================================== ========== .. rubric:: Examples >>> vol = SpatialProfile('volume') >>> print(vol.columns) >>> vol.plot('Calcite') >>> calcite = vol.extract('Calcite', time=2) .. !! processed by numpydoc !! .. py:method:: extract(var, time=None, output_time=None) Return the spatial profile of var at the given time. :Parameters: **var** : str variable to return (e.g., 'Porosity') **time** : int time slice at which to return the profile. By default, returns the first time slice. **output_time** : float output time at which to return the profile. If provided, this will override the `time` parameter. If both `time` and `output_time` are provided, `time` will be ignored. :Returns: **data** : ndarray of float (ny, nx) numpy array of var .. !! processed by numpydoc !! .. py:method:: plot(var, time=None, output_time=None, plot_type='image', figsize=(12, 3), **kwargs) Plot .tec output from a single time step. :Parameters: **var** : str variable to plot (e.g., 'H+') **time** : int which time slice to show. Refers to the file number, not the output time. By default, plots the first time slice. **output_time** : float which output time to show. If provided, this will override the `time` parameter. If both `time` and `output_time` are provided, `time` will be ignored. **figsize** : tuple of int figure size; default (12, 3) **plot_type** : str whether to display an image ('image') or a color-filled contour plot ('contourf') **\*\*kwargs** : dict args passed on to matplotlib plot function (either contourf or imshow) :Returns: **fig** : pyplot object matplotlib fig handle for the plot **ax** : pyplot object matplotlib ax handle for the plot .. !! processed by numpydoc !! .. py:method:: plot_series(var, times=None, output_times=None, plot_type='image', figsize=None, **kwargs) Plot .tec output for a series of time steps. :Parameters: **var** : str variable to plot (e.g., 'H+') **times** : list time steps to plot, must be either components of self.times or self.output_times; defaults to all time steps **plot_type** : str whether to display an image ('image') or a contour-filled contour plot ('contourf') **output_times** : list of float, optional list of the actual output times at which the .tec files were output, in CrunchFlow time units. If provided, this will override the `times` parameter. If both `times` and `output_times` are provided, `times` will be ignored. **figsize** : tuple of int figure size; default (12, 1.5 * # of timesteps) **\*\*kwargs** : dict args passed on to matplotlib's imshow :Returns: **fig** : pyplot object matplotlib fig handle for the plot **axes** : list of pyplot objects list of matplotlib axes handles for each subplot .. !! processed by numpydoc !! .. py:method:: outline(var, value=None, time=None, output_time=None) For a given .tec file, get line segments that outline all the regions equal to the provided value. Useful for generating outlines of areas of a model domain sharing a single attribute (e.g., permeability) and later adding the outlines to a plot of a different variable. :Parameters: **var** : str variable to outline (e.g., 'Porosity') **value** : float value to outline. The default is least-frequent value in array **time** : int time slice at which to create an outline. By default, outlines the first time slice. **output_time** : float output time at which to create an outline. If provided, this will override the `time` parameter. If both `time` and `output_time` are provided, `time` will be ignored. :Returns: **segments** : ndarray of float array of (x,y) coordinate pairs for each line segment that comprises the outline .. rubric:: Examples >>> # Get stratigraphy from permeability map >>> perm = SpatialProfile('permeability') >>> segments = perm.outline('X-Perm') >>> >>> # Plot stratigraphy outlines on O2 map >>> conc = SpatialProfile('conc') >>> fig, ax = conc.plot('O2(aq)') >>> ax.plot(segments[:,0], segments[:,1]) .. !! processed by numpydoc !!