seisflows.tools.graphics
Basic visualization tools for SeisFlows to visualize waveforms, models, etc. Includes utility functions for manipulating image files such as .png and .pdfs. Makes use use of the Python Pillow package if working with .png files, and the PyPDF2 package if manipulating pdf files. Internal imports for all functions to remove Pyatoa-wide dependencies on these packages for short functions.
Functions
|
Merge a list of pdfs into a single output pdf using the PyPDF2 package. |
|
Combine a list of .png files into a single PDF document |
|
Combine a list of images into a single, horizontally tiled image. |
|
Convert GeoTiff images (e.g., ETOPO1 topography) to a numpy array for |
|
Very simple plotting routine to show waveforms and adjoint sources |
|
Line plot of optimization stats, which are written about by |
|
Plots values of a SPECEFM2D model/gradient on an unstructured grid |
|
Plots values of a SPECEFM2D model/gradient by interpolating onto a regular |
Module Contents
- seisflows.tools.graphics.merge_pdfs(fids, fid_out, remove_fids=False)
Merge a list of pdfs into a single output pdf using the PyPDF2 package. Any desired order to the pdfs should be set in the list of input fids.
- Parameters:
fids (list) – list of paths to .pdf files
fid_out (str) – path and name of the resulting output .pdf file
remove_fids (bool) – remove the original input PDF files if the output PDF was successfully created. Defaults to False, original files are kept.
- seisflows.tools.graphics.imgs_to_pdf(fids, fid_out, remove_fids=False)
Combine a list of .png files into a single PDF document
- Parameters:
fids (list) – list of file ids with full pathnames to be combined
fid_out (str) – the name of the file to be saved with full pathname
remove_fids (bool) – remove the original input PNG files if the output PDF was successfully created. Defaults to False, original files are kept.
- seisflows.tools.graphics.tile_imgs(fids, fid_out)
Combine a list of images into a single, horizontally tiled image.
- Parameters:
fids (list) – list of file ids with full pathnames to be tiled
fid_out (str) – the name of the file to be saved with full pathname
- seisflows.tools.graphics.tif_to_array(fid)
Convert GeoTiff images (e.g., ETOPO1 topography) to a numpy array for conversion and processing
- Parameters:
fid (str) – .tif(f) file
- Return type:
np.array
- Returns:
array of data contained within the tiff file
- seisflows.tools.graphics.plot_waveforms(tr_obs, tr_syn, tr_adj=None, fid_out=None, title=None, **kwargs)
Very simple plotting routine to show waveforms and adjoint sources manipulated by the Default preprocessing module. Plots are simple and are provided in a default style that can be adjusted via keyword arguments.
Cuts the x-axis (time) to the length of the synthetic seismogram as data may be longer which tends to obscure signal of interest.
- Parameters:
tr_obs (obspy.core.stream.Stream) – observed seismogram, data
tr_syn (obspy.core.stream.Stream) – synthetic seismogram
tr_adj (obspy.core.stream.Stream) – optional adjoint source. if not given, none will be plotted
fid_out (str) – name and path to save output file. If none given, output file will be saved to current working directory and named based on the trace ID of the obs data
- seisflows.tools.graphics.plot_optim_stats(fid='output_optim.txt', path_out='./')
Line plot of optimization stats, which are written about by Optimize.write_stats(). Intrinsically tied to the format of input file.
- Parameters:
fid (str) – path to the optimization stats file to plot
path_out (str) – full path (no filename) to save figures. filenames will be determined by the header values
- seisflows.tools.graphics.plot_2d_contour(x, z, data, cmap='viridis', zero_midpoint=False)
Plots values of a SPECEFM2D model/gradient on an unstructured grid
- Parameters:
x (np.array) – x values of GLL mesh
z (np.array) – z values of GLL mesh
data (np.array) – D
cmap (str) – matplotlib colormap to be applied to the contour plot. Defaults to ‘viridis’
zero_midpoint (bool) – set 0 as the midpoint for the colorbar. Useful for diverging colorscales (e.g., for gradients), where the neutral color (e.g., white) is set at value=0
- seisflows.tools.graphics.plot_2d_image(x, z, data, res_x=1000, res_z=1000, cmap='viridis', vmin=None, vmax=None, levels=101)
Plots values of a SPECEFM2D model/gradient by interpolating onto a regular grid. Used for the SeisFlows command seisflows plot2d
- Parameters:
x (np.array) – x values of GLL mesh
z (np.array) – z values of GLL mesh
data (np.array) – D
cmap (str) – matplotlib colormap to be applied to the contour plot. Defaults to ‘viridis’
zero_midpoint (bool) – set 0 as the midpoint for the colorbar. Useful for diverging colorscales (e.g., for gradients), where the neutral color (e.g., white) is set at value=0
resX (int) – number of points for the interpolation in x- direction (default=1000)
resZ (int) – number of points for the interpolation in z- direction
(default=1000)