InvPyplot package
- invplot.autoplot(inv_file, iteration, verbose=False, **kwargs)[source]
Function to run all intermedaite functions and resinv_plot to simply read and plot everything in one call.
- Parameters:
- inv_filestr or pathlib.PurePath object
Filepath to .inv file of interest. The .inv file should be one generated from Res2DInv.
- iterationint or list or either str {‘:’, ‘all’}
Integer or list of integers indicating which iteration of the .inv result to use for plotting. If list, all will be plotted separately. If ‘:’ or ‘all’, will plot all iterations successively.
- verbosebool, optional
Whether to print results out to terminal along the way, by default False
- **kwargs
Other keyword arguments may be read into autoplot. These are read in as **kwargs to either resinv_plot() or matplotlib.pyplot.imshow via the resinv_plot function. See documentation for resinv_plot for available parameters for resinv_plot.
- Returns:
- inv_dictdict
Dictionary containing all input parameters and data generated along the way, including the output figures and axes
- invplot.get_resistivitiy_model(inv_file, inv_dict)[source]
Function to read the resistivity model, given the iteration of interest.
- Parameters:
- inv_filestr or pathlib.Path object
Filepath to .inv file of interest
- inv_dictdict
Dictionary containing cumulative output from invest_inv, read_inv_data, read_inv_data_other, and read_error_data.
- Returns:
- dict
Dictionary with resistivity model contained in new key:value pair of inv_dict
- invplot.ingest_inv(inv_file, verbose=True, show_iterations=True)[source]
Function to ingest inversion file and get key points (row numbers) in the file
- Parameters:
- inv_filestr or pathlib.Path object
The res2Dinv .inv file to work with.
- verbosebool, default=True
Whether to print results to terminal. Here, prints a pandas dataframe with information about iterations.
- show_iterationsbool, default=True
Whether to show a matplotlib plot with the iteration on x axis and percent error on y axis.
- Returns:
- inv_dictdict
Dictionary containing the important locations in the file
- invplot.map_diff(xIn, x1, x2, y1, y2)[source]
Simple, linear interpolation between two points
- Parameters:
- xInfloat, int, or numeric
X Location at which y-value is desired. This should fall between (or be equal to) x1 and x2
- x1float, int, or numeric
Initial X location, with known y-value y1
- x2float, int, or numeric
Second X location, with known y-value y2
- y1float, int, or numeric
Known y-value at x1
- y2float, int, or numeric
Known y-value at x2
- Returns:
- float
Y-value that is proportionally scaled based on the xIn relative distance to x1 and x2
- invplot.read_error_data(inv_file, inv_dict)[source]
Function to read data pertaining to model error
- Parameters:
- inv_filestr or pathlib.Path object
Filepath to .inv file of interest
- inv_dictdict
Dictionary containing cumulative output from ingest_inv, read_inv_data, and read_inv_data_other
- Returns:
- dict
Ouptput dictionary containing all information from read_error_data and previous functions.
- invplot.read_inv_data(inv_file, inv_dict, startRow=9)[source]
Function to do initial read of .inv file.
This data does not change with iteration, as in later function. This function should be readafter ingest_inv, using the output from that as inv_dict.
- Parameters:
- inv_filestr or pathlib.Path object
Filepath of .inv file
- inv_dictdict
Dictionary (output from ingest_inv) containing information about where data is located in the .inv file
- startRowint, optional
Where to start the read. This is, by default 9, which works well for .inv files tested.
- Returns:
- _type_
_description_
- invplot.read_inv_data_other(inv_file, inv_dict, iteration_no=None)[source]
Function to read inversion data.
- Parameters:
- inv_filestr or pathlib.Path object
Filepath to .inv file of interest.
- inv_dictdict
Dictionary contianing outputs from ingest_inv and read_in_data.
- iteration_noint
Iteration number of interest.
- Returns:
- dict
Dictionary with more information appended to input dictionary
- invplot.resinv_plot(inv_dict, colMap='nipy_spectral', cBarFormat='%3.0f', cBarLabel='Resistivity (ohm-m)', cBarOrientation='horizontal', cMin=None, cMax=None, griddedFt=[False, False], griddedM=[False, False], title=None, normType='log', primaryUnit='m', showPoints=False, whichTicks='major', figsize=None, dpi=None, reverse=False, tight_layout=True, savefig=False, saveformat='png', imshow_kwargs=None, **kwargs)[source]
Function to pull everything together and plot it nicely.
It is recommended to use the autoplot function rather than resinv_plot directly, since using autoplot() incorporates all the setup needed to create the input dictionary keys/values correctly.
- Parameters:
- inv_dictdict
Dictionary of inversion results generated from previous steps
- colMapstr, optional
Colormap, any acceptable from matplotlib, by default ‘nipy_spectral’
- cBarFormatstr, optional
Format string for colorbar tick labels, by default ‘%3.0f’
- cBarLabelstr, optional
Colorbar label, by default ‘Resistivity (ohm-m)’
- cBarOrientationstr {‘horizonta’, ‘vertical’}, optional
Orientation of the colorbar, by default ‘horizontal’
- cMinfloat, optional
Minimum of colorbar/colormap, by default None, which uses the minimum value of the dataset.
- cMaxfloat, optional
Maximum of colorbar/colormap, by default None, which uses the maximum value of the dataset.
- griddedFtlist, optional
Whether to show gridlines on the feet ticks, first position is x, second position is y, by default [False,False]
- griddedMlist, optional
Whether to show gridlines on the meter tickes, first position is x, second posistion is y, by default [False,False]
- titlestr, optional
String to show as the title, if desired to set manually, by default None, which shows the filename as the title
- normTypestr {‘log’, ‘linear’}, optional
Normalization type, by default ‘log’. Determines whether matplotlib.colors.LogNorm or matplotlib.colors.Normalize is used for colormap.
- primaryUnitstr {‘m’, ‘ft’}, optional
Whether to display meters or feet as primary unit (this determines which unit is larger on the axis and is on the left and top), by default ‘m’
- showPointsbool, optional
Whether to show the datapoints used for interpolation, by default False
- whichTicksstr {‘major’, ‘minor’, ‘both’}, optional
If griddedFt or griddedM has any True, this determines whether major, minor, or both gridlines are used; by default ‘major’.
- figsizetuple, optional
Tuple (width, height) of the figsize, read into plt.rcParams[‘figure.figsize’], by default None.
- dpiint or float, optional
Resolution (dots per square inch) of final figure, read into plt.rcParams[‘figure.dpi’], by default None.
- reversebool, optional
Whether to display the data in reverse (flipped along x) of what is read into from .inv file, by default False
- tight_layoutbool, optional
If true, calls fig.tight_layout(). Otherwise, tries to maximize space on the figure using plt.subplots_adjust, by default True
- savefigbool, optional
If False, will not save figure. Otherwise, calls plt.savefig() and the value of this parameter will be used as the output filepath, by default False.
- saveformatstr, optional
Read into plt.savefig(format) paramater, by default ‘png’.
- Returns:
- dict
Returns existing inv_dict input, but with added keys of [‘fig’] and [‘ax’] containing a list of the fig and ax objects (list, since multiple iterations can be done at once)