From df5794c1a37f55809d7ce8adb7689d1aa165257c Mon Sep 17 00:00:00 2001 From: MartinImrisekSHMU Date: Mon, 4 Sep 2023 09:08:28 +0000 Subject: [PATCH 1/2] minor changes in title of plot (added step range) --- R/geofield.R | 2 +- R/graphics.R | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/R/geofield.R b/R/geofield.R index c22cb30..809fc37 100644 --- a/R/geofield.R +++ b/R/geofield.R @@ -112,7 +112,7 @@ as.geofield <- function (x=NA, domain, } } if (!is.null(collapse[["prm"]])) info$name <- paste0(collapse$prm, info$name) - if (!is.null(collapse[["name"]])) info$name <- paste0(collapse$name, info$name) + if (!is.null(collapse[["name"]])) info$name <- paste0(collapse$name, info$name) if (!is.null(collapse[["hPa"]])) info$name <- paste0(info$name, " ", collapse[["hPa"]], "hPa") if (!is.null(collapse[["mbr"]])) info$name <- paste0(info$name, " mbr", collapse[["mbr"]]) if (!is.null(collapse[["level"]])) info$name <- paste0(info$name, " level ", collapse[["level"]]) diff --git a/R/graphics.R b/R/graphics.R index 37e3333..0da3c3e 100644 --- a/R/graphics.R +++ b/R/graphics.R @@ -177,11 +177,11 @@ geofield_title <- function(x) { mytitle <- trim(attr(x, "info")$name) dt <- attr(x, "info")$time if (!is.null(dt$basedate)) { - mytitle <- paste(mytitle, + mytitle <- paste(sprintf("%s [%s]", mytitle, attr(x, "info")$unit), format(attr(x, "info")$time$basedate, "%Y/%m/%d %H:%M"), sep="\n") - if (!is.null(attr(x, "info")$time$leadtime)) { - mytitle <- paste0(mytitle, " +", attr(x, "info")$time$leadtime) + if (!is.null(attr(x, "info")$steprange)) { + mytitle <- paste0(mytitle, " + ", attr(x, "info")$steprange, " ", attr(x, "info")$time$stepUnit) } } else if (!is.null(dt$validdate)) { mytitle <- paste(mytitle, From 23f997868dbd4c81df0c48a619eec4923df41f42 Mon Sep 17 00:00:00 2001 From: MartinImrisekSHMU Date: Mon, 18 Sep 2023 14:19:57 +0000 Subject: [PATCH 2/2] backward compatibility with FA files fixed --- R/graphics.R | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/R/graphics.R b/R/graphics.R index 0da3c3e..0a2a2d6 100644 --- a/R/graphics.R +++ b/R/graphics.R @@ -177,11 +177,15 @@ geofield_title <- function(x) { mytitle <- trim(attr(x, "info")$name) dt <- attr(x, "info")$time if (!is.null(dt$basedate)) { - mytitle <- paste(sprintf("%s [%s]", mytitle, attr(x, "info")$unit), + mytitle <- paste(sprintf("%s%s", + mytitle, + if(!is.null(attr(x, "info")$unit))sprintf(" [%s]",attr(x, "info")$unit) else ""), format(attr(x, "info")$time$basedate, "%Y/%m/%d %H:%M"), sep="\n") if (!is.null(attr(x, "info")$steprange)) { mytitle <- paste0(mytitle, " + ", attr(x, "info")$steprange, " ", attr(x, "info")$time$stepUnit) + } else if (!is.null(attr(x, "info")$time$leadtime)) { + mytitle <- paste0(mytitle, " +", attr(x, "info")$time$leadtime) } } else if (!is.null(dt$validdate)) { mytitle <- paste(mytitle,