Skip to content

Commit

Permalink
transitioned to and ; modified exported functions
Browse files Browse the repository at this point in the history
  • Loading branch information
mattmar committed Mar 31, 2023
1 parent 119640b commit 187affe
Show file tree
Hide file tree
Showing 47 changed files with 802 additions and 477 deletions.
6 changes: 3 additions & 3 deletions CRAN-SUBMISSION
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
Version: 2.1.1
Date: 2022-11-22 10:49:33.969 UTC
SHA: 67c7b4227692e8479fe385b11fbe8cb4a59ca98d
Version: 2.1.2
Date: 2023-03-30 10:19:09.372 UTC
SHA: 119640b3cb69afd00649a6f5c304c3c4ac5e882b
14 changes: 7 additions & 7 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
Package: dynamAedes
Version: 2.1.1
Date: 2022-11-21
Version: 2.1.2
Date: 2023-03-23
Title: A Unified Mechanistic Model for the Population Dynamics of Invasive Aedes Mosquitoes
Authors@R: c(person("Matteo", "Marcantonio", role = c("aut", "cre"), email = "marcantoniomatteo@gmail.com"),person("Daniele", "Da Re", role = c("aut"), email = "dare.daniele@gmail.com"))
Depends: R (>= 3.6.0), raster
Imports: drc, fields, foreach, insol, slam, doParallel, sp
Depends: R (>= 4.0.0)
Imports: doParallel, dplyr, drc, fields, foreach, geosphere, raster, slam, sp
BugReports: https://github.com/mattmar/dynamAedes
Description: Generalised model for population dynamics of invasive Aedes mosquitoes. Rationale and model structure are described here: Da Re, ..., Marcantonio (2021) <doi:10.1016/j.ecoinf.2020.101180> and Da Re, ..., Marcantonio (2022) <doi:10.1101/2021.12.21.473628>.
Description: Generalised model for population dynamics of invasive Aedes mosquitoes. Rationale and model structure are described here: Da Re et al. (2021) <doi:10.1016/j.ecoinf.2020.101180> and Da Re et al. (2022) <doi:10.1101/2021.12.21.473628>.
VignetteBuilder: knitr
Encoding: UTF-8
Language: en-GB
License: GPL(>=2)
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.2.1
Suggests: parallel, rmarkdown, knitr, eesim, geosphere, ggplot2, gstat, rgeos, spatstat, rgdal, tidyverse
RoxygenNote: 7.2.3
Suggests: terra, parallel, rmarkdown, knitr, eesim, ggplot2, gstat, spatstat, rgdal
Config/testthat/edition: 3
URL: https://mattmar.github.io/dynamAedes/
13 changes: 4 additions & 9 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,12 @@ importFrom("stats", "dgamma", "dlnorm", "lm", "predict", "rbinom", "rmultinom",
importFrom("fields", "rdist")
importFrom("slam", "as.simple_sparse_array")
importFrom("drc", "drm")
importFrom("insol", "JD", "daylength")
importFrom("geosphere", "daylength")
importFrom("raster", "stack", "raster", "rasterFromXYZ")
importFrom("sp", "gridded", "coordinates", "spTransform", "CRS", "SpatialPoints")

importFrom("dplyr", "%>%", "bind_rows", "as_tibble", "mutate")
#####################################
## Export ##
#####################################
export(dynamAedes.m, .beta.fun, .DRC.beta, .beta.init)
export(.a.a_disp.f, .a.gono_rate.f, .a.ovi_rate.f,
.a.surv_rate.f, .i.emer_rate.f, .e.surv_rate.f,
.i.surv_rate.f, .e.hatch_rate.f, .e.dia_rate.f,
.d.surv_rate.f, .i.ddmort_rate.f, psi, psi_sp,
icci, adci, adci_sp, dici,
.returndis, .euc, .meuc)
export(dynamAedes.m)
export(psi, psi_sp, icci, adci, adci_sp, dici)
6 changes: 6 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# dynamAedes 2.1.2
* Transitioning from 'rgdal' and 'sp' to 'terra'
* Transitioning from 'insol' to 'geosphere'
* Removing block-loading of 'tidyverse' (speeding up loading?)
* Helper functions not anymore exported

# dynamAedes 2.1.1
* Adding rgdal in the description

Expand Down
55 changes: 0 additions & 55 deletions R/beta_functions.R

This file was deleted.

25 changes: 1 addition & 24 deletions R/dici.R
Original file line number Diff line number Diff line change
Expand Up @@ -44,27 +44,4 @@ dici <- function(input_sim=NULL, coords=NULL, eval_date=NULL, breaks=c(0.25,0.5,
return(stack(outs))
}
}
}

