Skip to content

Commit

Permalink
Merge branch 'devel'
Browse files Browse the repository at this point in the history
  • Loading branch information
jbedia committed Oct 4, 2018
2 parents 60d90dd + 25e5c31 commit a2cbeb7
Show file tree
Hide file tree
Showing 9 changed files with 151 additions and 50 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ fireDanger.Rproj
*~
vignettes/cache
vignettes/figure
ignore
15 changes: 9 additions & 6 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ Depends:
R(>= 3.1.0)
Imports:
abind,
transformeR(>= 0.0.7),
transformeR(>= 1.4.7),
magrittr,
parallel
Suggests:
visualizeR,
Expand All @@ -13,19 +14,21 @@ Suggests:
easyVerification,
knitr,
rmarkdown,
drought4R,
RColorBrewer
VignetteBuilder: knitr
Type: Package
Title: Fire weather index calculation from station and model data
Version: 1.0.3
Date: 2017-07-10
Version: 1.1.0
Date: 2018-10-04
Authors@R: as.person(c(
"Santander Meteorology Group <http://meteo.unican.es> [aut]",
"Joaquin Bedia <bediaj@unican.es> [ctb, cre]",
"Maialen Iturbide <miturbide@ifca.unican.es> [ctb]"))
BugReports: https://github.com/SantanderMetGroup/fireDanger/issues
URL: https://github.com/SantanderMetGroup/fireDanger
Description: Tools for computing the Fire Weather Index from weather station and numerical climate model data.
URL: http://www.meteo.unican.es/climate4r
Description: A climate4R package for computing several popular fire danger indices.
License: GPL (>= 3)
Encoding: UTF-8
LazyData: true
RoxygenNote: 6.0.1
RoxygenNote: 6.1.0
8 changes: 8 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,16 +1,24 @@
# Generated by roxygen2: do not edit by hand

export(fffdiGrid)
export(fwi1D)
export(fwiGrid)
importFrom(abind,abind)
importFrom(abind,asub)
importFrom(magrittr,"%<>%")
importFrom(magrittr,"%>%")
importFrom(magrittr,extract2)
importFrom(parallel,parLapply)
importFrom(parallel,splitIndices)
importFrom(stats,complete.cases)
importFrom(transformeR,array3Dto2Dmat)
importFrom(transformeR,checkDim)
importFrom(transformeR,checkTemporalConsistency)
importFrom(transformeR,getCoordinates)
importFrom(transformeR,getDim)
importFrom(transformeR,getShape)
importFrom(transformeR,getYearsAsINDEX)
importFrom(transformeR,gridArithmetics)
importFrom(transformeR,mat2Dto3Darray)
importFrom(transformeR,parallelCheck)
importFrom(transformeR,redim)
Expand Down
11 changes: 7 additions & 4 deletions NEWS
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
New in fireDanger
=================
fireDanger changelog
====================

