Skip to content

Commit 721ac93

Browse files
authored
Merge pull request #12 from ecmwf/develop
Develop
2 parents def5fb5 + cb6b4e7 commit 721ac93

21 files changed

+193
-342
lines changed

.travis.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@ addons:
1313
- libhdf5-dev
1414
- libproj-dev
1515
- libgdal-dev
16-
- cdo
17-
- ncl-ncarg
16+
- gdal-bin
1817

1918
r_github_packages:
2019
- jimhester/lintr

DESCRIPTION

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ Depends:
2020
Imports:
2121
ncdf4,
2222
raster,
23+
gdalUtils,
2324
ggplot2,
2425
rworldmap,
2526
graphics,
@@ -42,6 +43,6 @@ Suggests:
4243
lintr
4344
VignetteBuilder: knitr
4445
Encoding: UTF-8
45-
SystemRequirements: GDAL, PROJ.4, cdo, ncl, netcdf4, hdf5
46+
SystemRequirements: GDAL binaries, PROJ.4, netcdf4, hdf5, openssl
4647
License: Apache License 2.0
4748
RoxygenNote: 6.1.1

NAMESPACE

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,16 @@ export(subset_datacube)
2626
export(validate_fire_danger_levels)
2727
export(vdi)
2828
import(ggplot2)
29-
import(hdf5r)
3029
import(ncdf4)
3130
importFrom(R.utils,gunzip)
3231
importFrom(RCurl,getBinaryURL)
3332
importFrom(RCurl,getURL)
33+
importFrom(gdalUtils,gdal_translate)
34+
importFrom(gdalUtils,get_subdatasets)
3435
importFrom(graphics,legend)
3536
importFrom(graphics,par)
3637
importFrom(graphics,plot)
38+
importFrom(hdf5r,h5file)
3739
importFrom(lubridate,yday)
3840
importFrom(plotrix,rescale)
3941
importFrom(raster,cellFromPolygon)

NEWS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
* Removed dependency from visualTest as it is not in mainstream repositories
1111
* Removed LICENSE file, linking directly to Apache License 2.0 in DESCRIPTION
1212
* Removed dependency from bioconductor package rhdf5, now using hdf5r from cran
13+
* Removed external dependency from ncl and cdo
1314
* Removed obsolete/deprecated dependencies
1415

1516
# caliver 1.4

