From SW's laptop
parent
a85ca0bf79
commit
ec16712498
|
|
@ -5,19 +5,53 @@ Sang Inn Woo, Ph.D. @ Incheon National University
|
||||||
Starting Date: 2022-11-10
|
Starting Date: 2022-11-10
|
||||||
"""
|
"""
|
||||||
import psycopg2 as pg2
|
import psycopg2 as pg2
|
||||||
|
import numpy as np
|
||||||
import settle_prediction_steps_main
|
import settle_prediction_steps_main
|
||||||
|
|
||||||
|
|
||||||
|
'''
|
||||||
|
apptb_surset01
|
||||||
|
cons_code: names of monitoring points
|
||||||
|
|
||||||
|
apptb_surset02
|
||||||
|
cons_code: names of monitoring points
|
||||||
|
amount_cum_sub: accumulated settlement
|
||||||
|
fill_height: height of surcharge fill
|
||||||
|
nod: number of date
|
||||||
|
'''
|
||||||
|
|
||||||
|
|
||||||
# connect the database
|
# connect the database
|
||||||
conn = 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")
|
||||||
|
|
||||||
# set cursor
|
# set cursor
|
||||||
cur = conn.cursor()
|
cursor = connection.cursor()
|
||||||
|
|
||||||
# read data
|
# select all monitoring points
|
||||||
|
postgres_select_query = """SELECT * FROM apptb_surset01"""
|
||||||
|
cursor.execute(postgres_select_query)
|
||||||
|
point_record = cursor.fetchall()
|
||||||
|
|
||||||
|
# for a monitoring point, set name
|
||||||
|
point_name = point_record[0][3]
|
||||||
|
|
||||||
# extract settlement prediction data using the prime key
|
# select monitoring data for the monitoring point
|
||||||
|
postgres_select_query = """SELECT * FROM apptb_surset02 WHERE cons_code='""" \
|
||||||
|
+ point_name + """' ORDER BY nod ASC"""
|
||||||
|
cursor.execute(postgres_select_query)
|
||||||
|
monitoring_record = cursor.fetchall()
|
||||||
|
|
||||||
# run settlement analysis
|
# initialize time, surcharge, and settlement lists
|
||||||
|
time = []
|
||||||
|
surcharge = []
|
||||||
|
settlement = []
|
||||||
|
|
||||||
# save results in the database
|
# fill list
|
||||||
|
for row in monitoring_record:
|
||||||
|
settlement.append(float(row[6]))
|
||||||
|
surcharge.append(float(row[8]))
|
||||||
|
time.append(float(row[12]))
|
||||||
|
|
||||||
|
print(settlement)
|
||||||
|
print(surcharge)
|
||||||
|
print(time)
|
||||||
|
|
|
||||||
|
|
@ -57,21 +57,16 @@ def fun_rmse(py1, py2):
|
||||||
return np.sqrt(mse)
|
return np.sqrt(mse)
|
||||||
|
|
||||||
|
|
||||||
def run_settle_prediction(input_file, output_dir,
|
def run_settle_prediction_from_file(input_file, output_dir,
|
||||||
final_step_predict_percent, additional_predict_percent,
|
final_step_predict_percent, additional_predict_percent,
|
||||||
plot_show,
|
plot_show,
|
||||||
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='False',
|
||||||
run_asaoka = 'True',
|
run_asaoka='True',
|
||||||
run_step_prediction='True',
|
run_step_prediction='True',
|
||||||
asaoka_interval = 3,
|
asaoka_interval=3):
|
||||||
settle_unit='cm'):
|
|
||||||
|
|
||||||
# ====================
|
|
||||||
# 파일 읽기, 데이터 설정
|
|
||||||
# ====================
|
|
||||||
|
|
||||||
# 현재 파일 이름 출력
|
# 현재 파일 이름 출력
|
||||||
print("Working on " + input_file)
|
print("Working on " + input_file)
|
||||||
|
|
@ -84,11 +79,39 @@ def run_settle_prediction(input_file, output_dir,
|
||||||
settle = data['Settlement'].to_numpy()
|
settle = data['Settlement'].to_numpy()
|
||||||
surcharge = data['Surcharge'].to_numpy()
|
surcharge = data['Surcharge'].to_numpy()
|
||||||
|
|
||||||
# 만일 침하량의 단위가 m일 경우, 조정
|
run_settle_prediction(np_time=time,
|
||||||
if settle_unit == 'm':
|
np_surcharge=surcharge,
|
||||||
settle = settle * 100
|
np_settlement=settle,
|
||||||
|
final_step_predict_percent=final_step_predict_percent,
|
||||||
|
additional_predict_percent=additional_predict_percent,
|
||||||
|
plot_show=plot_show,
|
||||||
|
print_values=print_values,
|
||||||
|
run_original_hyperbolic=run_original_hyperbolic,
|
||||||
|
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)
|
||||||
|
|
||||||
# 데이터 닫기
|
def run_settle_prediction(np_time, np_surcharge, np_settlement,
|
||||||
|
final_step_predict_percent, additional_predict_percent,
|
||||||
|
plot_show,
|
||||||
|
print_values,
|
||||||
|
run_original_hyperbolic='True',
|
||||||
|
run_nonlinear_hyperbolic='True',
|
||||||
|
run_weighted_nonlinear_hyperbolic='False',
|
||||||
|
run_asaoka = 'True',
|
||||||
|
run_step_prediction='True',
|
||||||
|
asaoka_interval = 3):
|
||||||
|
|
||||||
|
# ====================
|
||||||
|
# 파일 읽기, 데이터 설정
|
||||||
|
# ====================
|
||||||
|
|
||||||
|
# 시간, 침하량, 성토고 배열 생성
|
||||||
|
time = np_time
|
||||||
|
settle = np_settlement
|
||||||
|
surcharge = np_surcharge
|
||||||
|
|
||||||
# 마지막 계측 데이터 index + 1 파악
|
# 마지막 계측 데이터 index + 1 파악
|
||||||
final_index = time.size
|
final_index = time.size
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue