Skip to main content

Surface roughness calculation with Python

Project description

surface-roughness

Surface roughness is a library that processes 3D surface STL data and produces oriented roughness metrics.

Citation

If you wish to use this work, please cite this paper according to CITATION.cff.

Installation

Installation is completed by

pip install surface-roughness

Usage

Roughness mapping

from surface_roughness import Surface, SampleWindow, roughness_map

# Load Surface STL File into Python
surface = Surface(path="example_surface.stl")

# Specify SampleWindow parameters
w = SampleWindow(is_circle=True,radius=2) # in units of STL mesh

# Generate roughness map object based on method presented in Magsipoc & Grasselli (2023) with parameters
map = roughness_map(
    surface,        # surface object required to interact with library
    'delta_t',      # Method for analyzing roughness
    w,              # SampleWindow object
    0.5,            # Distance between windows in mesh units
    1               # Number of vertices for mesh facet to be included in window sampling
    )

# Start subsampling process
map.sample()

# Evaluate roughness of subsamples
map.evaluate()

# Analyze directional roughness statistics
map.analyze_directional_roughness('delta_t')
map.analyze_directional_roughness('delta*_t')

# Pickle map to save analysis (optional)
with ('example_surface_r2_s0.5.pickle','wb') as f:
    pickle.dump(map, f)

# Save data to VTK for visualization
map.to_vtk('example_surface_r2_s0.5','delta_t')

Directional Roughness

from surface_roughness import Surface
import matplotlib.pyplot as plt     # For plotting graphs

surface = Surface('example_surface.stl')

# Calculate roughness from Tatone and Grasselli (2009) doi: 10.1063/1.3266964
surface.evaluate_thetamax_cp1()
az = surface.thetamax_cp1('az') # Get azimuth correlating with analysis
thetamaxcp1_roughness = surface.thetamax_cp1('thetamax_cp1')

# Plot surface roughness
plt.figure()
plt.polar(az,thetamaxcp1_roughness,label=r'$\theta^*_{max}/(C+1)$')
plt.legend()

# Calculate roughness from Babanouri and Karami Nasab (2017) doi: 10.1007/s00603-016-1139-1
surface.evaluate_delta_t()
az_t = s.delta_t('az')
delta_t = s.delta_t('delta_t')

az_a = s.delta_a('az')
delta_a = s.delta_a('delta_a')

az_n = s.delta_n('az')
delta_n = s.delta_n('delta_n')


plt.figure()
plt.polar(az_t,delta_t,label='$\Delta_T$')
plt.polar(az_a,delta_a,label='$\Delta_A$')
plt.polar(az_n,delta_n,label='$\Delta_N$')
plt.legend()

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

surface_roughness-0.0.3.tar.gz (37.7 kB view hashes)

Uploaded Source

Built Distributions

surface_roughness-0.0.3-cp312-cp312-win_amd64.whl (239.3 kB view hashes)

Uploaded CPython 3.12 Windows x86-64

surface_roughness-0.0.3-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (383.1 kB view hashes)

Uploaded CPython 3.12 manylinux: glibc 2.17+ x86-64

surface_roughness-0.0.3-cp312-cp312-macosx_11_0_arm64.whl (263.2 kB view hashes)

Uploaded CPython 3.12 macOS 11.0+ ARM64

surface_roughness-0.0.3-cp312-cp312-macosx_10_9_x86_64.whl (289.8 kB view hashes)

Uploaded CPython 3.12 macOS 10.9+ x86-64

surface_roughness-0.0.3-cp311-cp311-win_amd64.whl (239.2 kB view hashes)

Uploaded CPython 3.11 Windows x86-64

surface_roughness-0.0.3-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (382.9 kB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

surface_roughness-0.0.3-cp311-cp311-macosx_11_0_arm64.whl (262.6 kB view hashes)

Uploaded CPython 3.11 macOS 11.0+ ARM64

surface_roughness-0.0.3-cp311-cp311-macosx_10_9_x86_64.whl (289.4 kB view hashes)

Uploaded CPython 3.11 macOS 10.9+ x86-64

surface_roughness-0.0.3-cp310-cp310-win_amd64.whl (238.9 kB view hashes)

Uploaded CPython 3.10 Windows x86-64

surface_roughness-0.0.3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (382.2 kB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

surface_roughness-0.0.3-cp310-cp310-macosx_11_0_arm64.whl (261.4 kB view hashes)

Uploaded CPython 3.10 macOS 11.0+ ARM64

surface_roughness-0.0.3-cp310-cp310-macosx_10_9_x86_64.whl (287.9 kB view hashes)

Uploaded CPython 3.10 macOS 10.9+ x86-64

surface_roughness-0.0.3-cp39-cp39-win_amd64.whl (236.7 kB view hashes)

Uploaded CPython 3.9 Windows x86-64

surface_roughness-0.0.3-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (382.3 kB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

surface_roughness-0.0.3-cp39-cp39-macosx_11_0_arm64.whl (261.5 kB view hashes)

Uploaded CPython 3.9 macOS 11.0+ ARM64

surface_roughness-0.0.3-cp39-cp39-macosx_10_9_x86_64.whl (287.9 kB view hashes)

Uploaded CPython 3.9 macOS 10.9+ x86-64

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page