Skip to content
Snippets Groups Projects
Commit e8c3bcfc authored by wactbprot's avatar wactbprot
Browse files

Berechnung der sz ...

parent 4740b1fa
No related branches found
No related tags found
No related merge requests found
......@@ -2,10 +2,23 @@
### DB request example
http://localhost:5984/sz_mc/_design/theoLw/_list/make_array/all?key=[100,5,0,0.001,-0.0018]
Die `view` all emited folgendes array als key:
key[0]: doc.M
key[1]: doc.N
key[2]: doc.p.randSdRel
key[3]: doc.t.randSdRel
key[4]: doc.m.mean
<pre>
function(doc) {
emit([doc.M,
doc.N,
doc.dyn,
doc.p.fill,
doc.p.randSdRel,
doc.p.offset,
doc.p.mmean,
doc.p.round,
doc.m.mean,
doc.t.between,
doc.t.randSdRel], doc.t.DeltaSdRel);
}
</pre>
http://localhost:5984/sz_mc/_design/theoLw/_view/all?key=[100,5,0.0016,0.03,0.2,0,-3.0e-05,8,-3.5e-07,5,0.005]
library(R4CouchDB)
library(ggplot2)
cdb <- cdbIni()
cdb$DBName <- "sz_mc"
cdb$design <- "theoLw"
cdb$view <- "all"
cdb$list <- "make_array"
## function(doc) {
##
## emit([doc.M, // 1
## doc.N, // 2
## doc.dyn, // 3
## doc.p.fill, // 4
## doc.p.randSdRel, // 5
## doc.p.offset, // 6
## doc.p.mmean, // 7
## doc.p.round, // 8
## doc.m.mean, // 9
## doc.t.between, // 10
## doc.t.randSdRel], // 11
## [doc.M, // 1
## doc.N, // 2
## doc.dyn, // 3
## doc.p.fill, // 4
## doc.p.randSdRel, // 5
## doc.p.offset, // 6
## doc.p.mmean, // 7
## doc.p.round, // 8
## doc.m.mean, // 9
## doc.t.between, // 0
## doc.t.randSdRel, // 11
## doc.t.DeltaMean, // 12
## doc.t.DeltaSd, // 13
## doc.t.DeltaSdRel]); // 14
## }
##
cdb$queryParam <- 'startkey=[100,5,0.0016,0.03,0.02,0,1e-10,8,-3.5e-7,5,0.005]&endkey=[100,5,0.0016,0.03,0.2,0,0.0000001,8,-3.5e-7,5,0.005]'
res <- cdbGetList(cdb)$res
dat <-matrix(unlist(res),ncol=length(res), nrow=length(res[[1]]))
plot(dat[7,], dat[12,], log="xy")
function(head, req) {
var share = require("lib/vaclab/share"),
row,
res = { "aaData":[]};
start(share.startJson);
while(row = getRow()) {
res.aaData.push(row.value);
}
send(toJSON(res));
}
......@@ -10,7 +10,7 @@ function(head, req) {
});
while(row = getRow()) {
res.push(row.value);
}
......
......@@ -3,29 +3,31 @@ library(R4CouchDB)
cdb <- cdbIni()
cdb$DBName <- "sz_mc"
## c(1e-3, 3e-3, 5e-3, 9e-3, 1e-2, 3e-2, 5e-2, 9e-2,1e-1, 3e-1, 5e-1, 9e-1)
#pfill <- c(0.37, 0.69, 1.19, 4.33, 7.49, 14.3, 50.1, 82.6, 149.3)
#ma <- c(-3.9e-9, -7.6e-9 , -1.3e-8 , -4.3e-8, -7.1e-8, -1.2e-7, -4.2e-7, -7.0e-7, -1.3e-6)*1000
for(l in 1:length(pfill)){
##c(1e-3, 3e-3, 5e-3, 9e-3, 1e-2, 3e-2, 5e-2, 9e-2,1e-1, 3e-1, 5e-1, 9e-1)
## pfill <- c(0.37, 0.69, 1.19, 4.33, 7.49, 14.3, 50.1, 82.6, 149.3)
## ma <- c(-3.9e-9, -7.6e-9 , -1.3e-8 , -4.3e-8, -7.1e-8, -1.2e-7, -4.2e-7, -7.0e-7, -1.3e-6)*1000
mmean <- c(0,1e-10,3e-10,1.3e-9,3e-9,5e-9,9e-9,2e-8,1.3e-8,3e-8,5e-8,9e-8,1.3e-7,3e-7,5e-7,9e-7,1.3e-6,3e-6,5e-6,9e-6, 1.3e-5,3e-5,5e-5,9e-5)
for(l in 1:length(mmean)){
for( k in 1:100){
### --------------------------------------------------------
d <- list(
M = 100, # Anz. Messpunkte pro SZ
N = 5, # Anz. der SZ
dyn = 1.6e-3, # Dynamikbereich des SZ
p = list(
fill = 3e-2, # mbar
randSdRel = 0.2 ,
offset = 0,
mmean = 0,#-1.3e-5,
round = 5),# mbar/s steigung der mittleren SZ Drcke
m = list(
mean = -3.5e-7),# mbar/s
t = list(
between = 5.0, # s
randSdRel = 5e-3) #
M = 100, # 1 : Anz. Messpunkte pro SZ
N = 5, # 2 :Anz. der SZ
dyn = 1.6e-3, # 3 :Dynamikbereich des SZ
p = list(
fill = 3e-2, # 4 :Flldruck in mbar
# 5 :muss zur Steigung Passen
# 6 :(evtl. noch berechn. einbaues)
randSdRel = 0.02, # 7 :Rel. sd des Rauschens
offset = 0, # 8 :Offset in mbar auf Nullindik.
mmean = mmean[l], # 9 :Steigung der mittl SZ-Drcke
round = 8), # 10:Runden (Digitalisierungseffekt)
m = list(
mean = -3.5e-7),# 11:Steigung des SZ in mbar/s
t = list(
between = 5.0, # 12:Antiebszeit in s
randSdRel = 5e-3) # 13:Rel. sd des rauschens der Zeit
)
### -------------------------------------------------------
......@@ -36,7 +38,8 @@ for(l in 1:length(pfill)){
d$t$d <- d$p$d / d$m$sz
d$t$T <- (mean(d$t$d) * d$M) * d$N # T Dauer aber ohne t.between
d$p$meanSz <- seq(d$p$offset - d$t$T* d$p$mmean/2,
d$p$offset + d$t$T* d$p$mmean/2, length.out=d$N)
d$p$offset + d$t$T* d$p$mmean/2,
length.out=d$N)
d$p$upper <- d$p$meanSz + d$p$D / 2
d$p$lower <- d$p$meanSz - d$p$D / 2
d$t$randSd <- abs(d$t$T * d$t$randSdRel)
......@@ -45,32 +48,31 @@ for(l in 1:length(pfill)){
## neue knstliche SZs
## erzeugen
d$p$pure <- matrix(NA, ncol = d$M , nrow = d$N)
d$p$rand <- matrix(NA, ncol = d$M , nrow = d$N)
d$t$pure <- matrix(NA, ncol = d$M , nrow = d$N)
d$t$rand <- matrix(NA, ncol = d$M , nrow = d$N)
ppure <- matrix(NA, ncol = d$M , nrow = d$N)
prand <- matrix(NA, ncol = d$M , nrow = d$N)
tpure <- matrix(NA, ncol = d$M , nrow = d$N)
trand <- matrix(NA, ncol = d$M , nrow = d$N)
d$m$rand <- rep(NA, d$N)
d$c$rand <- rep(NA, d$N)
d$p$randMean <- rep(NA, d$N)
d$t$randMean <- rep(NA, d$N)
for(i in 1:d$N){
if(i == 1){
d$t$pure[i,] <- d$t$d[i] * idx
tpure[i,] <- d$t$d[i] * idx
ppure[i,] <- d$p$d[i] * idx
}else{
d$t$pure[i,] <- d$t$pure[i-1, d$M] + d$t$between + d$t$d[i] * idx
tpure[i,] <- tpure[i-1, d$M] + d$t$between + d$t$d[i] * idx
ppure[i,] <- ppure[i-1, d$M] + d$t$between *d$p$mmean + d$p$D + d$p$d * idx
}
d$p$pure[i,] <- seq(d$p$upper[i],
d$p$lower[i],
length.out = d$M)
d$p$rand[i,] <- round(d$p$pure[i,] + rnorm(d$M, 0, d$p$randSd),d$p$round)
d$t$rand[i,] <- d$t$pure[i,] + rnorm(d$M, 0, d$t$randSd)
prand[i,] <- round(ppure[i,] + rnorm(d$M, 0, d$p$randSd),d$p$round)
trand[i,] <- tpure[i,] + rnorm(d$M, 0, d$t$randSd)
temp.lm <- lm( d$p$rand[i,] ~ d$t$rand[i,])
temp.lm <- lm( prand[i,] ~ trand[i,])
d$m$rand[i] <- coefficients(temp.lm)[2]
d$p$randMean[i] <- mean(d$p$rand[i,])
d$t$randMean[i] <- mean(d$t$rand[i,])
d$p$randMean[i] <- mean(prand[i,])
d$t$randMean[i] <- mean(trand[i,])
}
d$p$randIntercept <- d$p$randMean - d$m$rand * d$t$randMean
......@@ -86,10 +88,10 @@ for(l in 1:length(pfill)){
}
pt.df <- data.frame(d.p.pure = as.vector(d$p$pure),
d.t.pure = as.vector(d$t$pure),
d.p.rand = as.vector(d$p$rand),
d.t.rand = as.vector(d$t$rand))
pt.df <- data.frame(d.p.pure = as.vector(ppure),
d.t.pure = as.vector(tpure),
d.p.rand = as.vector(prand),
d.t.rand = as.vector(trand))
ggplot(pt.df) +
geom_point(aes(x = d.t.pure, y = d.p.pure), color='black') +
geom_point(aes(x = d.t.rand, y = d.p.rand), color='red') +
......
cdb <- cdbInit()
cdb$DBName <- "sz_mc"
cdb$id <- "1f817eefa918f5bb1a8620eaa01f9aac"
d <- cdbGetDoc(cdb)$res
pt.df <- data.frame(d.p.pure = unlist(d$p$pure),
d.t.pure = unlist(d$t$pure),
d.p.rand = unlist(d$p$rand),
d.t.rand = unlist(d$t$rand))
ggplot(pt.df) +
geom_point(aes(x = d.t.pure, y = d.p.pure), color='black') +
geom_point(aes(x = d.t.rand, y = d.p.rand), color='red') +
geom_abline(aes(intercept = unlist(d$p$randIntercept), slope = unlist(d$m$rand)), color='red') +
geom_vline(xintercept = unlist(d$t$rand0), linetype = "longdash") +
geom_point(aes(y = unlist(d$p$randMean), x = unlist(d$t$randMean)), color="black", size=4) +
ggtitle("dp vs. dt")
function(doc) {
emit([doc.M, doc.N, doc.p.randSdRel,doc.t.randSdRel,doc.m.mean], doc.t.DeltaSdRel);
}
emit([doc.M, // 1
doc.N, // 2
doc.dyn, // 3
doc.p.fill, // 4
doc.p.randSdRel, // 5
doc.p.offset, // 6
doc.p.mmean, // 7
doc.p.round, // 8
doc.m.mean, // 9
doc.t.between, // 10
doc.t.randSdRel], // 11
[doc.M, // 1
doc.N, // 2
doc.dyn, // 3
doc.p.fill, // 4
doc.p.randSdRel, // 5
doc.p.offset, // 6
doc.p.mmean, // 7
doc.p.round, // 8
doc.m.mean, // 9
doc.t.between, // 0
doc.t.randSdRel, // 11
doc.t.DeltaMean, // 12
doc.t.DeltaSd, // 13
doc.t.DeltaSdRel]); // 14
}
function(doc) {
if(doc.p.randSdRel < 1e-6){
emit(null, {"pRandSdRel":doc.p.randSdRel,
"tRandSdRel":doc.t.randSdRel,
"DeltaMean":doc.t.DeltaMean,
"DeltaSdRel":doc.t.DeltaSdRel
}
);
}
}
function(doc) {
if(doc.t.randSdRel > 4.9e-3 && doc.p.randSdRel > 4.9e-3 &&
doc.t.randSdRel < 5.1e-3 && doc.p.randSdRel < 5.1e-3){
emit(null, {"pRandSdRel":doc.p.randSdRel,
"tRandSdRel":doc.t.randSdRel,
"DeltaMean":doc.t.DeltaMean,
"DeltaSdRel":doc.t.DeltaSdRel,
"mMean":doc.m.mean
}
);
}
}
function(doc) {
if(doc.t.randSdRel < 1e-6){
emit(null, {"pRandSdRel":doc.p.randSdRel,
"tRandSdRel":doc.t.randSdRel,
"DeltaMean":doc.t.DeltaMean,
"DeltaSdRel":doc.t.DeltaSdRel
}
);
}
}
function(doc) {
emit([doc.M,
doc.N,
doc.dyn,
doc.p.fill,
doc.p.randSdRel,
doc.p.offset,
doc.p.mmean,
doc.p.round,
doc.m.mean,
doc.t.between,
doc.t.randSdRel], 1 );
}
function(k, v, c){
return sum(v);
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment