Browse Source

minor modifications : added blank rows.

master
김선중 1 year ago
parent
commit
b1adf75c9f
2 changed files with 26 additions and 8 deletions
  1. +4
    -7
      Scripts/generate_signals.py
  2. +22
    -1
      Scripts/preprocess_daily.py

+ 4
- 7
Scripts/generate_signals.py View File

@ -1006,6 +1006,7 @@ class SignalGenerator():
csig = pd.concat(csig).reset_index(drop=True)
return csig
# 5-3. 부적절하게 연속된 신호조합 체크
def find_impropers(self):
improper_pairs = dict()
@ -1062,6 +1063,7 @@ class SignalGenerator():
for review in self.issues:
print(review)
def main(self):
self.time0 = datetime.now()
# 1. 데이터 준비
@ -1107,6 +1109,7 @@ class SignalGenerator():
print('(6)', self.time6 - self.time5)
print('total time :', self.time6 - self.time0)
if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument('-c','--config_name', dest='config_name', type=str, default='test_0721')
@ -1123,10 +1126,4 @@ if __name__ == '__main__':
minute = args.minute
self = SignalGenerator(config_name=config_name, month=month, day=day,
hour=hour, minute=minute)
self.main()
# self.path_unit = os.path.join(self.path_root, 'Analysis', '0207_unit_test')
# self.hrhists.to_csv(os.path.join(self.path_unit, 'hrhists.csv'))
# self.histids.to_csv(os.path.join(self.path_unit, 'histids.csv'))
# self.sigtable.to_csv(os.path.join(self.path_unit, 'sigtable.csv'))
# self.Sigtable.to_csv(os.path.join(self.path_unit, 'ssigtable.csv'))
# print("elapsed time :", datetime.now() - starting_time)
self.main()

+ 22
- 1
Scripts/preprocess_daily.py View File