# Ad-hoc functions
.returndis <- function(distl=NA, days=NA, breaks=breaks) {
out <- do.call(rbind.data.frame,
lapply(days, function(x) {
round(quantile(unlist(sapply(1:length(distl),
function(y) {mean(if(x<=length(distl[[y]])) as.integer(distl[[y]][[x]]) else NA, na.rm=T)})), probs=breaks, na.rm=T),1)
}))
names(out) <- breaks
return(out)
}

.euc <- function(xs, ys) { sqrt((xs[1]-xs[2])^2 + (ys[1]-ys[2])^2) }
.meuc <- function(c1, c2, coords) {
c3 <- coords[unlist(c1[,1])[1],]
outd <- list(NA)
for ( rw in 1:length(c2) ) {
outd[[rw]] <- sapply(unlist(c2[rw]), function(x) {
.euc(c(as.numeric(c3[1]), as.numeric(coords[x,1])), c(as.numeric(c3[2]), as.numeric(coords[x,2])))
})
}
return(outd)
}
}
14 changes: 7 additions & 7 deletions R/dynamAedes.m.R
Original file line number Diff line number Diff line change
Expand Up @@ -44,18 +44,18 @@ dynamAedes.m <- function(species="aegypti", intro.eggs=0, intro.deggs=0, intro.a
### Initial checks
#Species
if( !species%in%c("aegypti","albopictus","koreicus","japonicus") ) {
stop("Species not supported, exiting..." )
stop("Mosquito species not supported, exiting..." )
}
#Dayspan
if( is.na(endd) ) {
if( nchar(strsplit(as.character(startd),"-")[[1]][1])<4 ) {
stop("Dates in the wrong format: change them to %Y-%m-%d")
stop("Dates in the wrong format: change them to '%Y-%m-%d'.")
}
dayspan <- as.integer(ncol(temps.matrix)-1)
}
else {
if( nchar(strsplit(as.character(startd),"-")[[1]][1])<4|nchar(strsplit(as.character(endd),"-")[[1]][1])<4 ) {
stop("Dates in the wrong format: change them to %Y-%m-%d")
stop("Dates in the wrong format: change them to '%Y-%m-%d'.")
}
dayspan <- as.integer(as.Date(endd)-as.Date(startd))
}
Expand All @@ -68,7 +68,6 @@ dynamAedes.m <- function(species="aegypti", intro.eggs=0, intro.deggs=0, intro.a
if( is.na(coords.proj4) ) {
stop("No proj4 string for input coordinates. Please set 'coords.proj4' option.")
} else {
message("inside")
cells.coords.photo <- as.data.frame(coordinates(spTransform(SpatialPoints(cells.coords, proj4string=CRS(coords.proj4)), CRSobj=CRS("+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs"))))
}
}
Expand All @@ -95,12 +94,13 @@ dynamAedes.m <- function(species="aegypti", intro.eggs=0, intro.deggs=0, intro.a
} else (stop("avgpdisp not supported yet..."))
## Derive daylength for laying of diapausing eggs in albopictus/koreicus/japonicus
if( species!="aegypti" ){
jd <- JD(seq(as.POSIXct(startd), as.POSIXct(as.Date(startd)+dayspan), by='day'))
doy <- as.numeric(format(seq(as.POSIXct(startd), as.POSIXct(as.Date(startd)+dayspan), by='day'), "%j"))
if( scale=="rg" ) {
photo.matrix <- lapply(jd, function(x){insol::daylength(long = cells.coords.photo[,1], lat=cells.coords.photo[,2], jd=x, 1)[,3]})
photo.matrix <- lapply(doy, function(x){daylength(lat=cells.coords.photo[,2], doy=x)})

photo.matrix <- do.call(cbind,photo.matrix)
} else if( !is.na(lat)&!is.na(long) ) {
dl <- daylength(lat,long,jd,1)[,3]
dl <- daylength(lat,doy)
photo.matrix <- matrix(dl, nrow=1)
} else (stop("Something's wrong with scale or lat and long"))
} else{
Expand Down
Loading

0 comments on commit 187affe

Please sign in to comment.