|
|
Line 1: |
Line 1: |
| {{variable|moderator=Ehac}} | | {{variable|moderator=Ehac}} |
− |
| |
− | ==Urgenche energy balance test==
| |
− |
| |
− | <rcode variables="name:heat|description:What is the amount of heat needed (kWh)?|default:500|
| |
− | name:electricity|description:What is the amount of electricity needed (kWh)?|default:1000">
| |
− | library(OpasnetUtils)
| |
− | library(xtable)
| |
− |
| |
− | D <- data.frame(
| |
− | CHP_Peat = c(-1, 0, 1.205, 1.205, 0, -1),
| |
− | CHP_Ren = c(-1, 0, -22.2, 0, 0, -1),
| |
− | CHP_Mineral = c(-1, 0, 0, -7.40, 0, -1),
| |
− | CHP_Heating = c(1, 1.43, 0, 0, 1, 0),
| |
− | Production_loss = c(1, 0, 0, 0, 0, 1/0.18),
| |
− | CHP_Electricity = c(1, -3.28, 0, 0, 0, 0)
| |
− | )
| |
− |
| |
− | D <- as.matrix(D)
| |
− |
| |
− | print(xtable(D), type ='html')
| |
− | B <- data.frame(Parameter = colnames(D), value = solve(D, c(0,0,0,0,heat, 0)))
| |
− | print(xtable(B), type = 'html')
| |
− |
| |
− | A <- data.frame(
| |
− | MengeGas = c(0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0),
| |
− | MengeWarme = c(0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0),
| |
− | MengeStrom = c(0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.5),
| |
− | MengeCO2 = c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0),
| |
− | KesselGas = c(-0.95, -55000, 0, 0, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0),
| |
− | KesselWarme = c(1, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 0, 0, 0),
| |
− | KesselCO2 = c(0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 0),
| |
− | GUDGas = c(0, 0, -0.47, -55000, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0),
| |
− | GUDStrom = c(0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, -1, 0, 0),
| |
− | GUDCO2 = c(0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, -1, 0),
| |
− | BHKWGas = c(0, 0, 0, 0, -0.3, 0, -55000, 0, 0, -1, 0, 0, 0, 0),
| |
− | BHKWWarme = c(0, 0, 0, 0, 0, -0.5, 0, 0, 0, 0, -1, 0, 0, 0),
| |
− | BHKWStrom = c(0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, -1, 0, 1),
| |
− | BHKWCO2 = c(0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, -1, 0)
| |
− | )
| |
− | A <- as.matrix(A)
| |
− |
| |
− | B <- data.frame(Parameter = colnames(A), value = solve(A, c(0, 0, 0, 0, 0, 0, 0, heat, electricity, 0, 0, 0, 0, 0)))
| |
− | print(xtable(B), type = 'html')
| |
− |
| |
− |
| |
− |
| |
− | </rcode>
| |
− |
| |
| | | |
| http://ytoswww/yhteiset/YMAL/Projects/ | | http://ytoswww/yhteiset/YMAL/Projects/ |
+ Show code- Hide code
library(rgdal)
library(maptools)
library(RColorBrewer)
library(classInt)
library(OpasnetBaseUtils)
library(RODBC)
shp <- spatial_db_query(paste('SELECT * FROM kuopio_house WHERE ika >= ',age,';',sep=''))
coordinates(shp)=c("y_koord","x_koord")
#shp<-readOGR('PG:host=localhost user=postgres dbname=spatial_db','kuopio_house')
plotvar<-shp@data$ika
nclr<-8
plotclr<-brewer.pal(nclr,"BuPu")
class<-classIntervals(plotvar,nclr,style="quantile")
colcode<-findColours(class,plotclr)
epsg4326String <- CRS("+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs")
proj4string(shp)<-("+init=epsg:3067")
shp2<-spTransform(shp,epsg4326String)
kmlname<-"Kuopio house data"
kmldescription<-"Random stuff about here"
icon<-"http://maps.google.com/mapfiles/kml/pal2/icon18.png"
name<-paste("Value: ",shp2$ika)
description <- paste("<b>Ikä:</b>",shp2$ika,"<br><b>Rakennustunnus:</b>",shp2$rakennustunnus)
MyPointKML<-function(obj = NULL, kmlname = "", kmldescription = "", name = NULL, description = "", icon = "http://maps.google.com/mapfiles/kml/pal4/icon24.png",col=NULL)
{
if (is.null(obj))
return(list(header = c("<?xml version=\"1.0\" encoding=\"UTF-8\"?>",
"<kml xmlns=\"http://earth.google.com/kml/2.2\">",
"<Document>", paste("<name>", kmlname, "</name>",
sep = ""), paste("<description><![CDATA[", kmldescription,
"]]></description>", sep = "")), footer = c("</Document>",
"</kml>")))
if (class(obj) != "SpatialPointsDataFrame")
stop("obj must be of class 'SpatialPointsDataFrame' [package 'sp']")
if (is.null(name)) {
name = c()
for (i in 1:nrow(obj)) name <- append(name, paste("site",
i))
}
col2kmlcolor <- function(col) paste(rev(sapply(col2rgb(col, TRUE), function(x) sprintf("%02x", x))), collapse = "")
kml <- kmlStyle <- ""
kmlHeader <- c("<?xml version=\"1.0\" encoding=\"UTF-8\"?>","<kml xmlns=\"http://earth.google.com/kml/2.2\">", "<Document>")
kmlFooter <- c("</Document>", "</kml>")
for (i in 1:nrow(obj)) {
point <- obj[i, ]
pt_name = name[i]
pt_description = description[i]
pt_style <- paste("#style", ifelse(length(icon) == 1, 1, i), sep = "")
kml <- append(kml, "<Placemark>")
kml <- append(kml, paste(" <description><![CDATA[",pt_description, "]]></description>", sep = ""))
#kml <- append(kml, "<Style><IconStyle>")
#kml <- append(kml, paste("<color>", col2kmlcolor(col[i]), "</color>", sep =""))
#kml <- append(kml, paste(" <Icon><href>", icon, "</href></Icon>", sep = ""))
#kml <- append(kml, "<scale>0.300000</scale>")
#kml <- append(kml, "</IconStyle></Style>")
kml <- append(kml, " <Point>")
kml <- append(kml, " <coordinates>")
kml <- append(kml, paste(point@coords[1], point@coords[2], sep = ","))
kml <- append(kml, " </coordinates>")
kml <- append(kml, " </Point>")
kml <- append(kml, "</Placemark>")
}
return(paste(paste(c(kmlHeader, kmlStyle, kml, kmlFooter), sep = "", collapse = "\n"), collapse="\n", sep = ""))
}
data <- MyPointKML(shp2,kmlname,kmldescription,name,description,icon,colcode)
google.show_kml_data_on_maps(data)
| |