NOTICE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ Copyright 2016 European Centre for Medium-Range Weather Forecasts (ECMWF)
44
This product includes software developed at
55
The European Centre for Medium-Range Weather Forecasts (ECMWF, http://www.ecmwf.int/).
66

7-
Portions of this software were developed at the CIMA Research Foundation (http://www.cimafoundation.org/).
7+
A part of this software was developed at the CIMA Research Foundation (http://www.cimafoundation.org/).

R/caliver-package.R

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@
88
#' @docType package
99
#'
1010
#' @import ncdf4
11-
#' @import hdf5r
1211
#' @import ggplot2
12+
#' @importFrom hdf5r h5file
13+
#' @importFrom gdalUtils get_subdatasets gdal_translate
1314
#' @importFrom raster raster stack mask crop rotate extent extract t plot crs
1415
#' @importFrom raster cellFromPolygon cellStats nlayers getData trim overlay
1516
#' @importFrom rworldmap getMap

R/forecast_summary.R

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ forecast_summary <- function(input_dir,
4747
# For each starting date and forecast date, calculate the percentage of
4848
# pixels exceeding the high danger level
4949
r <- raster::stack()
50-
for (i in 1:length(my_dates)) {
50+
for (i in seq_along(my_dates)) {
5151

5252
# transform dates to strings to build file name
5353
start_d <- gsub("-", "", as.character(my_dates[i]))
@@ -139,12 +139,12 @@ forecast_summary <- function(input_dir,
139139
}
140140

141141
frp_ts <- as.numeric(raster::cellStats(frp_cropped, sum))
142-
df_frp <- data.frame(date = forecast_dates[1:length(frp_ts)],
142+
df_frp <- data.frame(date = forecast_dates[seq_along(frp_ts)],
143143
frp_original = frp_ts,
144144
frp = plotrix::rescale(frp_ts, c(0, length(frp_ts))))
145-
labels_obs <- round(plotrix::rescale(1:length(frp_ts),
145+
labels_obs <- round(plotrix::rescale(seq_along(frp_ts),
146146
c(1, max(frp_ts))),
147-
0)[1:length(frp_ts)]
147+
0)[seq_along(frp_ts)]
148148
}
149149

150150
# Make the boxy forecast plot using ggplot2
@@ -158,10 +158,10 @@ forecast_summary <- function(input_dir,
158158
theme_bw() +
159159
labs(x = "Observation date", y = "Forecast date") +
160160
scale_x_continuous(expand = c(0, 0),
161-
breaks = 1:length(observation_dates),
161+
breaks = seq_along(observation_dates),
162162
labels = as.character(observation_dates)) +
163163
scale_y_continuous(expand = c(0, 0),
164-
breaks = 1:length(forecast_dates),
164+
breaks = seq_along(forecast_dates),
165165
labels = as.character(forecast_dates)) +
166166
theme(axis.text.x = element_text(angle = 90),
167167
panel.grid.major = element_blank(),
@@ -189,7 +189,7 @@ forecast_summary <- function(input_dir,
189189
override.aes = mylist)) +
190190
scale_y_continuous(sec.axis = sec_axis(~.,
191191
name = myname,
192-
breaks = 1:length(labels_obs),
192+
breaks = seq_along(labels_obs),
193193
labels = labels_obs))
194194
}
195195

R/forecast_summary_clima.R

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ forecast_summary_clima <- function(input_dir,
5555
# For each starting date and forecast date, calculate the percentage of
5656
# pixels exceeding the high danger level
5757
w <- raster::stack()
58-
for (i in 1:length(my_dates)) {
58+
for (i in seq_along(my_dates)) {
5959
print(my_dates[i])
6060

6161
# transform dates to strings to build file name
@@ -140,12 +140,13 @@ forecast_summary_clima <- function(input_dir,
140140
}
141141
frp_cropped <- mask_crop_subset(r = frp, p = p, mask = TRUE, crop = FALSE)
142142
frp_ts <- as.numeric(raster::cellStats(frp_cropped, sum))
143-
df_frp <- data.frame(date = forecast_dates[1:length(frp_ts)],
143+
frp_ts_length <- length(frp_ts)
144+
df_frp <- data.frame(date = forecast_dates[1:frp_ts_length],
144145
frp_original = frp_ts,
145-
frp = plotrix::rescale(frp_ts, c(0, length(frp_ts))))
146-
labels_obs <- round(plotrix::rescale(1:length(frp_ts),
146+
frp = plotrix::rescale(frp_ts, c(0, frp_ts_length)))
147+
labels_obs <- round(plotrix::rescale(1:frp_ts_length,
147148
c(1, max(frp_ts))),
148-
0)[1:length(frp_ts)]
149+
0)[1:frp_ts_length]
149150
}
150151

151152
# Make the boxy forecast plot using ggplot2
@@ -158,10 +159,10 @@ forecast_summary_clima <- function(input_dir,
158159
"\npercentile = ", threshold)) +
159160
theme_bw() + labs(x = "Observation date", y = "Forecast date") +
160161
scale_x_continuous(expand = c(0, 0),
161-
breaks = 1:length(observation_dates),
162+
breaks = seq_along(observation_dates),
162163
labels = as.character(observation_dates)) +
163164
scale_y_continuous(expand = c(0, 0),
164-
breaks = 1:length(forecast_dates),
165+
breaks = seq_along(forecast_dates),
165166
labels = as.character(forecast_dates)) +
166167
theme(axis.text.x = element_text(angle = 90),
167168
panel.grid.major = element_blank(), legend.position = c(.08, .82)) +
@@ -183,7 +184,7 @@ forecast_summary_clima <- function(input_dir,
183184
override.aes = mylist)) +
184185
scale_y_continuous(sec.axis = sec_axis(~.,
185186
name = myname,
186-
breaks = 1:length(labels_obs),
187+
breaks = seq_along(labels_obs),
187188
labels = labels_obs))
188189
}
189190

0 commit comments

Comments
 (0)