Commit 97373880 authored by Jean-Marie Lepioufle's avatar Jean-Marie Lepioufle
Browse files

added qa data timeserie gathering

parent 0ad2a2f8
......@@ -13,10 +13,9 @@ Depends:
Imports:
luftkvalr,
timelyr
Remotes:
git::git@git.nilu.no:rdbnilu/luftkvalr.git,
Remotes: git::git@git.nilu.no:rdbnilu/luftkvalr.git,
git::git@git.nilu.no:rfriendlyr/timelyr.git
License: GPL-3
Encoding: UTF-8
LazyData: false
RoxygenNote: 6.0.1
RoxygenNote: 5.0.1
# Generated by roxygen2: do not edit by hand
export(luftlyr_df_data)
export(luftlyr_df_qa)
export(luftlyr_friendly)
export(luftlyr_get_data)
export(luftlyr_get_meta)
export(luftlyr_get_qa)
......@@ -23,10 +23,29 @@ luftlyr_df_data <- function(x,res){
return(tmp)
}
#' luftlyr_df_qa
#' luftlyr_df_qa
#' @param x request object
#' @param res resulted data.frame
#' @keywords luftlyr
#' @export
#' @examples
#' \dontrun{
#' luftlyr_df_qa()
#' }
luftlyr_df_qa <- function(x,res){
luftlyr_df_data(x=x,res=res)
}
df_data <- function(x,ugly_df){
output <- data.frame(date = x$timeObj$seqPeriod())
target <- setdiff(names(ugly_df), c("YEAR_UTC","MONTH_UTC","DAY_UTC","HOUR_UTC","ST_ID","ST_NAME","CO_NAME"))
for (i_e in 1:length(x$elementObj$element_id)) {
if (length(x$stationObj$station_id)>0) {
......@@ -39,7 +58,7 @@ df_data <- function(x,ugly_df){
}
stations_id <- x$stationObj$station_id[i_s]
tmp <- timelyr::checkDate(df=ugly_df[indice,],timeObj = x$timeObj, missingValues=NA)[,"TE_VALUE"]
tmp <- timelyr::checkDate(df=ugly_df[indice,],timeObj = x$timeObj, missingValues=NA)[,target]
df <- tmp
if (length(x$stationObj$station_id)>1) {
......@@ -50,7 +69,7 @@ df_data <- function(x,ugly_df){
indice <- which( (ugly_df["ST_ID"] == x$stationObj$station_id[i_s]) & (ugly_df["CO_NAME"] == x$elementObj$element_id[i_e]))
}
stations_id <- c(stations_id,x$stationObj$station_id[i_s])
tmp <- timelyr::checkDate(df=ugly_df[indice,],timeObj = x$timeObj, missingValues=NA)[,"TE_VALUE"]
tmp <- timelyr::checkDate(df=ugly_df[indice,],timeObj = x$timeObj, missingValues=NA)[,target]
df <- cbind(df,tmp)
}
......
......@@ -28,6 +28,34 @@ luftlyr_get_data <- function(x,username,password) {
} else stop("number of stations is null")
}
#' luftlyr_get_qa
#' luftlyr_get_qa
#' @param x request object
#' @param username username
#' @param password password
#' @keywords luftlyr
#' @export
#' @examples
#' \dontrun{
#' luftlyr_get_qa()
#' }
luftlyr_get_qa <- function(x,username,password) {
db <- luftkvalr::luftkvalr()
db$start(username,password)
tmp_st <- db$GetAQStations(stationIDs=x$stationObj$station_id,west=x$stationObj$west,south=x$stationObj$south,east=x$stationObj$east,north=x$stationObj$north)
tmp_ts <- db$GetAQTimeseries(stationIDs=unique(tmp_st$ST_ID),componentName=x$elementObj$element_id)
if (nrow(tmp_st)>0) {
res <- db$GetAQqaData(stationIDs=unique(tmp_st$ST_ID),
timeSeriesIDs=tmp_ts$TS_ID,
fromDateTime=as.character(x$timeObj$fromDateTime()+3600), #UTC+1, no summer time
toDateTime=as.character(x$timeObj$toDateTime()+3600)) #UTC+1, no summer time
db$stop()
return(res)
} else stop("number of stations is null")
}
#' luftlyr_get_meta
#' luftlyr_getmeta
......
......@@ -22,3 +22,4 @@ luftlyr_df_data()
}
}
\keyword{luftlyr}
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/luftlyr_df.R
\name{luftlyr_df_qa}
\alias{luftlyr_df_qa}
\title{luftlyr_df_qa
luftlyr_df_qa}
\usage{
luftlyr_df_qa(x, res)
}
\arguments{
\item{x}{request object}
\item{res}{resulted data.frame}
}
\description{
luftlyr_df_qa
luftlyr_df_qa
}
\examples{
\dontrun{
luftlyr_df_qa()
}
}
\keyword{luftlyr}
......@@ -22,3 +22,4 @@ luftlyr_friendly()
}
}
\keyword{luftlyr}
......@@ -24,3 +24,4 @@ luftlyr_get_data()
}
}
\keyword{luftlyr}
......@@ -24,3 +24,4 @@ luftlyr_get_meta()
}
}
\keyword{luftlyr}
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/luftlyr_get.R
\name{luftlyr_get_qa}
\alias{luftlyr_get_qa}
\title{luftlyr_get_qa
luftlyr_get_qa}
\usage{
luftlyr_get_qa(x, username, password)
}
\arguments{
\item{x}{request object}
\item{username}{username}
\item{password}{password}
}
\description{
luftlyr_get_qa
luftlyr_get_qa
}
\examples{
\dontrun{
luftlyr_get_qa()
}
}
\keyword{luftlyr}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment