注册 登录  
 加关注
   显示下一条  |  关闭
温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!立即重新绑定新浪微博》  |  关闭

阿弥陀佛

街树飘影未见尘 潭月潜水了无声 般若观照心空静...

 
 
 

日志

 
 
关于我

一直从事气象预报、服务建模实践应用。 注重气象物理场、实况场、地理信息、本体知识库、分布式气象内容管理系统建立。 对Barnes客观分析, 小波,计算神经网络、信任传播、贝叶斯推理、专家系统、网络本体语言有一定体会。 一直使用Java、Delphi、Prolog、SQL编程。

网易考拉推荐

R rbokeh 散布图  

2016-11-06 18:05:25|  分类: R |  标签: |举报 |字号 订阅

  下载LOFTER 我的照片书  |

# new version
library(rbokeh)
library(data.table)
ymdhmStr <- '201607180000'
elenm <- 'TEM'

elenms <- c("PRS", "PRS_Sea", "TEM", "DPT", "RHU", "VAP", "PRE_1h", "WIN_D_Avg_2mi", "WIN_S_Avg_2mi",
            "GST", "T_5cm", "T_10cm", "T_15cm", "T_20cm", "T_40cm", "U", "V", "QSE",
            "GTEM","VISM","DDDMAX","FFMAX","PRE_10m","PRE_5mprev","PRE_5mpost")
vnms <- c("V1","V2","V3","V4","V5","V6","V7","V8","V9","V10",
          "V11","V12","V13","V14","V15","V16","V17","V18","V19","V20",
          "V21","V22","V23","V24","V25","V26","V27","V28","V29","V30")
csvnms <- c("ymdhm","sta","lat","lon","alt",elenms)
ssnms <- c("ymdhm","cnm","bias","rmse","cor","nsamp")
ymdhms <- c(substr(ymdhmStr,1,4),substr(ymdhmStr,1,8))
eleIdx <- match(elenm,elenms)
vnm <- vnms[match(elenm,csvnms)]
vnm

fnmReal <- sprintf("/data/calf/csv/eleh/csvreal/%s/%s/%s.csv",
                   ymdhms[1],ymdhms[2],ymdhmStr)
fnmFit  <- sprintf("/data/calf/csv/eleh/csvfit/%s/%s/%s.csv",
                   ymdhms[1],ymdhms[2],ymdhmStr)
fnmStats<- sprintf("/data/calf/logs/RMSE/%s/%s/%s.txt",
                   ymdhms[1],ymdhms[2],ymdhmStr)
if (file.exists(fnmReal) & file.exists(fnmFit) & file.exists(fnmStats) ){
  print('all file exists')
} else {
  stop('some file not exists !')
}

dReal <- fread(fnmReal,select=c('V2',vnm))
dFit <- fread(fnmFit,select=c('V2',vnm))
ss0 <- read.csv(fnmStats,header = F)
ss1 <- ss0[eleIdx,] #提取统计向量
std <- ss1[4]       #均方根误擦

names(dReal) <- c('sta',elenms[eleIdx])
names(dFit)  <- c('sta',elenms[eleIdx])
names(ss1) <- ssnms
setkey(dReal,sta)
setkey(dFit,sta)
#tables()

realDF  <- data.frame(dReal)
fitDF   <- data.frame(dFit)
stas  <- realDF[realDF$sta %in% fitDF$sta,'sta']
tReal <- realDF[realDF$sta  %in% stas,elenm]
tFit  <- fitDF[fitDF$sta %in% stas,elenm]

tfmm <- c(min(tFit,na.rm = T),max(tFit,na.rm = T))
tfMM <- c(max(tFit,na.rm = T),max(tFit,na.rm = T))

length(stas)
length(tReal)
length(tFit)


m <- sprintf("%s,%s,%s=%s,%s=%s,%s=%s,%s=%s,"
             ,ss1[1],elenm,ssnms[3],ss1[3],ssnms[4],ss1[4],ssnms[5],ss1[5],ssnms[6],ss1[6])

# plot(tReal,tFit,xlab=m,ylab='拟合',main=elenm,type='p',pch = 20,col = "blue")
# z <- lm(tReal ~ tFit)
p <- figure(width = 800, height = 600,title=m,xlab=elenm,ylab='拟合') %>%
  ly_points(tReal, tFit,size=2) %>%
  # ly_abline(z, type = 1, legend = "回归线",color = "red") %>%
  ly_lines(tfmm, tfmm, tfMM,tfMM, type = 1, legend = "理想线",color = "black")
