Skip to main content

A library to analize and plot AFM scans

Project description

README

Overview

This script provides tools for analyzing and visualizing surface profiles exported from Gwyddion .txt files. It allows you to create height maps, profile plots, perform peak/valley detection, and compute statistical metrics and model fits from surface data.


Installation

pip install /path/to/pygwy_txt-[VERSION].tar.gz


Important File Naming Convention

To ensure proper ordering in the aggregated plots, the filenames of the .txt files has to have the x-axis parameter as first number in the file name.

1s_sample.txt
5s_sample.txt
10s_sample.txt

Classes and Initialization

PygwyTxt

Handles reading, analysis, and visualization of a single Gwyddion .txt scan file.

Initialization parameters:

  • file_path: str – Path to the input .txt file containing surface data.
  • scan_size_x: float – Horizontal scan size in micrometers.
  • scan_size_y: float – Vertical scan size in micrometers.
  • name: str, optional – Custom name for the dataset. Defaults to the filename.
  • peak_finder_settings: PeakFinderSettings, optional – Settings controlling peak/valley detection.
  • skip_header: int, optional – Skips that many rows at the start of the input file. Default: 0.
  • input_unit: astropy.unit, optional – Gives the unit of the data in the input file. Default: astopy.unint.m

Key methods:

  • plot_scan() – Creates a heatmap of the full scan.
  • plot_profile() – Plots the height profile along the central scan line.
  • plot_profile_section(start, stop, line) – Plots a selected section of a chosen scan line.
  • plot_debug(line) – Visualizes detected peaks and valleys for inspection.
  • export_stats() – Saves calculated statistics as a JSON file.

Automatically computed values:

  • Mean height and mean period
  • Standard deviation, minimum, maximum

StatJson

Collects and processes multiple JSON statistic files to visualize aggregated results or fits.

Initialization parameters:

  • base_path: str – Directory containing JSON statistic files.

Key methods:

  • plot(plot_type, x_label, x_unit, plot_name_appendix='', model=None, params=None, show_title=True, x_log=False, y_log=False) – Plots mean and standard deviation of height (plot_type=0) or period (plot_type=1). Optionally applies a model fit.
  • export_plot_data(plot_type) – Exports the plotted data (including fits) to a CSV file.

PeakFinderSettings

Defines configurable parameters for the scipy.signal.find_peaks algorithm to control peak and valley detection.

Initialization parameters (all optional):

  • height – Required height of peaks.
  • threshold – Required vertical difference between peaks and neighbors.
  • distance – Minimum horizontal distance between peaks.
  • prominence – Required prominence of peaks.
  • width – Required width of peaks.
  • wlen – Window length for peak prominence evaluation.
  • rel_height – Relative height at which the peak width is measured.
  • plateau_size – Range of flat peak plateaus.

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

pygwy_txt_analysis-0.0.5.tar.gz (26.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pygwy_txt_analysis-0.0.5-py3-none-any.whl (20.1 kB view details)

Uploaded Python 3

File details

Details for the file pygwy_txt_analysis-0.0.5.tar.gz.

File metadata

  • Download URL: pygwy_txt_analysis-0.0.5.tar.gz
  • Upload date:
  • Size: 26.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.6

File hashes

Hashes for pygwy_txt_analysis-0.0.5.tar.gz
Algorithm Hash digest
SHA256 7eef6328cdeb5f62033a36fd009f1f1af5428fa1866a95b5941832fc009091ff
MD5 0a2a76f75bf5e0404900aae9f7ec112a
BLAKE2b-256 6a958b966cb789ba37af84ba53d1d43770e73bdeb2771bb7eefacf4c3da618c4

See more details on using hashes here.

File details

Details for the file pygwy_txt_analysis-0.0.5-py3-none-any.whl.

File metadata

File hashes

Hashes for pygwy_txt_analysis-0.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 5a1d0d580b32d7de809ebc6c7b9b4124630cde92b8bdeb3723c2d2d205286dac
MD5 5ad60e52aa4bccfba0f296435dec3e5c
BLAKE2b-256 2431e64a200f426217b8112cedcf00d2154235a1eab8fa3e1955c6efe0b7d8a0

See more details on using hashes here.

Supported by

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