@ -14,7 +14,7 @@ class DailyPreprocessor():
self.path_root = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
with open(os.path.join(self.path_root, 'configs', f'config_{self.config_name}.json'), 'r') as config_file:
config = json.load(config_file)
# 주요 폴더 경로 지정
self.paths = config['paths']
self.path_data = os.path.join(self.path_root, *self.paths['data'])
@ -27,6 +27,7 @@ class DailyPreprocessor():
# 이슈사항 목록
self.issues = []
# 1. 데이터 불러오기
def load_data(self):
print('1. 데이터를 로드합니다.')
@ -37,11 +38,13 @@ class DailyPreprocessor():
self.standardize()
self.store_objects()
# 1-1. 네트워크 불러오기
def load_networks(self):
self.net = sumolib.net.readNet(self.path_network)
print("1-1. 네트워크가 로드되었습니다.")
# 1-2. 테이블 불러오기
def load_tables(self):
if self.config_name == 'draft':
@ -160,6 +163,7 @@ class DailyPreprocessor():
print("1-2. 테이블들이 로드되었습니다.")
# 1-3. 네트워크 무결성 검사
def check_networks(self):
# https://sumo.dlr.de/docs/Netedit/neteditUsageExamples.html#simplify_tls_program_state_after_changing_connections
@ -184,6 +188,7 @@ class DailyPreprocessor():
traci.close()
print("1-3. 네트워크의 모든 clean state requirement들을 체크했습니다.")
# 1-4. 테이블 무결성 검사
def check_tables(self):
self.check_plan()
@ -191,6 +196,7 @@ class DailyPreprocessor():
self.check_angle()
print("1-4. 테이블들의 무결성 검사를 완료했습니다.")
# 1-4-1. 신호계획(plan) 검사
def check_plan(self):
# 1-4-1-1. inter_no 검사
@ -242,6 +248,7 @@ class DailyPreprocessor():
msg = f"1-4-1-5. inter_no:{inc_inter_no}, A링현시시간의 합과 B링현시시간의 합이 일치하지 않거나, 현시시간의 합과 주기가 일치하지 않습니다."
self.issues.append(msg)
# 1-4-2. 교차로정보(inter_info) 검사
def check_inter_info(self):
# 1-4-2-1. inter_lat, inter_lon 적절성 검사
@ -255,6 +262,7 @@ class DailyPreprocessor():
msg = f"1-4-2-1. 위도 또는 경도가 범위를 벗어난 교차로가 있습니다: inter_no : {row['inter_no']}"
self.issues.append(msg)
# 1-4-3. 방위각정보(inter_info) 검사
def check_angle(self):
# 1-4-3-1. inter_no 검사
@ -444,6 +452,7 @@ class DailyPreprocessor():
print("1-6. 주요 객체 (리스트, 딕셔너리)들을 저장했습니다.")
# 2. 중간산출물 만들기
def get_intermediates(self):
print('2. 중간산출물을 생성합니다.')
@ -454,6 +463,7 @@ class DailyPreprocessor():
self.avoid_all_reds()
self.save_intermediates()
# 2-1 매칭테이블 생성
def get_matches(self):
self.make_match1()
@ -465,6 +475,7 @@ class DailyPreprocessor():
self.make_matching()
print('2-1. 매칭 테이블들을 생성했습니다.')
# 2-1-1
def make_match1(self, fetch_all:bool=False):
'''
@ -493,6 +504,7 @@ class DailyPreprocessor():
else:
self.match1 = pd.read_csv(os.path.join(self.path_intermediates, 'match1.csv'))
# 2-1-2
def make_match2(self):
'''
@ -511,6 +523,7 @@ class DailyPreprocessor():
self.match2 = self.match2[['inter_no', 'phase_no', 'ring_type', 'move_no']]
self.match2 = self.match2.sort_values(by=list(self.match2.columns))
# 2-1-3
def make_match3(self):
'''
@ -521,6 +534,7 @@ class DailyPreprocessor():
# nema 정보 불러오기 및 병합
self.match3 = pd.merge(self.match2, self.nema, how='left', on='move_no').drop_duplicates()
# 2-1-4
def make_match4(self):
'''
@ -558,6 +572,7 @@ class DailyPreprocessor():
self.match4.at[i, 'inc_angle'] = im2inc_angle[(inter_no, move_no)]
self.match4.at[i, 'out_angle'] = im2out_angle[(inter_no, move_no)]
# 2-1-5
def make_match5(self):
'''
@ -633,6 +648,7 @@ class DailyPreprocessor():
turn_type = io2turn[(inc_edge_id, out_edge_id)]
self.match5.at[i, 'turn_type'] = turn_type
# 2-1-6
def make_match6(self):
'''
@ -772,6 +788,7 @@ class DailyPreprocessor():
self.match6 = pd.concat([self.match5, cmatches, self.coord]).drop_duplicates().sort_values(by=['inter_no', 'node_id', 'phase_no', 'ring_type'])
self.match6 = self.match6.reset_index(drop=True)
# 2-1-7
def make_matching(self):
'''
@ -898,6 +915,7 @@ class DailyPreprocessor():
.sort_values(by=['inter_no', 'node_id', 'move_no']).reset_index(drop=True)
self.matching['move_no'] = self.matching['move_no'].astype(int)
# 2-2 신호 초기화
def initialize_state(self):
'''
@ -1017,6 +1035,7 @@ class DailyPreprocessor():
self.p2UPLindices2inc_edge_ids[parent_id][UPLindex] = inc_edge_ids
print('2-3. 유턴 인덱스 / 비보호좌회전 인덱스를 지정했습니다.')
# 2-4 신호배정
def assign_signals(self):
# matching : 신호 배정
@ -1184,6 +1203,7 @@ class DailyPreprocessor():
for review in self.issues:
print(review)
def main(self):
# 1. 데이터 불러오기
self.load_data()
@ -1192,6 +1212,7 @@ class DailyPreprocessor():
# 3. 이슈사항 저장
self.write_issues()
if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument('-c','--config_name', dest='config_name', type=str, default='revised')

Loading…
Cancel
Save