Maintenance is scheduled between 16:00 and 23:59 CEST (14:00 and 21:59 UTC) on Thursday 2021-09-30. The system may be unavailable at any time during this timeframe. Please plan accordingly.

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

push on gitlab

parents
Package: d.synthaq.oslyr
Type: Package
Version: 0.0.1
Authors@R: c(person("Jean-Marie", "Lepioufle", , "jml@nilu.no", role=c("aut","cre")))
Title: d.synthaq.oslyr
Description: Make hourly synthetic NO2 observations of 10 monitoring stations in Oslo from 2015 to 2018 easy to manipulate.
The package provides:
1. libraries to access synthetic datasets.
2. get friendly data.frame to work with.
Depends:
R (>= 3.4.4)
Imports:
data.synthaq.oslo10.seed123,
friendlyts,
timemanip
Remotes: git::https://git.nilu.no/rextdata/data.synthaq.oslo10.seed123.git,
git::https://git.nilu.no/rfriendlyts/friendlyts.git,
git::https://git.nilu.no/rspacetimemanip/timemanip.git
License: GPL-3
Encoding: UTF-8
LazyData: false
RoxygenNote: 6.1.1
# Generated by roxygen2: do not edit by hand
export(d.synthaq.oslyr_df_data)
export(d.synthaq.oslyr_df_qa)
export(d.synthaq.oslyr_friendly)
export(d.synthaq.oslyr_get_data)
export(d.synthaq.oslyr_get_meta)
export(d.synthaq.oslyr_get_qa)
#' d.synthaq.oslyr_df_data
#' d.synthaq.oslyr_df_data
#' @param x request object
#' @param res resulted data.frame
#' @keywords d.synthaq.oslyr
#' @export
#' @examples
#' \dontrun{
#' d.synthaq.oslyr_df_data()
#' }
d.synthaq.oslyr_df_data <- function(x,res){
if (nrow(res)>0){
tmp <- friendlyts::ts_spread(df=res, col_date=c("date"),
col_key=c("CO_NAME","ID"),col_target="value",
precision=x$timeObj$precision(),tzone=x$timeObj$tzone(),
date_type="%Y-%m-%d %H:%M:%S")
df <- friendlyts::check_date(tbl_fts=tmp, fromDate=x$timeObj$fromDateTime(),toDate=x$timeObj$toDateTime(),timeResolution=x$timeObj$timeResolution(), v=x$timeObj$v(), precision=x$timeObj$precision(), tzone=x$timeObj$tzone(),missingValues=NA,date_type="posixlt")
} else {
df <- friendlyts::friendlyts(varnames="empty",date_type=c("posixlt"),fromDate=x$timeObj$fromDateTime(),toDate=x$timeObj$toDateTime(),timeResolution=x$timeObj$timeResolution(),v=x$timeObj$v(),precision=x$timeObj$precision(),tzone=x$timeObj$tzone())
}
if (x$dateStructObj$COL_DATE) {
stop("to be done")
}
return(df)
}
#' d.synthaq.oslyr_df_qa
#' d.synthaq.oslyr_df_qa
#' @param x request object
#' @param res resulted data.frame
#' @keywords d.synthaq.oslyr
#' @export
#' @examples
#' \dontrun{
#' d.synthaq.oslyr_df_qa()
#' }
d.synthaq.oslyr_df_qa <- function(x,res){
if (nrow(res)>0){
tmp <- friendlyts::ts_spread(df=res, col_date=c("date"),
col_key=c("CO_NAME","ID"),col_target="qualityCode",
precision=x$timeObj$precision(),tzone=x$timeObj$tzone(),
date_type="%Y-%m-%d %H:%M:%S")
df <- friendlyts::check_date(tbl_fts=tmp, fromDate=x$timeObj$fromDateTime(),toDate=x$timeObj$toDateTime(),timeResolution=x$timeObj$timeResolution(), v=x$timeObj$v(), precision=x$timeObj$precision(), tzone=x$timeObj$tzone(),missingValues=NA,date_type="posixlt")
} else {
df <- friendlyts::friendlyts(varnames="empty",date_type=c("posixlt"),fromDate=x$timeObj$fromDateTime(),toDate=x$timeObj$toDateTime(),timeResolution=x$timeObj$timeResolution(),v=x$timeObj$v(),precision=x$timeObj$precision(),tzone=x$timeObj$tzone())
}
icol <- friendlyts::get_date_col(precision=x$timeObj$precision())
names(df) <- c(names(df)[icol],paste0("qa_",names(tmp)[-c(icol)]))
if (x$dateStructObj$COL_DATE) {
stop("to be done")
}
return(df)
}
#' frostly_friendly
#' frostly_friendly
#' @param fn character fun
#' @param type character type
#' @keywords d.synthaq.oslyr
#' @export
#' @examples
#' \dontrun{
#' frostly_friendly()
#' }
d.synthaq.oslyr_friendly <- function(fn,type) {
return(get(paste0("d.synthaq.oslyr_",fn,"_",type)))
}
#' d.synthaq.oslyr_get_data
#' d.synthaq.oslyr_get_data
#' @param x request object
#' @param username username
#' @param password password
#' @keywords d.synthaq.oslyr
#' @export
#' @examples
#' \dontrun{
#' d.synthaq.oslyr_get_data()
#' }
d.synthaq.oslyr_get_data <- function(x,username=NULL,password=NULL) {
username <- username
password <- password
if (!is.null(x$stationObj$locationName)){
meta <- d.synthaq.oslyr_get_meta(x=x,username=username,password=password)
station_id <- meta$ID
} else if (!is.null(x$stationObj$station_id)) {
station_id <- x$stationObj$station_id
}
from <- timemanip::posixlt2char(x$timeObj$fromDateTime(),ISO8601=NULL,date_type="%Y/%m/%d %H:%M:%S")
to <- timemanip::posixlt2char(x$timeObj$toDateTime(),ISO8601=NULL,date_type="%Y/%m/%d %H:%M:%S")
res <- data.luftkval.oslo10::get_short_data(stations=unique(station_id),referencetimeFrom=from,referencetimeTo=to,elements=x$elementObj$element_id,timeResolution=x$timeObj$timeResolution())
return(res)
}
#' d.synthaq.oslyr_get_meta
#' d.synthaq.oslyr_get_meta
#' @param x request object
#' @param username username
#' @param password password
#' @keywords d.synthaq.oslyr
#' @export
#' @examples
#' \dontrun{
#' d.synthaq.oslyr_get_meta()
#' }
d.synthaq.oslyr_get_meta <- function(x,username=NULL,password=NULL) {
username <- username
password <- password
res <- data.luftkval.oslo10::get_short_meta_station(stations=x$stationObj$station_id,west=x$stationObj$west,south=x$stationObj$south,east=x$stationObj$east,north=x$stationObj$north)
return(res)
}
#' d.synthaq.oslyr_get_qa
#' d.synthaq.oslyr_get_qa
#' @param x request object
#' @param username username
#' @param password password
#' @keywords d.synthaq.oslyr
#' @export
#' @examples
#' \dontrun{
#' d.synthaq.oslyr_get_qa()
#' }
d.synthaq.oslyr_get_qa <- function(x,username=NULL,password=NULL) {
res <- d.synthaq.oslyr_get_data(x=x,username=username,password=password)
return(res)
}
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/d.luft.oslyr_df.R
\name{d.synthaq.oslyr_df_data}
\alias{d.synthaq.oslyr_df_data}
\title{d.synthaq.oslyr_df_data
d.synthaq.oslyr_df_data}
\usage{
d.synthaq.oslyr_df_data(x, res)
}
\arguments{
\item{x}{request object}
\item{res}{resulted data.frame}
}
\description{
d.synthaq.oslyr_df_data
d.synthaq.oslyr_df_data
}
\examples{
\dontrun{
d.synthaq.oslyr_df_data()
}
}
\keyword{d.synthaq.oslyr}
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/d.luft.oslyr_df.R
\name{d.synthaq.oslyr_df_qa}
\alias{d.synthaq.oslyr_df_qa}
\title{d.synthaq.oslyr_df_qa
d.synthaq.oslyr_df_qa}
\usage{
d.synthaq.oslyr_df_qa(x, res)
}
\arguments{
\item{x}{request object}
\item{res}{resulted data.frame}
}
\description{
d.synthaq.oslyr_df_qa
d.synthaq.oslyr_df_qa
}
\examples{
\dontrun{
d.synthaq.oslyr_df_qa()
}
}
\keyword{d.synthaq.oslyr}
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/d.luft.oslyr_friendly.R
\name{d.synthaq.oslyr_friendly}
\alias{d.synthaq.oslyr_friendly}
\title{frostly_friendly
frostly_friendly}
\usage{
d.synthaq.oslyr_friendly(fn, type)
}
\arguments{
\item{fn}{character fun}
\item{type}{character type}
}
\description{
frostly_friendly
frostly_friendly
}
\examples{
\dontrun{
frostly_friendly()
}
}
\keyword{d.synthaq.oslyr}
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/d.luft.oslyr_get.R
\name{d.synthaq.oslyr_get_data}
\alias{d.synthaq.oslyr_get_data}
\title{d.synthaq.oslyr_get_data
d.synthaq.oslyr_get_data}
\usage{
d.synthaq.oslyr_get_data(x, username = NULL, password = NULL)
}
\arguments{
\item{x}{request object}
\item{username}{username}
\item{password}{password}
}
\description{
d.synthaq.oslyr_get_data
d.synthaq.oslyr_get_data
}
\examples{
\dontrun{
d.synthaq.oslyr_get_data()
}
}
\keyword{d.synthaq.oslyr}
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/d.luft.oslyr_get.R
\name{d.synthaq.oslyr_get_meta}
\alias{d.synthaq.oslyr_get_meta}
\title{d.synthaq.oslyr_get_meta
d.synthaq.oslyr_get_meta}
\usage{
d.synthaq.oslyr_get_meta(x, username = NULL, password = NULL)
}
\arguments{
\item{x}{request object}
\item{username}{username}
\item{password}{password}
}
\description{
d.synthaq.oslyr_get_meta
d.synthaq.oslyr_get_meta
}
\examples{
\dontrun{
d.synthaq.oslyr_get_meta()
}
}
\keyword{d.synthaq.oslyr}
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/d.luft.oslyr_get.R
\name{d.synthaq.oslyr_get_qa}
\alias{d.synthaq.oslyr_get_qa}
\title{d.synthaq.oslyr_get_qa
d.synthaq.oslyr_get_qa}
\usage{
d.synthaq.oslyr_get_qa(x, username = NULL, password = NULL)
}
\arguments{
\item{x}{request object}
\item{username}{username}
\item{password}{password}
}
\description{
d.synthaq.oslyr_get_qa
d.synthaq.oslyr_get_qa
}
\examples{
\dontrun{
d.synthaq.oslyr_get_qa()
}
}
\keyword{d.synthaq.oslyr}
Markdown is supported
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