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
nanosurflibrary 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
Metadata
Release files for nanosurf-core 2.0.7
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| nanosurf_core-2.0.7.tar.gz | 66.7 kB | Without provenance | Details for nanosurf_core-2.0.7.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| nanosurf_core-2.0.7-py3-none-any.whl | Python 3 | none | any | Details for nanosurf_core-2.0.7-py3-none-any.whl |
Total release size: 143.9 kB
Release files / nanosurf_core-2.0.7.tar.gz
| Download URL | nanosurf_core-2.0.7.tar.gz |
|---|---|
| Size | 66.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
69738955c2d5681cfb110caf3ebb2081802cb568bebe146418bbaf51ca525f90
|
|
BLAKE2b-256 checksum How to use checksums |
183a3eb38d81632634cd433072366bedac90fd36fad3163814934d6a97af6451
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.11.9
|
Release files / nanosurf_core-2.0.7-py3-none-any.whl
| Download URL | nanosurf_core-2.0.7-py3-none-any.whl |
|---|---|
| Size | 77.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b56505e52ed710540080f5d0098e11e5149fe9885b3671c708941117811d13af
|
|
BLAKE2b-256 checksum How to use checksums |
2c1c12488439b8d2168d0c0b380775ae54fca83c6fa2b64e93c6f7275a900f0d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.11.9
|
Security for nanosurf-core 2.0.7
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.