pySW4.postp.image module¶
Python module to handle SW4 images of Maps or Cross-Sections.
| author: | Shahar Shani-Kadmiel (s.shanikadmiel@tudelft.nl) Omry Volk (omryv@post.bgu.ac.il) Tobias Megies (megies@geophysik.uni-muenchen.de) | 
|---|---|
| copyright: | Shahar Shani-Kadmiel (s.shanikadmiel@tudelft.nl) Omry Volk (omryv@post.bgu.ac.il) Tobias Megies (megies@geophysik.uni-muenchen.de) | 
| license: | This code is distributed under the terms of the GNU Lesser General Public License, Version 3 (https://www.gnu.org/copyleft/lesser.html) | 
- 
class Image(input_file=None, stf=None)[source]¶
- Bases: - object- A class to hold SW4 image files. - Initialize an empty Image object, preferentially specifying the input file used to run the simulation. - Parameters: - input_file : str or - AttribDict- Input file (already parsed or filename) used to compute the image output. - stf : {‘displacement’, ‘velocity’} - Only needed if no metadata from original input_file is used. - 
_read_curvilinear_grid(f)[source]¶
- Read the last bit of the SW4 image file in case a curvilinear grid is found. - Parameters: - f : file - Open file handle of SW4 image file (at correct position). 
 - 
_read_header(f)[source]¶
- Read SW4 header information and store it in an - Imageobject.- Parameters: - f : file - Open file handle of SW4 image file (at correct position). 
 - 
_read_patches(f)[source]¶
- Read SW4 patch data and store it in a list of - Patchobjects under- patches.- Parameters: - f : file - Open file handle of SW4 image file (at correct position). 
 - 
plot(patches=None, ax=None, vmin='min', vmax='max', colorbar=True, cmap=None, interpolation='nearest', origin='lower', projection_distance=inf, **kwargs)[source]¶
- Plot all (or specific) patches in - Image.- Parameters: - patches : list of int - Patches to plot - Other Parameters: - ax : - Axes- Use existing axes. - vmin : float - Manually set minimum of color scale. - vmax : str or float - Used to clip the coloring of the data at the set value. Default is ‘max’ which shows all the data. If - float, the colorscale saturates at the given value. Finally, if a string is passed (other than ‘max’), it is casted to float and used as an- rmsmultiplier. For instance, if- vmax='3', clipping is done at 3.0*rms of the data.- colorbar : bool or str - If - colorbaris a string, that string is used to override the automatic label chosen based on the image header. To Supress plotting of the colorbar set to- False.- cmap : - Colormap- Colormap for the plot - interpolation : str - Acceptable values are ‘none’, ‘nearest’, ‘bilinear’, ‘bicubic’, ‘spline16’, ‘spline36’, ‘hanning’, ‘hamming’, ‘hermite’, ‘kaiser’, ‘quadric’, ‘catrom’, ‘gaussian’, ‘bessel’, ‘mitchell’, ‘sinc’, ‘lanczos’. - origin : str - Places the origin at the ‘lower’ (default) or ‘upper’ left corner of the plot. - projection_distance : float - Threshold distance from the plane coordinate to include symbols of stations and sources. These are orthogonally projected onto the plotted 2D plane. By default everything is included but this can cause too many symbols to be plotted, obscuring the image. - Examples - >>> my_image.plot() # plots all patches >>> my_image.plot(patches=[0, 2]) # plots first and third patch 
 
- 
- 
class Patch(image=None, number=None)[source]¶
- Bases: - object- A class to hold SW4 patch data. - Initialize an empty Patch object, preferentially specifying the parent - Image.- Parameters: - image : - Image- Parent Image object. - number : int - Patch index in parent image (starts at 0). - 
plot(ax=None, vmin=None, vmax=None, colorbar=True, cmap=None, interpolation='nearest', origin='lower', **kwargs)[source]¶
- Plot patch. - Note - Should not really be used directly by the user but rather called by the - plot()method.- Parameters: - ax : - Axes- Use existing axes. - vmin : float - Manually set minimum of color scale. - vmax : float - Manually set maximum of color scale. - colorbar : bool or str - If - colorbaris a string, that string is used to override the automatic label chosen based on the image header. To Supress plotting of the colorbar set to- False.- cmap : - Colormap- Colormap for the plot - interpolation : str - Acceptable values are ‘none’, ‘nearest’, ‘bilinear’, ‘bicubic’, ‘spline16’, ‘spline36’, ‘hanning’, ‘hamming’, ‘hermite’, ‘kaiser’, ‘quadric’, ‘catrom’, ‘gaussian’, ‘bessel’, ‘mitchell’, ‘sinc’, ‘lanczos’. - origin : str - Places the origin at the ‘lower’ (default) or ‘upper’ left corner of the plot. - Other Parameters: - kwargs : - imshow()
 
- 
- 
read_image(filename='random', input_file=None, stf='displacement', verbose=False)[source]¶
- Read image data, cross-section or map into a - Imageobject.- Parameters: - filename : str - If no filename is passed, by default, a random image is generated. if filename is - None, an empty- Imageobject is returned.- input_file : str or AttribDict - Input file (already parsed or filename) used to compute the image output. - stf : str - ‘displacement’ or ‘velocity’. Only needed if no metadata from original input_file is used. - verbose : bool - If set to - True, print some information while reading the file.- Returns: