Commit a4d4f11a authored by jml's avatar jml
Browse files

taking into account several instrument on a same station

parent 417c48d9
......@@ -23,10 +23,13 @@ get_short_data <- function(frostObj,stations,referencetime,elements,...) {
df <- build_data_df(tmp=tmp,indice=i)
res <- rbind(res,df)
}
res[,"ID"] <-gsub(":.*","",res[,"ID"])
} else {
res <- short_data_init()
}
#res[,"ID"] <-gsub(":.*","",res[,"ID"])
return(res)
}
......
......@@ -13,7 +13,10 @@ get_short_meta_element <- function(frostObj,elements) {
for ( i in 1:length(elements)) {
tmp <- frostObj$timeSeries(elements=elements[i],format='jsonld')
if (!is.null(tmp)) {
stnr <-gsub(":.*","",tmp[,"sourceId"])
#stnr <-gsub(":.*","",tmp[,"sourceId"])
stnr <-tmp[,"sourceId"]
df <- data.frame(ID = stnr,CO_NAME = tmp[,"elementId"])
res <- rbind(res,df)
} else {
......@@ -89,6 +92,7 @@ get_short_meta_station_with_element <- function(frostObj,stations=NULL,west=NULL
ele_meta <- get_short_meta_element(frostObj=frostObj,elements=elements)
stn_meta <- get_short_meta_station(frostObj=frostObj,stations=stations,west=west,south=south,east=east,north=north)
if (!is.null(ele_meta) && !is.null(stn_meta)) {
ele_meta[,"ID"] <- gsub(":.*","",ele_meta[,"ID"])
res <- dplyr::inner_join(stn_meta,ele_meta)
} else {
res <- data.frame(ID = character(0), CO_NAME=character(0), ALT= numeric(0), LAT= numeric(0), LON= numeric(0), NAME = character(0))
......
......@@ -28,9 +28,11 @@ tmp <- frostr::get_short_data(frostObj=frostr,stations="SN18700",referencetime='
res <- frostr::get_short_meta_station_with_element(frostObj=frostr,west=10,south=60,east=11,north=65,elements='sum(precipitation_amount PT1H)')
tmp <- frostr::get_short_data(frostObj=frostr,stations=res$ID,referencetime='2017-01-01T00:00:00Z',elements='sum(precipitation_amount PT1H)')
ele_meta <- get_short_meta_element(frostObj=frostr,elements='sum(precipitation_amount PT1H)')
stn_meta <- get_short_meta_station(frostObj=frostr,stations=NULL,west=10,south=60,east=11,north=65)
referencetime <- '2017-01-01T00:00:00Z/2017-01-02T12:00:00'
elements <- c("sum(precipitation_amount PT1H)",
"wind_from_direction",
"wind_speed",
......@@ -39,8 +41,7 @@ elements <- c("sum(precipitation_amount PT1H)",
"air_temperature",
"relative_humidity")
res <- frostr::get_short_meta_station_with_element(frostObj=frostr,stations=NULL,west=10.57,south=59.75,east=60.07,north=10.89,elements=elements)
tmp <- frostr::get_short_data(frostObj=frostr,stations=res$ID,referencetime='2017-01-01T00:00:00Z/2017-01-02T12:00:00',elements=elements,timeresolutions="PT1H")
tmp <- frostr::get_short_data(frostObj=frostr,stations=unique(res$ID),referencetime='2016-11-01T00:00:00Z/2016-11-02T12:00:00',elements=elements,timeresolutions="PT1H")
```
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