# Check path existence
if not os.path.exists(full_x_valid_path):
    os.makedirs(full_x_valid_path)
if not os.path.exists(model_path):
    os.makedirs(model_path)

##########################################################
# 2. Construct normal series and abnormal series
##########################################################
normal_series_list = []

print('Start constructing normal series....')
for filename in sorted(glob.glob(normal_output_path + '*.txt')):
    print(filename)
    series = utils.txt_to_series(filename)
    print(series.shape)
    normal_series_list.append(series)

##########################################################
# 3. Load and Process Data
##########################################################
print('Start loading and processing data...')
# Initiate data
temp = normal_series_list[0].copy()
split_time = int(temp.shape[0] * 0.8)
temp_x_train = temp[:split_time]
temp_x_valid = temp[split_time:]
full_x_valid = temp_x_valid.copy()

# Initiate training and valid set
# Check path existence
if not os.path.exists(full_x_valid_path):
    os.makedirs(full_x_valid_path)
if not os.path.exists(model_path):
    os.makedirs(model_path)

##########################################################
# 2. Construct normal series and abnormal series
##########################################################
normal_series_list = []

print('Start constructing normal series....')
for filename in sorted(glob.glob(normal_output_path + '*.txt')):
    print(filename)
    series = utils.txt_to_series(filename)[:, 87:123]
    print(series.shape)
    normal_series_list.append(series)

##########################################################
# 3. Load and Process Data
##########################################################
print('Start loading and processing data...')
# Initiate data
temp = normal_series_list[0].copy()
split_time = int(temp.shape[0] * 0.8)
temp_x_train = temp[:split_time]
temp_x_valid = temp[split_time:]
full_x_valid = temp_x_valid.copy()

# Initiate training and valid set