https://github.com/hyperspy/hyperspy_swift_library
HyperSpy Nion Swift Library reader
https://github.com/hyperspy/hyperspy_swift_library
Last synced: 3 months ago
JSON representation
HyperSpy Nion Swift Library reader
- Host: GitHub
- URL: https://github.com/hyperspy/hyperspy_swift_library
- Owner: hyperspy
- Created: 2019-06-28T14:35:32.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2022-10-25T16:19:25.000Z (over 3 years ago)
- Last Synced: 2026-01-02T07:21:36.420Z (7 months ago)
- Language: Python
- Size: 24.6 MB
- Stars: 0
- Watchers: 6
- Forks: 3
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Hyperspy Swift Library
Read Nion Swift libraries into HyperSpy object.
## Installation
This package depends on [Nion Swift](https://github.com/nion-software/nionswift). [Installing
it](https://nionswift.readthedocs.io/en/stable/installation.html) with ``conda``
before installing ``hyperspy_swift_library`` is recommended.
```bash
pip install --upgrade https://github.com/hyperspy/hyperspy_swift_library/archive/master.tar.gz
```
## Usage
```python
>>> from hyperspy_swift_library import SwiftLibraryReader
>>> project = SwiftLibraryReader("Nion Swift Project 20221025.nsproj")
```
If [pandas]() is installed, the `get_data_items_properties` returns a Pandas `DataFrame`.
Using Pandas syntax, it is very easy to select the information that you want to display.
For example, to display only the title and data_shape columns of the `DataFrame`:
```python
>>> df = project.get_data_items_properties()
>>> df[["title", "data_shape"]]
title data_shape
0 EELS [128, 1024]
1 Orsay Scan (BF) [512, 512]
2 EELS [1024]
3 Orsay Scan (eels_spim) [256, 256, 1024]
4 Pick Sum of Orsay Scan (eels_spim)
```
To filter data based on its title:
```python
>>> df[df['title'].str.endswith("(BF)")]['title']
1 Orsay Scan (BF)
Name: title, dtype: object
```
To load data as a HyperSpy signal:
```python
>>> s = project.load_data(0)
>>> s
```