p
############################################################
# old version
library(rbokeh)
  ymdhmStr <- '201607180000'
  elenm <- 'TEM'
 
  elenms <- c("PRS", "PRS_Sea", "TEM", "DPT", "RHU", "VAP", "PRE_1h", "WIN_D_Avg_2mi", "WIN_S_Avg_2mi",
              "GST", "T_5cm", "T_10cm", "T_15cm", "T_20cm", "T_40cm", "U", "V", "QSE",
              "GTEM","VISM","DDDMAX","FFMAX","PRE_10m","PRE_5mprev","PRE_5mpost")
  csvnms <- c("ymdhm","sta","lat","lon","alt",elenms)
  ssnms <- c("ymdhm","cnm","bias","rmse","cor","nsamp")
  ymdhms <- c(substr(ymdhmStr,1,4),substr(ymdhmStr,1,8))
  eleIdx <- match(elenm,elenms)

  fnmReal <- sprintf("/data/calf/csv/eleh/csvreal/%s/%s/%s.csv",
                     ymdhms[1],ymdhms[2],ymdhmStr)
  fnmFit  <- sprintf("/data/calf/csv/eleh/csvfit/%s/%s/%s.csv",
                     ymdhms[1],ymdhms[2],ymdhmStr)
  fnmStats<- sprintf("/data/calf/logs/RMSE/%s/%s/%s.txt",
                     ymdhms[1],ymdhms[2],ymdhmStr)
   
  dReal <- read.csv(fnmReal,header = F)
  dFit <- read.csv(fnmFit,header = F)
  ss0 <- read.csv(fnmStats,header = F)
  ss1 <- ss0[eleIdx,]
 
  names(dReal) <- csvnms
  names(dFit) <- csvnms
  names(ss1) <- ssnms

  stas  <- dReal[dReal$sta %in% dFit$sta,"sta"]
  tReal <- dReal[dReal$sta %in% stas,elenm]
  tFit  <- dFit[dFit$sta %in% stas,elenm]
  tfmm <- c(min(tFit,na.rm = T),max(tFit,na.rm = T))
 
  length(stas)
  length(tReal)
  length(tFit)

 
  m <- sprintf("%s,%s,%s=%s,%s=%s,%s=%s,%s=%s,"
               ,ss1[1],elenm,ssnms[3],ss1[3],ssnms[4],ss1[4],ssnms[5],ss1[5],ssnms[6],ss1[6])

  # plot(tReal,tFit,xlab=m,ylab='拟合',main=elenm,type='p',pch = 20,col = "blue")
  # z <- lm(tReal ~ tFit)
  p <- figure(width = 800, height = 600,title=m,xlab=elenm,ylab='拟合') %>%
    ly_points(tReal, tFit,size=2) %>%
    # ly_abline(z, type = 1, legend = "回归线",color = "red") %>%
    ly_lines(tfmm,tfmm, type = 1, legend = "理想线",color = "black")
  p
 
R rbokeh 散布图 - 险峰 - 阿弥陀佛
 
R rbokeh 散布图 - 险峰 - 阿弥陀佛
 
R rbokeh 散布图 - 险峰 - 阿弥陀佛
 
R rbokeh 散布图 - 险峰 - 阿弥陀佛
 
R rbokeh 散布图 - 险峰 - 阿弥陀佛
 
R rbokeh 散布图 - 险峰 - 阿弥陀佛
 
R rbokeh 散布图 - 险峰 - 阿弥陀佛
 
R rbokeh 散布图 - 险峰 - 阿弥陀佛
 
R rbokeh 散布图 - 险峰 - 阿弥陀佛
 
R rbokeh 散布图 - 险峰 - 阿弥陀佛
 
R rbokeh 散布图 - 险峰 - 阿弥陀佛
  评论这张
 
阅读(78)| 评论(0)
推荐 转载

历史上的今天

在LOFTER的更多文章

评论

<#--最新日志,群博日志--> <#--推荐日志--> <#--引用记录--> <#--博主推荐--> <#--随机阅读--> <#--首页推荐--> <#--历史上的今天--> <#--被推荐日志--> <#--上一篇,下一篇--> <#-- 热度 --> <#-- 网易新闻广告 --> <#--右边模块结构--> <#--评论模块结构--> <#--引用模块结构--> <#--博主发起的投票-->
 
 
 
 
 
 
 
 
 
 
 
 
 
 

页脚

网易公司版权所有 ©1997-2017