Skip to content
Snippets Groups Projects
Commit 12bde30b authored by clblatte's avatar clblatte
Browse files

Merge branches 'maria_FBE' and 'maria_FBE' of gitlab.jyu.fi:clblatte/simo_output into maria_FBE

parents b875dd1e fa2807f0
No related branches found
No related tags found
No related merge requests found
#####
#
# Restructer the SIMO output in the SQLite database (final "UNIT" table)
# Restructer the SIMO output in the SQLite database (final "UNIT_2" table)
#
# 2019-07-15
#
......@@ -130,6 +130,11 @@ create_table_UNIT <- 'Create Table UNIT AS SELECT u.*,
ORDER BY u.id, l.branch, l.data_date'
create_table_UNIT_2 <- 'Create Table UNIT_2 AS SELECT u.*,
(4.471+0.0645*u.D_gm - 0.0001745*u.N + 0.006439*u.V_pine*(CASE WHEN u.H_dom >= 10 THEN 1 ELSE 0 END) + 0.005733*u.V_penbirch + u.V_pubbirch*(CASE WHEN u.H_dom >= 10 THEN 1 ELSE 0 END)) as Scenic_beauty,
(income/power(1.03, year-2016+2.5)) as Disc_income_3,
(PV/power(1.03, year-2016+2.5)) as Disc_PV_3
FROM UNIT u'
# -------------------
# Process: Run queries for all regimes
......@@ -142,19 +147,20 @@ db <- dbConnect(dbDriver("SQLite"),
# If the following tables already exist, for which the query is defined, remove them
tab_to_delete <- c("OPERS2", "OPERS3", "max_v", "UNIT")
tab_to_delete <- c("OPERS2", "OPERS3", "max_v", "UNIT","UNIT_2")
# Remove the tables if already exist
for(i in tab_to_delete){
if(dbExistsTable(db, i)) {dbRemoveTable(db, i)}
}
# Run the Queries and create the final table "UNIT",
# Run the Queries and create the final table "UNIT_2",
# which contains the development of all stands and indicators under the simulated management regimes
query_to_run <- c(create_table_max_v,
create_table_OPERS2,
create_table_OPERS3,
create_table_UNIT)
create_table_UNIT,
create_table_UNIT_2)
for(i in query_to_run){
......
#####
#
# Restructer the SIMO output in the SQLite database (final "UNIT" table)
# Restructer the SIMO output in the SQLite database (final "UNIT_2" table)
#
# !!! ONLY FOR SetAside simulations
#
......@@ -78,7 +78,9 @@ create_table_UNIT <- 'Create Table UNIT AS SELECT u.*,
ORDER BY u.id, l.branch, l.data_date'
create_table_UNIT_2 <- 'Create Table UNIT_2 AS SELECT u.*,
(4.471+0.0645*u.D_gm - 0.0001745*u.N + 0.006439*u.V_pine*(CASE WHEN u.H_dom >= 10 THEN 1 ELSE 0 END) + 0.005733*u.V_penbirch + u. V_pubbirch*(CASE WHEN u.H_dom >= 10 THEN 1 ELSE 0 END)) as Scenic_beauty
FROM UNIT u'
# -------------------
# Process: Run queries for SA
......@@ -92,7 +94,7 @@ db <- dbConnect(dbDriver("SQLite"),
# If the following tables already exist, for which the query is defined, remove them
tab_to_delete <- c("OPERS2", "OPERS3", "max_v", "UNIT")
tab_to_delete <- c("OPERS2", "OPERS3", "max_v", "UNIT", "UNIT_2")
# Remove the tables if already exist
......@@ -100,9 +102,9 @@ for(i in tab_to_delete){
if(dbExistsTable(db, i)) {dbRemoveTable(db, i)}
}
# Run the Queries and create the final table "UNIT",
# Run the Queries and create the final table "UNIT_2",
# which contains the development of all stands and indicators under the simulated management regimes
query_to_run <- c(create_table_max_v, create_table_UNIT)
query_to_run <- c(create_table_max_v, create_table_UNIT, create_table_UNIT_2)
for(i in query_to_run){
dbExecute(db, i)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment