Tutorial

Overview

This tutorial demonstrates how to use the transient nutation analysis package in a Python script.

The workflow consists of:

  • defining analysis parameters

  • running the processing pipeline

  • visualising the results

Imports

Start by importing the required modules:

import tna.classes as cl
import tna.functions as fun
from pathlib import Path
import matplotlib.pyplot as plt

Define the data path:

BASE_DIR = Path(__file__).resolve().parent

Example 1: Two-dimensional analysis

In this example, a full 2D dataset is processed and transformed into the frequency domain.

  1. Define parameters

    params = cl.Parameters(
        two_d=True,
        path=BASE_DIR / "data" / "your_dataset.DSC",
        baseline_correction=False,
        reconstruction=True,
        mean_subtraction=True,
        wdw_hamming=True,
        hamming_window_coefficient=0.54,
        zero_filling=True,
        zero_filling_factor=2,
        reference_freq=True,
        reference_freq_value=1e7
    )
    
  2. Run the analysis

    trans_nut = fun.run_tna_2d(params.path, params)
    
  3. Plot a frequency slice

    plt.figure()
    plt.plot(trans_nut.freq, trans_nut.freq_signal[99])
    plt.draw()
    

Example 2: One-dimensional analysis

In this example, a single field slice is selected from a 2D dataset and processed as a one-dimensional signal.

  1. Define parameters

    params = cl.Parameters(
        two_d=True,
        path=BASE_DIR / "data" / "your_dataset.DSC",
        baseline_correction=False,
        reconstruction=True,
        mean_subtraction=True,
        wdw_hamming=True,
        hamming_window_coefficient=0.54,
        zero_filling=True,
        zero_filling_factor=2,
        reference_freq=True,
        reference_freq_value=1e7,
        current_field=12020
    )
    
  2. Run the analysis

    trans_nut = fun.run_tna(params.path, params)
    
  3. Plot the spectrum

    plt.figure()
    plt.plot(trans_nut.freq, trans_nut.freq_signal)
    plt.show()
    

Notes

  • The parameter object controls the entire processing pipeline.

  • Processing steps (e.g. reconstruction, window functions) are enabled via boolean flags.

  • The order of processing steps follows the internal pipeline definition.

  • The output object contains both time-domain and frequency-domain data.

Further information

For a complete description of available parameters and data structures, see classes.

The tna.classes.Parameters class defines all configurable options for the processing pipeline, while tna.classes.TransientNutations provides access to the resulting data.