Skip to main content

micromagnetic post processing library

Project description

Pyzfn

Pyzfn is a micromagnetic post-processing library designed for analyzing and visualizing data generated by amumax, a fork of mumax3. It provides a convenient interface for working with simulation data stored in Zarr format, offering optimized functions for data manipulation, spectral analysis, and visualization.

Features

  • Easy Data Access: Load and navigate large simulation datasets efficiently.
  • Spectral Analysis: Calculate dispersion relations and extract spin wave modes.
  • Visualization Tools: Generate snapshots and interactive spectral plots.
  • Integration with Zarr: Leverage Zarr's capabilities for handling big data.

Installation

Install Pyzfn using pip:

pip install pyzfn

Usage

Pyzfn builds upon the functionalities provided by Zarr. Familiarity with Zarr is recommended for advanced usage.

Importing Pyzfn

from pyzfn import Pyzfn

Loading a Simulation

# Replace 'path/to/job.zarr' with your simulation data path
job = Pyzfn('path/to/job.zarr')

Exploring the Data Structure

Pretty Print the Data Tree

# Interactive tree (requires IPython)
job.pp

Simple Data Tree Print

# Non-interactive print
job.p

Accessing Simulation Metadata

Simulation metadata is stored in the .attrs attribute:

# Access metadata as a dictionary
dx = job.attrs['dx']

# Or as a class attribute (if no dataset shares the same name)
dx = job.dx

Retrieving Simulation Data

Access datasets saved during the simulation:

# Access magnetization data
# For example, get the x-component of magnetization for time steps 10 <= t < 20
# Dimensions are (time, z, y, x, component)
mag = job.m[10:20, :, :, :, 0]  # mag is a NumPy array

Lazy Loading

To handle large datasets without loading them into memory immediately:

# Get a reference to the dataset
mag_dset = job.m

# Load data when needed
arr = mag_dset[:]

Dataset Information

Display detailed information about a dataset:

mag_dset.info

Utilizing Help Functions

Use Python's built-in help and dir functions for assistance:

help(mag_dset)

Post-Processing Functions

Pyzfn provides optimized functions for common post-processing tasks.

Calculating Dispersion Relations

# Calculate the dispersion relation for the magnetization dataset
job.calc_disp(dset_in_str='m', dset_out_str='m')

Calculating Spin Wave Modes

# Extract spin wave modes from the data
job.calc_modes(dset_in_str='m', dset_out_str='m')

Data Visualization

Snapshot Visualization

Generate a snapshot of the magnetization at a specific time step:

# Visualize the magnetization at time index t=50 and layer z=0
job.snapshot(t=50, z=0)

Interactive Spectral Analysis

Launch an interactive FFT spectrum plot:

# Interactive spectrum analysis
job.ispec(dset='m', c=0)

Advanced Usage

Custom Slicing

Optimize memory usage and performance with custom slicing:

# Define custom slices for processing
slices = (
    slice(None),  # Time dimension
    slice(None),  # z dimension
    slice(None),  # y dimension
    slice(None),  # x dimension
    slice(None)   # Component dimension
)

# Calculate modes with custom slices
job.calc_modes(dset_in_str='m', dset_out_str='m', slices=slices)

Saving and Loading OVF Files

Pyzfn includes utilities for working with OOMMF's OVF file format:

from pyzfn.utils import save_ovf, load_ovf

# Save data to an OVF file
save_ovf('output.ovf', mag)

# Load data from an OVF file
data = load_ovf('output.ovf')

Trimming Modes

Trim modes based on peak detection to reduce data size:

# Trim modes with specified parameters
job.trim_modes(dset_in_str='m', dset_out_str='trimmed_m', peak_xcut_min=0)

Contributing

Contributions are welcome! If you find a bug or have a feature request, please open an issue or submit a pull request on the GitHub repository.

Acknowledgments

  • amumax for simulation data.
  • Zarr for efficient data handling.

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

pyzfn-1.0.4.tar.gz (56.2 kB view details)

Uploaded Source

Built Distribution

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

pyzfn-1.0.4-py3-none-any.whl (45.9 kB view details)

Uploaded Python 3

File details

Details for the file pyzfn-1.0.4.tar.gz.

File metadata

  • Download URL: pyzfn-1.0.4.tar.gz
  • Upload date:
  • Size: 56.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for pyzfn-1.0.4.tar.gz
Algorithm Hash digest
SHA256 843f9a630f9d068978371623bc886d7d3afb44b6e6171dfaf6864f144e412896
MD5 0f05d57a8868c5fc091bde46a9f354de
BLAKE2b-256 18eee8f9178df3d872b1c4ead05040e62bcbcb2474d738ecba8a63587894b4a9

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyzfn-1.0.4.tar.gz:

Publisher: ci-cd.yml on MathieuMoalic/pyzfn

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyzfn-1.0.4-py3-none-any.whl.

File metadata

  • Download URL: pyzfn-1.0.4-py3-none-any.whl
  • Upload date:
  • Size: 45.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for pyzfn-1.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 2f0c65eed2f1b92bf6d0f499fda673d62052766f8554f881d50f2e9f1ca2dc0d
MD5 ab46856658a22e98966458a9a14400e2
BLAKE2b-256 9ae54fb8a35c6eee3e11969c1a7b453eaa9c81f377d99928004d901d3d9b2add

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyzfn-1.0.4-py3-none-any.whl:

Publisher: ci-cd.yml on MathieuMoalic/pyzfn

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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