slippy.surface.Surface¶
- class slippy.surface.Surface(profile: Optional[numpy.ndarray] = None, grid_spacing: Optional[float] = None, shape: Optional[tuple] = None, extent: Optional[tuple] = None, file_name: Optional[str] = None, mat_profile_name: Optional[str] = None, mat_grid_spacing_name: Optional[str] = None, csv_delimiter: Optional[str] = None, csv_dialect: Union[csv.Dialect, str] = 'sniff', csv_sniffer_n_bytes: int = 2048)[source]¶
Object for reading, manipulating and plotting surfaces
The Surface class contains methods for setting properties, examining measures of roughness and descriptions of surfaces, plotting, fixing and editing surfaces.
- Parameters
profile (np.ndarray, optional (None)) – The height profile of the surface, the units should be the same as used for the grid spacing parameter
grid_spacing (float, optional (None)) – The distance between the grid points in the surface profile
shape (tuple, optional (None)) – The number of grid points in the surface in each direction, should not be set if a profile is given
extent (tuple, optional (None)) – The total extent of the surface in the same units as the grid spacing, either this or the grid spacing can be set if a profile is given (either as the profile argument or from a file)
file_name (str, optional (None)) – The full path including the file extension to a supported file type, supported types are .txt, .csv, .al3d, .mat
csv_delimiter (str, optional (None)) – The delimiter used in the .csv or .txt file, only used if the file name is given and the file is a .txt or .csv file
csv_dialect ({csv.Dialect, str), optional ('sniff')) – The dialect used to read the csv file, only used if a file is supplied and the file is a csv file, defaults to ‘sniff’ meaning that the csv. sniffer will be used.
csv_sniffer_n_bytes (int, optional (2048)) – The number of bytes used by the csv sniffer, only used if ‘sniff’ is given as the dialect and a csv file is given as the file name
mat_profile_name (str, optional ('profile')) – The name of the profile variable in the .mat file, only used if the file_name is given and the file is a .mat file
mat_grid_spacing_name (str, optional (None)) – The name of the grid_spacing variable in the .mat file, only used if the file_name is given and the file is a .mat file. If unset the grid_spacing property is not read from the file.
See also
ACF,roughnessNotes
Roughness functions are aliased from the functions provided in the surface module
Examples
Making a surface from a numpy array:
>>> import slippy.surface as s >>> import numpy as np >>> profile = np.random.rand(10,10) >>> my_surface = s.Surface(profile = profile, grid_spacing = 1)
Making a surface from a csv file:
>>> my_surface = s.Surface(file_name='surface.csv', grid_spacing = 1)
Note that variations on csv files can be handled by passing a CSV dialect object from the csv package, this can also be automatically detected by passing ‘sniff’ as the dialect.
Making a surface from an alicona file:
>>> path = r'path\to\alicona\file' >>> my_surface = s.Surface(file_name=path+r'\dem.al3d')
This will extract the surface profile and grid spacing from the .al3d file. More parameters can be extracted by using the alicona_read function.
Making a surface from a matlab file:
>>> my_surface = s.Surface(file_name='saved profiles.mat', grid_spacing = 1)
If the profile parameter in the matlab file is not called ‘profile’ this can be set:
>>> my_surface = s.Surface(file_name='saved profiles.mat', mat_profile_name='profile_b', grid_spacing = 1)
- __init__(profile: Optional[numpy.ndarray] = None, grid_spacing: Optional[float] = None, shape: Optional[tuple] = None, extent: Optional[tuple] = None, file_name: Optional[str] = None, mat_profile_name: Optional[str] = None, mat_grid_spacing_name: Optional[str] = None, csv_delimiter: Optional[str] = None, csv_dialect: Union[csv.Dialect, str] = 'sniff', csv_sniffer_n_bytes: int = 2048)[source]¶
Methods
__init__([profile, grid_spacing, shape, ...])convert_coordinates(y_coord, x_coord)fill_holes([hole_value, mk_copy, ...])Replaces specified values with filler
find_summits([mask, four_nearest, ...])Find summits after low pass filtering
get_acf([profile_in])Find the auto correlation function of the surface
get_fft([profile_in])Find the fourier transform of the surface
get_height_of_mat_vr(ratio[, void, mask, ...])Find the height of a given material or void volume ratio
get_mat_vr(height[, void, mask, ratio])Find the material or void volume ratio for a given height
get_points_from_extent([extent, ...])Gets the grid points from the extent and the grid spacing
get_psd()Find the power spectral density of the surface
get_summit_curvature([summits, mask, ...])Get summit curvatures
interpolate(y_points, x_points[, mode, ...])Easy memoized interpolation on surface objects
low_pass_filter(cut_off_freq[, return_copy])Low pass FIR filter the surface profile
max_shape()mesh(depth[, method, parameters])Returns a Mesh object for the surface
read_al3d(file_name[, return_data])Reads an alicona al3d file and sets the profile and grid_spacing property of the surface
read_csv(file_name[, delimiter, ...])Read a profile from a csv or txt file, header lines are automatically skipped
read_mat(path[, profile_name, grid_spacing_name])Reads .mat files as surfaces
resample([new_grid_spacing, return_profile, ...])Resample or crop the profile by interpolation
rotate(radians)roughness(parameter_name[, mask, ...])Find areal roughness parameters
show([property_to_plot, plot_type, ax, ...])Plot surface properties
subtract_polynomial(order[, mask])Flatten the surface by subtracting a polynomial
wear(name, x_pts, y_pts, depth)Add wear / geometry changes to the surface profile
Attributes
acfThe auto correlation function of the surface profile
dimensionsThe number of spatial dimensions that
extentThe overall dimensions of the surface in the same units as grid spacing
fftThe fast fourier transform of the surface
grid_spacingThe distance between grid points in the x and y directions
is_analyticis_discreteA bool flag, True if there is a profile present
maskA mask used to exclude some values from analysis, a single float or an array of bool the same size as profile Either a boolean array of size self.size or a float of the value to be excluded
materialA material object describing the properties of the surface
moving_surfaceprofileThe height data for the surface profile
psdThe power spectral density of the surface
shapeThe shape of the surface profile array, the number of points in each direction
sizeThe total number of points in the surface
surface_typeA description of the surface type
unworn_profilewear_volumes