Note

This page was generated from a Jupyter Notebook. Download the notebook (.ipynb)

ASD Analysis Pipeline

This tutorial demonstrates how to use SegmentTable for a batch ASD analysis pipeline. We will crop data for each segment, compute ASDs, and visualize the variation.

[ ]:
import numpy as np
from gwpy.segments import Segment
from gwexpy.table import SegmentTable
from gwpy.timeseries import TimeSeries

def get_synthetic_data():
    return TimeSeries(np.random.randn(1024), sample_rate=64)

segs = [Segment(i*16, i*16+16) for i in range(4)]
st = SegmentTable.from_segments(segs)
st.add_series_column("raw", data=[get_synthetic_data()]*len(st), kind="timeseries")
st

Crop and ASD

We can use sugar APIs like crop() and asd() to process all segments at once.

[ ]:
# Crop to each segment span
st_cropped = st.crop("raw", out_col="cropped")
# Calculate ASD for each segment
st_asd = st_cropped.asd("cropped", out_col="asd", fftlength=2.0)
st_asd.display()

Multi-channel Summary

You can map custom functions (like calculating band RMS) using map().

[ ]:
def calc_rms(fs):
    return np.sqrt(np.sum(fs.value**2)) # Simplified

st_asd.map("asd", calc_rms, out_col="band_rms", inplace=True)
st_asd.display()