<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">"""Below you'll need to download the various Zygo measurement data
from the various DCC entries.
"""

import finesse
import finesse.ligo
import numpy as np
import matplotlib.pyplot as plt
import h5py
import pathlib

finesse.init_plotting()

# Download each map from a DCC
maps = [
    "/Users/ddb/Downloads/ITM07_-power_in_160mm.dat",
    "/Users/ddb/Downloads/ITM01_S1-P_160.dat",
    "/Users/ddb/Downloads/ETM13_-power_160.dat",
    "/Users/ddb/Downloads/ETM16_S1_-power_on_160.dat",
    "/Users/ddb/Downloads/ITM04.dat",
    "/Users/ddb/Downloads/ITM08_S1.dat",
    "/Users/ddb/Downloads/ETM10_S1-power.dat",
    "/Users/ddb/Downloads/ETM15_S1_-power_fit_on_160mm.dat",
]

for m in maps:
    p = pathlib.Path(m)
    tm = p.name.split('_')[0]
    x, y, A = finesse.ligo.maps.process_ligo_zygo_binary_data(p, 53e-3 if "ITM" in tm else 62e-3)
    try:
        hf = h5py.File(tm+'.h5', 'w')
        hf.create_dataset('finesse.version', data=finesse.__version__)
        hf.create_dataset('finesse.ligo.version', data=finesse.ligo.__version__)
        hf.create_dataset('x', data=x, compression="gzip", compression_opts=9)
        hf.create_dataset('y', data=y, compression="gzip", compression_opts=9)
        hf.create_dataset('A', data=A, compression="gzip", compression_opts=9)
    finally:
        hf.close()
        
    plt.figure(figsize=(8, 6))
    plt.imshow(A, extent=(x.min(), x.max(), y.min(), y.max()), interpolation='none')
    plt.colorbar(label="z [m]")
    plt.xlabel("x [m]")
    plt.ylabel("y [m]")
    plt.tight_layout()
    plt.savefig(tm+".png")</pre></body></html>