* Added CITATION file
* Documentation updates
For earlier version descriptions, got to the [Releases Tab](https://github.com/SantanderMetGroup/fireDanger/releases)

## v1.1.0 (4 Oct 2018)
* Included an implementation of the Finish Forest Fire Danger Index System
* Other minor changes and documentation updates
80 changes: 80 additions & 0 deletions R/fffdiGrid.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# fffdiGrid.R Finnish Forest Fire Danger Index
#
# Copyright (C) 2018 Santander Meteorology Group (http://www.meteo.unican.es)
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

#' @title Finnish Forest Fire Danger Index (FFFDI)
#' @description Implementation of the FFFDI for climate4R grids
#' @param pr A climate4R object containing daily precipitation (in mm)
#' @param pet A climate4R object containing daily (potential) evapotranspiration data (in mm).
#' @param Wvol.init Initialization value for volumetric moisture, in the range 0.1-0.5.
#' Default to 0.5 (very wet soil), but see Details.
#' @param z reference surface layer thickness (mm). Default to 60.
#' @references Vajda, A., Venalainen, A., Suomi, I., Junila, P. and Makela, H., 2014. Assessment of forest
#' fire danger in a boreal forest environment: description and evaluation of the operational
#' system applied in Finland. Meteorol. Appl., 21: 879-887, DOI: 10.1002/met.1425
#' @importFrom transformeR gridArithmetics getDim getShape
#' @importFrom abind asub abind
#' @importFrom transformeR checkDim checkTemporalConsistency redim getShape subsetGrid array3Dto2Dmat getCoordinates
#' @importFrom magrittr %>% %<>% extract2
#' @return A climate4R object containing FFFDI data
#' @details
#' \strong{Volumetric moisture}
#' The default is 0.5, indicating that the soil is very wet and near field capacity. This is so, assuming that the
#' index is started in early spring. This value is applied to all locations as a spatially constant initialization value.
#' However, Vajda \emph{et al.} (2014, Table 1) provide reference values for different soil moisture conditions. This value ranges
#' from 0.1 (very dry) to 0.5 (very wet).
#' @author J. Bedia (based on the original FORTRAN code from Vajda et al. 2014).
#' @seealso \code{petGrid} function, from package \pkg{drought4R}
#' is recommended for PET estimation <https://github.com/SantanderMetGroup/drought4R>.
#' @export


fffdiGrid <- function(pr, pet, Wvol.init = 0.5, z = 60) {
pr %<>% redim()
pet %<>% redim()
suppressMessages(checkDim(pr, pet))
checkTemporalConsistency(pr, pet)
if ("var" %in% getDim(pet)) stop("Input multigrids are not allowed")
ntimes <- getShape(pr, "time")
nmem <- getShape(pr, "member")
npoints <- getCoordinates(pet) %>% expand.grid() %>% nrow()
aux.grid <- pet
fffdi.list <- lapply(1:nmem, function(x) {
Wvol <- rep(Wvol.init, npoints)
Wt <- Wvol * z
pr.aux <- subsetGrid(pr, members = x) %>% redim(member = FALSE) %>% extract2("Data") %>% array3Dto2Dmat()
pet.aux <- subsetGrid(pet, members = x) %>% redim(member = FALSE) %>% extract2("Data") %>% array3Dto2Dmat()
ref <- pet.aux
for (i in 1:ntimes) {
dw <- (-pet.aux[i,] * 0.757) / (1 + exp(2.74 - 16.67 * (Wvol - 0.1))) + 5.612 * (1 - exp(-pr.aux[i,] / 5.612))
Wt <- Wt + dw
Wvol <- Wt/z
Wvol[which(Wvol > 0.5)] <- 0.5
Wvol[which(Wvol < 0.1)] <- 0.1
ref[i,] <- 8.76 - 30.879 * Wvol + 30.712 * Wvol^2
}
grd <- mat2Dto3Darray(ref, x = getCoordinates(pet)[["x"]], y = getCoordinates(pet)[["y"]])
aux.grid$Data <- grd
redim(aux.grid) %>% return()
})
out <- suppressMessages(do.call("bindGrid", c(fffdi.list, dimension = "member")))
out$Variable$varName <- "fffdi"
descr <- "finnish_forest_fire_danger_index"
attr(out$Variable, "description") <- descr
attr(out$Variable, "longname") <- descr
attr(out$Variable, "daily_agg_cellfun") <- "index"
return(out)
}
37 changes: 0 additions & 37 deletions R/hsPET.R

This file was deleted.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ What is fireDanger?
`fireDanger` is an R package for the Implementation of the Canadian Fire Weather Index System using as input seasonal forecast data and other climatic datasets.

***
`fireDanger` is part of the [**loadeR**](https://github.com/SantanderMetGroup/loadeR) **bundle**.
`fireDanger` is part of the **climate4R bundle**.

***

Expand Down
43 changes: 43 additions & 0 deletions man/fffdiGrid.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions man/fwi1D.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit a2cbeb7

Please sign in to comment.