From SW's laptop

master
sanginnwoo 2022-12-05 16:41:58 +09:00
parent a85ca0bf79
commit ec16712498
2 changed files with 82 additions and 25 deletions

View File

@ -5,19 +5,53 @@ Sang Inn Woo, Ph.D. @ Incheon National University
Starting Date: 2022-11-10
"""
import psycopg2 as pg2
import numpy as np
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
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
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)

View File

@ -57,21 +57,16 @@ def fun_rmse(py1, py2):
return np.sqrt(mse)
def run_settle_prediction(input_file, output_dir,
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,
settle_unit='cm'):
# ====================
# 파일 읽기, 데이터 설정
# ====================
def run_settle_prediction_from_file(input_file, output_dir,
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):
# 현재 파일 이름 출력
print("Working on " + input_file)
@ -84,11 +79,39 @@ def run_settle_prediction(input_file, output_dir,
settle = data['Settlement'].to_numpy()
surcharge = data['Surcharge'].to_numpy()
# 만일 침하량의 단위가 m일 경우, 조정
if settle_unit == 'm':
settle = settle * 100
run_settle_prediction(np_time=time,
np_surcharge=surcharge,
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 파악
final_index = time.size