Skip to content

Commit 8aa5271

Browse files
committed
Fix read_profile() for obsnodes!
1 parent 05f6eb8 commit 8aa5271

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

R/read_profile.R

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,16 +62,19 @@ read_profile <- function(path) {
6262

6363
if (length(which(ncols == 2)) > 0) {
6464
idx_obsnodes <- which(ncols == 2)
65-
if(any(idx_obsnodes < length(ncols))) {
65+
obsnodes$n <- as.integer(dat[idx_obsnodes[1]])
6666

67-
n_obsnodes <- as.integer(dat[idx_obsnodes[-length(idx_obsnodes)]])
68-
obs_node_ids <- stringr::str_split(dat[idx_obsnodes[length(idx_obsnodes)]],
67+
if(stringr::str_length(dat[idx_obsnodes[1]+1]) > 0) {
68+
69+
obsnodes$ids <- stringr::str_split(dat[idx_obsnodes[1]+1],
6970
pattern = ",",
7071
simplify = TRUE) %>%
7172
as.integer()
7273

73-
obsnodes <- list(n = n_obsnodes,
74-
ids = obs_node_ids)
74+
} else {
75+
stop("Check stucture of input file %s. Missing ids for %d specified observation points!",
76+
path,
77+
obsnodes$n)
7578
}
7679
}
7780

0 commit comments

Comments
 (0)