import os
import pandas as pd
import numpy as np
import sys
sys.path.append('Scripts')
from preprocess_daily import DailyPreprocessor
from generate_signals import SignalGenerator

self = DailyPreprocessor()
self.load_data() # 1
self.make_match1() # 2-1
self.make_match2() # 2-2
self.make_match3() # 2-3

# helper dictionaries
im2inc_angle = dict() # a dictionary that maps (inter_no, move_no) to inc_angle
im2out_angle = dict() # a dictionary that maps (inter_no, move_no) to out_angle
for row in self.angle.itertuples():
    inter_no = row.inter_no
    move_no = row.move_no
    angle_code = row.angle_code
    im2inc_angle[(inter_no, move_no)] = angle_code[:3]
    im2out_angle[(inter_no, move_no)] = angle_code[3:]
for inter_no in self.inter_nos:
    im2inc_angle[(inter_no, 17)] = np.nan
    im2out_angle[(inter_no, 17)] = np.nan
    im2inc_angle[(inter_no, 18)] = np.nan
    im2out_angle[(inter_no, 18)] = np.nan

# 진입, 진출 방위각 매칭
self.match4 = self.match3.copy()
for i, row in self.match4.iterrows():
    inter_no = row.inter_no
    move_no = row.move_no
    self.match4.at[i, 'inc_angle'] = im2inc_angle[(inter_no, move_no)]
    self.match4.at[i, 'out_angle'] = im2out_angle[(inter_no, move_no)]
self.match4.head()

