From SW's laptop

master
sanginnwoo 2022-12-17 20:20:18 +09:00
parent a748d20de2
commit 261f1d8e95
3 changed files with 49 additions and 46 deletions

View File

@ -39,15 +39,7 @@ for input_file in input_files:
# 침하 예측을 수행하고 반환값 저장 # 침하 예측을 수행하고 반환값 저장
return_values = settle_prediction_steps_main. \ return_values = settle_prediction_steps_main. \
run_settle_prediction(input_file=input_file, output_dir=output_dir, run_settle_prediction(,
final_step_predict_percent=i,
additional_predict_percent=100,
plot_show=False,
print_values=False,
run_original_hyperbolic=True,
run_nonlinear_hyperbolic=True,
run_step_prediction=True,
settle_unit=settle_unit)
# 데이터프레임에 일단 및 다단 성토를 포함한 예측의 에러를 저장 # 데이터프레임에 일단 및 다단 성토를 포함한 예측의 에러를 저장
df_overall.loc[len(df_overall.index)] = [input_file, i, return_values[0], return_values[1], df_overall.loc[len(df_overall.index)] = [input_file, i, return_values[0], return_values[1],

View File

@ -25,7 +25,8 @@ nod: number of date
def settlement_prediction(point_name): def settlement_prediction(point_name):
# connect the database # connect the database
connection = pg2.connect("host=localhost dbname=postgres user=postgres password=lab36981 port=5432") #connection = pg2.connect("host=localhost dbname=postgres user=postgres password=lab36981 port=5432") # local
connection = pg2.connect("host=192.168.0.13 dbname=sgis user=sgis password=sgis port=5432") # ICTWay internal
# set cursor # set cursor
cursor = connection.cursor() cursor = connection.cursor()
@ -43,9 +44,9 @@ def settlement_prediction(point_name):
# fill lists # fill lists
for row in monitoring_record: for row in monitoring_record:
settlement.append(float(row[6])) settlement.append(float(row[5]))
surcharge.append(float(row[8])) surcharge.append(float(row[7]))
time.append(float(row[12])) time.append(float(row[1]))
# convert lists to np arrays # convert lists to np arrays
settlement = np.array(settlement) settlement = np.array(settlement)
@ -53,19 +54,14 @@ def settlement_prediction(point_name):
time = np.array(time) time = np.array(time)
# run the settlement prediction and get results # run the settlement prediction and get results
results = settle_prediction_steps_main.run_settle_prediction(point_name=point_name, results = settle_prediction_steps_main.run_settle_prediction(point_name=point_name, np_time=time,
np_time=time, np_surcharge=surcharge, np_settlement=settlement,
np_surcharge=surcharge,
np_settlement=settlement,
final_step_predict_percent=90, final_step_predict_percent=90,
additional_predict_percent=300, additional_predict_percent=300, plot_show=False,
plot_show=False, print_values=False, run_original_hyperbolic=True,
print_values=False,
run_original_hyperbolic=True,
run_nonlinear_hyperbolic=True, run_nonlinear_hyperbolic=True,
run_weighted_nonlinear_hyperbolic=True, run_weighted_nonlinear_hyperbolic=True,
run_asaoka=True, run_asaoka=True, run_step_prediction=True,
run_step_prediction=True,
asaoka_interval=3) asaoka_interval=3)
# if there are prediction data for the given data point, delete it first # if there are prediction data for the given data point, delete it first
@ -73,6 +69,14 @@ def settlement_prediction(point_name):
cursor.execute(postgres_delete_query) cursor.execute(postgres_delete_query)
connection.commit() connection.commit()
# prediction method code
# 0: original hyperbolic method
# 1: nonlinear hyperbolic method
# 2: weighted nonlinear hyperbolic method
# 3: Asaoka method
# 4: Step loading
# 5: temp
# insert predicted settlement into database # insert predicted settlement into database
for i in range(5): for i in range(5):
@ -85,7 +89,8 @@ def settlement_prediction(point_name):
# construct insert query # construct insert query
postgres_insert_query \ postgres_insert_query \
= """INSERT INTO apptb_pred02 (cons_code, prediction_progress_days, predicted_settlement, prediction_method) """\ = """INSERT INTO apptb_pred02 """ \
+ """(cons_code, prediction_progress_days, predicted_settlement, prediction_method) """ \
+ """VALUES (%s, %s, %s, %s)""" + """VALUES (%s, %s, %s, %s)"""
# set data to insert # set data to insert
@ -128,8 +133,18 @@ def read_database_and_plot(point_name):
surcharge_monitored = np.array(surcharge_monitored) surcharge_monitored = np.array(surcharge_monitored)
time_monitored = np.array(time_monitored) time_monitored = np.array(time_monitored)
# prediction method code
# 0: original hyperbolic method
# 1: nonlinear hyperbolic method
# 2: weighted nonlinear hyperbolic method
# 3: Asaoka method
# 4: Step loading
# 5: temp
# temporarily set the prediction method as 0
prediction_method = 0 prediction_method = 0
# select monitoring data for the monitoring point
# select predicted data for the monitoring point
postgres_select_query = """SELECT prediction_progress_days, predicted_settlement """ \ postgres_select_query = """SELECT prediction_progress_days, predicted_settlement """ \
+ """FROM apptb_pred02 WHERE cons_code= '""" + point_name \ + """FROM apptb_pred02 WHERE cons_code= '""" + point_name \
+ """' and prediction_method = """ + str(prediction_method) \ + """' and prediction_method = """ + str(prediction_method) \
@ -169,12 +184,10 @@ def read_database_and_plot(point_name):
linestyle='--', color='red', label='Original Hyperbolic') linestyle='--', color='red', label='Original Hyperbolic')
# script to call: python3 controller.py [business_code] [cons_code]
# python3 controller.py 1_SP-5 # for example:
if __name__ == '__main__': if __name__ == '__main__':
args = sys.argv[1:] args = sys.argv[1:]
point_name = args[0] point_name = args[0]
#settlement_prediction(point_name=point_name) settlement_prediction(point_name=point_name)
read_database_and_plot(point_name=point_name) # read_database_and_plot(point_name=point_name) #DB 입력 결과 확인 시에 활성화 / 평소에는 비활성화

View File

@ -79,19 +79,12 @@ def run_settle_prediction_from_file(input_file, output_dir,
settle = data['Settlement'].to_numpy() settle = data['Settlement'].to_numpy()
surcharge = data['Surcharge'].to_numpy() surcharge = data['Surcharge'].to_numpy()
run_settle_prediction(point_name=input_file, run_settle_prediction(point_name=input_file, np_time=time, np_surcharge=surcharge, np_settlement=settle,
np_time=time,
np_surcharge=surcharge,
np_settlement=settle,
final_step_predict_percent=final_step_predict_percent, final_step_predict_percent=final_step_predict_percent,
additional_predict_percent=additional_predict_percent, additional_predict_percent=additional_predict_percent, plot_show=plot_show,
plot_show=plot_show, print_values=print_values, run_original_hyperbolic=run_original_hyperbolic,
print_values=print_values, run_nonlinear_hyperbolic=run_nonlinear_hyperbolic, run_weighted_nonlinear_hyperbolic='False',
run_original_hyperbolic=run_original_hyperbolic, run_asaoka=run_asaoka, run_step_prediction=run_step_prediction,
run_nonlinear_hyperbolic=run_nonlinear_hyperbolic,
run_weighted_nonlinear_hyperbolic='False',
run_asaoka=run_asaoka,
run_step_prediction=run_step_prediction,
asaoka_interval=asaoka_interval) asaoka_interval=asaoka_interval)
def run_settle_prediction(point_name, def run_settle_prediction(point_name,
@ -101,10 +94,10 @@ def run_settle_prediction(point_name,
print_values, print_values,
run_original_hyperbolic='True', run_original_hyperbolic='True',
run_nonlinear_hyperbolic='True', run_nonlinear_hyperbolic='True',
run_weighted_nonlinear_hyperbolic='False', run_weighted_nonlinear_hyperbolic='True',
run_asaoka = 'True', run_asaoka = 'True',
run_step_prediction='True', run_step_prediction='True',
asaoka_interval = 3): asaoka_interval = 5):
# ==================== # ====================
# 파일 읽기, 데이터 설정 # 파일 읽기, 데이터 설정
@ -757,6 +750,11 @@ def run_settle_prediction(point_name,
final_error_hyper_original, final_error_hyper_nonlinear, final_error_hyper_weight_nonlinear, final_error_hyper_original, final_error_hyper_nonlinear, final_error_hyper_weight_nonlinear,
final_error_asaoka, final_error_step] final_error_asaoka, final_error_step]
#def run_postprocessing_error(point_name, np_time, np_surcharge, np_settlement):
# a = a + 1
#def run_postprocessing_graph(point_name, np_time, np_surcharge, np_)
#
''' '''
run_settle_prediction(input_file='data/2-5_No.39.csv', run_settle_prediction(input_file='data/2-5_No.39.csv',
output_dir='output', output_dir='output',