import os
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt


df = pd.read_csv('curated_data.csv')
print(df.info())

# Plots
#fig, ax = plt.subplots(1, 1, figsize=(7, 2.5))
fig = plt.figure(figsize=(9, 9))

N_dev = len(list(df.dev.unique()))
print(f'{N_dev=}')
n_plot = 0
for n, dev in enumerate(df.dev.unique()):
    for ant in [0,1]:
        n_plot += 1
        dfq = df.query(f'dev=="{dev}" and antenna=={ant}')
        print(f'{n_plot} {n=} {ant=} {dfq.empty}')
        if not dfq.empty:
            ax = plt.subplot(N_dev, 2, n_plot)
            plt.plot(dfq.de, dfq.dn, 
                        marker='+', linewidth=0,
                        )
            for i, row in dfq.iterrows():
                ax.annotate(row['label'], (row['de'], row['dn']))
            if ant == 0:
                ax.set_ylabel('Delta Northing (m)')
            if n > 0:
                plt.xlim([-0.007, 0.002])
                ax.set_ylim([-0.001, 0.006])
            if n == 0:
                ax.set_title(f'Ant {ant}')
            if n == N_dev -1:
                ax.set_xlabel('Delta Easting (m)')

plt.savefig('curated_plot.png')
plt.show()
