<jupyter_start><jupyter_text>AimAnalyze data from the SEAL tests.For the closed-loop tests, demonstrate the potential model problems.<jupyter_code># imports
import os
from os import path, listdir
import numpy as np
from matplotlib import pyplot as plt
import re
from toolz import pipe
import sys
sys.path.append("..")
from src.utils import genpsd, rms
datapath = path.join("..", "data")
ol = np.load(path.join(datapath, "openloop", "ol_tt_stamp_21_08_2021_08_56_31.npy"))
ol_spectra = [genpsd(ol[:,i], dt=0.01) for i in range(2)]
lqg_path = path.join(datapath, "lqg")
lqg_files = pipe(
    listdir(lqg_path),
    lambda files: filter(lambda f: not re.search("time", f), files),
    list
)
len(lqg_files)
def plot_cl_rtf(f):
    ttvals = np.load(path.join(lqg_path, f))
    fig, axs = plt.subplots(2, figsize=(9,9))
    fig.tight_layout(pad=4.0)
    plt.suptitle("LQG rejection")
    for mode in range(2):
        cl = ttvals[:,mode]
        olc = ol[:len(cl),mode]
        f_ol, p_ol = genpsd(olc, dt=0.01)
        f_cl, p_cl = genpsd(cl, dt=0.01)
        rms_ratio = rms(cl) / rms(olc)
        rms_ratio = str(np.round(rms_ratio, 4))[:7]
        axs[mode].loglog(f_ol, p_ol, label="Open-loop")
        axs[mode].loglog(f_cl, p_cl, label="Closed-loop")
        axs[mode].loglog(f_cl, p_cl / p_ol, label="Rejection TF")
        axs[mode].legend()
        axs[mode].set_xlabel("Frequency (Hz)")
        axs[mode].set_ylabel(r"Power (DM $units^2/Hz$)")
        axs[mode].set_title("Mode {0}, CL/OL RMS {1}".format(mode, rms_ratio))

    plt.show()
for i in [4, 10, 20, 41, 50, 74, 104, 105, 109, 112]:
    plot_cl_rtf(lqg_files[i])
ttvals = np.load(path.join(lqg_path, lqg_files[112]))
plt.plot(ttvals[:,0])<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.16205305651672433, 'fraction_numerical': 0.03575547866205306, 'mean_word_length': 3.846368715083799, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '74212', 'license': 'CC0-1.0', 'n_tokens_mistral': 767, 'n_tokens_neox': 722, 'n_words': 152, 'path': 'notebooks/seal_cl_analysis.ipynb', 'repo_name': 'aditya-sengupta/sealrtc-mirror', 'size': '1734'}