Skip to main content

nanosurf-core package

This package provides a Python interface and functionality for remote controlling Nanosurf atomic force microscopes (AFMs) with a running Nanosurf Studio or Nanosurf MobileS session.

Requirements

  • To use the Python interface to remotely control a Nanosurf AFM, a running Nanosurf Studio or Nanosurf MobileS session is required.
  • Scripting access to low-level Studio functionality can be obtained in different tiers. See documentation, or contact Nanosurf sales for more information.

The library installs on Windows, Linux and macOS, but not every feature is available on every platform:

Windows Linux macOS
Studio or MobileS functionality via Python

Installation and updating

To install the nanosurf-core package, run the following command from your command line interface:

pip install nanosurf-core

To upgrade your nanosurf-core package installation to the newest version, run the following command from your command line interface:

pip install -U nanosurf-core

Note: If a nanosurf library version < 2.0.0 is already installed, the library needs to be uninstalled first:

pip uninstall nanosurf

Getting started

With a running Studio session:

from nanosurf.studio import Studio, StudioScriptError

studio = Studio()

try:
    session = studio.select_measurement_session()
    print(f"Instrument: {session.workflow.device.scan_head.name} / "
          f"{session.workflow.device.controller.name}")

    laser = session.workflow.laser
    calibration = session.workflow.probe.cantilever_calibration
    imaging = session.workflow.imaging
    storage = session.workflow.data.storage
    approach = session.workflow.approach

    # 1. Laser alignment
    print("Aligning laser...")
    print(laser.alignment.align_all()['message'])

    # 2. Cantilever calibration
    calibration.operation_mode = calibration.operation_mode_enum.non_contact
    print("Running thermal tune...")
    print(calibration.run()['message'])
    calibration.apply()

    # 3. Set imaging parameters
    imaging.scan_range_fast_axis = 2e-6
    imaging.scan_range_slow_axis = 2e-6
    imaging.points_per_line = 256
    imaging.lines_per_frame = 256
    imaging.line_rate = 1.0

    # 4. Where to save
    storage.file_basename = "demo_[DATE]_[INDEX]"

    # 5. Approach and acquire an image
    print("Approaching...")
    print(approach.approach()['message'])

    print("Scanning...")
    print(imaging.acquire()['message'])

    # 6. Withdraw
    approach.withdraw()
    print("Session complete.")

except StudioScriptError as e:
    print(f"Studio error: {e}")

With a running MobileS session:

import time
from nanosurf.com_proxy import SPM
# SPM() auto-detects whichever supported control software is running
# (MobileS, C3000, CoreAFM, CX, etc). Use e.g. nanosurf.MobileS() to target one directly.

spm = SPM()
try:
    if not spm.is_connected():
        raise RuntimeError("No running Nanosurf MobileS session found.")
    if not spm.is_scripting_enabled():
        raise RuntimeError("Scripting is not enabled.")

    # configure the measurement
    scan = spm.application.Scan
    scan.ImageWidth  = 2e-6
    scan.ImageHeight = 2e-6
    scan.Points = 200
    scan.Lines  = 200

    # start the measurement
    scan.StartFrameUp()
    while scan.IsScanning:
        time.sleep(0.1)

except Exception as e:
    print(f"Connecting to MobileS or imaging failed: {e}")

Documentation

The full documentation for the library and the Studio scripting interface is bundled with Nanosurf Studio starting from version 18.

Version History

See CHANGELOG.txt in the installed package folder.

License

MIT License

Download files

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

Source Distribution

nanosurf_core-2.0.7.tar.gz (66.7 kB view details)

Uploaded Source

Built Distribution

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

nanosurf_core-2.0.7-py3-none-any.whl (77.2 kB view details)

Uploaded Python 3

File details

Details for the file nanosurf_core-2.0.7.tar.gz.

File metadata

  • Download URL: nanosurf_core-2.0.7.tar.gz
  • Upload date:
  • Size: 66.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.11.9

File hashes

Hashes for nanosurf_core-2.0.7.tar.gz
Algorithm Hash digest
SHA256 69738955c2d5681cfb110caf3ebb2081802cb568bebe146418bbaf51ca525f90
MD5 efa377570eb093ad695885def452d85f
BLAKE2b-256 183a3eb38d81632634cd433072366bedac90fd36fad3163814934d6a97af6451

See more details on using hashes here.

File details

Details for the file nanosurf_core-2.0.7-py3-none-any.whl.

File metadata

  • Download URL: nanosurf_core-2.0.7-py3-none-any.whl
  • Upload date:
  • Size: 77.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.11.9

File hashes

Hashes for nanosurf_core-2.0.7-py3-none-any.whl
Algorithm Hash digest
SHA256 b56505e52ed710540080f5d0098e11e5149fe9885b3671c708941117811d13af
MD5 685112f7ebfe41b9f541ecd1b8c9ad70
BLAKE2b-256 2c1c12488439b8d2168d0c0b380775ae54fca83c6fa2b64e93c6f7275a900f0d

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

2.0.7 This release

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page