Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Rfriendlyr
luftlyr
Commits
ded72825
Commit
ded72825
authored
Jul 12, 2018
by
jml
Browse files
upgrade according to luftkvalr
parent
70006417
Changes
2
Hide whitespace changes
Inline
Side-by-side
DESCRIPTION
View file @
ded72825
Package: luftlyr
Type: Package
Version: 0.0.
4
Version: 0.0.
5
Authors@R: c(person("Jean-Marie", "Lepioufle", , "jml@nilu.no", role=c("aut","cre")),
person("NILU",role="cph"))
Title: luftlyr
...
...
R/luftlyr_get.R
View file @
ded72825
...
...
@@ -11,21 +11,12 @@
#' luftlyr_get_data()
#' }
luftlyr_get_data
<-
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
)
{
fromDateTime
<-
as.character
(
x
$
timeObj
$
fromDateTime
()
+3600
)
#UTC+1, no summer time
toDateTime
<-
as.character
(
x
$
timeObj
$
toDateTime
()
+3600
)
#UTC+1, no summer time
res
<-
db
$
GetAQData
(
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
()
#Negative values
res
[
which
(
res
$
TE_VALUE
<
0
),
"TE_VALUE"
]
<-
NA
return
(
res
)
}
else
stop
(
"number of stations is null"
)
res
<-
luftkvalr
::
luft_data
(
stationIDs
=
x
$
stationObj
$
station_id
,
west
=
x
$
stationObj
$
west
,
south
=
x
$
stationObj
$
south
,
east
=
x
$
stationObj
$
east
,
north
=
x
$
stationObj
$
north
,
componentName
=
x
$
elementObj
$
element_id
,
fromDateTime
,
toDateTime
,
username
,
password
)
return
(
res
)
}
#' luftlyr_get_qa
...
...
@@ -41,19 +32,13 @@ luftlyr_get_data <- function(x,username,password) {
#' 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"
)
fromDateTime
<-
as.character
(
x
$
timeObj
$
fromDateTime
()
+3600
)
#UTC+1, no summer time
toDateTime
<-
as.character
(
x
$
timeObj
$
toDateTime
()
+3600
)
#UTC+1, no summer time
res
<-
luftkvalr
::
luft_qa
(
stationIDs
=
x
$
stationObj
$
station_id
,
west
=
x
$
stationObj
$
west
,
south
=
x
$
stationObj
$
south
,
east
=
x
$
stationObj
$
east
,
north
=
x
$
stationObj
$
north
,
componentName
=
x
$
elementObj
$
element_id
,
fromDateTime
,
toDateTime
,
username
,
password
)
return
(
res
)
}
#' luftlyr_get_meta
...
...
@@ -69,13 +54,7 @@ luftlyr_get_qa <- function(x,username,password) {
#' luftlyr_get_meta()
#' }
luftlyr_get_meta
<-
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
)
if
(
nrow
(
tmp_st
)
>
0
)
{
tmp_ts
<-
db
$
GetAQTimeseries
(
stationIDs
=
unique
(
tmp_st
$
ST_ID
),
componentName
=
x
$
elementObj
$
element_id
)
db
$
stop
()
colnames
(
tmp_ts
)
<-
c
(
"ID"
,
"NAME"
,
"ALT"
,
"LAT"
,
"LON"
,
"TS_ID"
,
"CO_NAME"
,
"TS_Z1"
,
"TS_Z2"
)
return
(
tmp_ts
[,
c
(
1
:
5
,
7
)])
}
else
stop
(
"number of stations is null"
)
res
<-
luftkvalr
::
luft_meta
(
stationIDs
=
x
$
stationObj
$
station_id
,
west
=
x
$
stationObj
$
west
,
south
=
x
$
stationObj
$
south
,
east
=
x
$
stationObj
$
east
,
north
=
x
$
stationObj
$
north
,
componentName
=
x
$
elementObj
$
element_id
,
username
,
password
)
return
(
res
)
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment