Skip to content

Commit

Permalink
Merge pull request #1 from rogiersbart/develop
Browse files Browse the repository at this point in the history
File list update
  • Loading branch information
cneyens authored Jun 20, 2019
2 parents 7ee5fbd + 16db14c commit 2019c39
Show file tree
Hide file tree
Showing 462 changed files with 13,556 additions and 11,856 deletions.
8 changes: 5 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ Title: Pre- and post-processing of MODFLOW files in R
Version: 0.4.0.9000
Date: 2016-06-27
Authors@R: person("Bart", "Rogiers", role = c("aut", "cre"), email = "brogiers@sckcen.be")
Author: Bart Rogiers <brogiers@sckcen.be>
Maintainer: Bart Rogiers <brogiers@sckcen.be>
Description: The RMODFLOW package provides a set of tools for groundwater flow
modelling with MODFLOW.
License: GPL (>= 2)
Expand All @@ -26,7 +24,11 @@ Imports:
tools,
lubridate,
xml2,
rvest
rvest,
sf,
tibble,
dplyr,
tidyr
URL: https://github.com/rogiersbart/RMODFLOW
BugReports: https://github.com/rogiersbart/RMODFLOW/issues
RoxygenNote: 6.1.1
Expand Down
40 changes: 12 additions & 28 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@ S3method(plot,rmf_3d_array)
S3method(plot,rmf_4d_array)
S3method(plot,sen)
S3method(rmf_animate,rmf_4d_array)
S3method(rmf_as_array,rmf_list)
S3method(rmf_as_list,rmf_2d_array)
S3method(rmf_as_list,rmf_3d_array)
S3method(rmf_as_list,rmf_4d_array)
S3method(rmf_as_sf,rmf_2d_array)
S3method(rmf_as_tibble,rmf_2d_array)
S3method(rmf_as_tibble,rmf_3d_array)
S3method(rmf_as_tibble,rmf_4d_array)
S3method(rmf_cell_coordinates,dis)
S3method(rmf_cell_coordinates,huf)
S3method(rmf_cell_dimensions,dis)
Expand Down Expand Up @@ -77,8 +85,11 @@ export(read_oc)
export(read_pcg)
export(read_prj)
export(read_pvl)
export(read_rds)
export(rmf_animate)
export(rmf_as_array)
export(rmf_as_list)
export(rmf_as_sf)
export(rmf_as_tibble)
export(rmf_cell_coordinates)
export(rmf_cell_dimensions)
export(rmf_cell_info)
Expand Down Expand Up @@ -218,31 +229,4 @@ export(write_oc)
export(write_pcg)
export(write_prj)
export(write_pvl)
export(write_rds)
import(akima)
import(directlabels)
import(ggplot2)
import(quadprog)
import(rgl)
importFrom(DEoptim,DEoptim)
importFrom(animation,saveGIF)
importFrom(animation,saveHTML)
importFrom(animation,saveLatex)
importFrom(hydroPSO,hydroPSO)
importFrom(magrittr,"%>%")
importFrom(readr,read_lines)
importFrom(readr,read_rds)
importFrom(readr,write_rds)
importFrom(rgdal,writeOGR)
importFrom(sf,st_coordinates)
importFrom(sf,st_crs)
importFrom(sf,st_multipoint)
importFrom(sf,st_sfc)
importFrom(sf,st_transform)
importFrom(sp,CRS)
importFrom(sp,Polygon)
importFrom(sp,Polygons)
importFrom(sp,SpatialPolygons)
importFrom(sp,SpatialPolygonsDataFrame)
importFrom(tools,file_ext)
importFrom(tools,file_path_sans_ext)
2 changes: 1 addition & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# RMODFLOW 0.5.0 [WIP]

* Added automatic installation of MODFLOW variants.
* Added automatic installation of MODFLOW variants ([#2](https://github.com/rogiersbart/RMODFLOW/issues/2)).
* Added automatic finding of paths to MODFLOW executables.
* Added function prefixes `rmf_`, and `rmfi_` for internal functions.
* Added a [pkgdown site](https://rogiersbart.github.io/RMODFLOW/).
Expand Down
52 changes: 29 additions & 23 deletions R/rmf-animate.rmf-4d-array.R → R/animate.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
#' Generic function to make animations from RMODFLOW arrays
#'
#' @rdname rmf_animate
#' @export
rmf_animate <- function(...) {
UseMethod('rmf_animate')
}

#' Animations from rmf 4d arrays
#'
#' @param array rmf 4d array
Expand All @@ -18,26 +26,24 @@
#' @param overlay additional ggplot2 layers to add to all frames
#' @param background background ggplot2 plot for all frames
#' @rdname rmf_animate
#' @importFrom animation saveLatex saveGIF saveHTML
#' @importFrom tools file_ext file_path_sans_ext
#' @export
rmf_animate.rmf_4d_array <- function(array,
i = NULL,
j = NULL,
k = NULL,
l = 1:dim(array)[4],
title = 'totim_unit',
dis = dis,
...,
file='rmf_animation.gif',
type = tools::file_ext(file),
plot_type = 'fill',
width=c(600,600,8)[type==c('gif','html','pdf')],
height=width,
clean = TRUE,
interval = 0.5,
overlay = NULL,
background = NULL) {
i = NULL,
j = NULL,
k = NULL,
l = 1:dim(array)[4],
title = 'totim_unit',
dis = dis,
...,
file='rmf_animation.gif',
type = tools::file_ext(file),
plot_type = 'fill',
width=c(600,600,8)[type==c('gif','html','pdf')],
height=width,
clean = TRUE,
interval = 0.5,
overlay = NULL,
background = NULL) {
if(!is.null(title)){
if(title == 'totim') {
title <- attributes(array)$totim[l]
Expand All @@ -61,18 +67,18 @@ rmf_animate.rmf_4d_array <- function(array,
current_wd <- getwd()
setwd(dirname(file))
if(type == 'gif') {
saveGIF(expr,img.name=paste0(basename(file_path_sans_ext(file)),'_frame'),movie.name=basename(file),
animation::saveGIF(expr,img.name=paste0(basename(tools::file_path_sans_ext(file)),'_frame'),movie.name=basename(file),
ani.dev='png',ani.type='png',ani.width=width,ani.height=height, clean = clean, interval = interval)
} else if(type == 'pdf') {
ani.options(ani.dev='pdf',ani.type='pdf',ani.height=8, ani.width=8)
saveLatex(expr,img.name=paste0(basename(file_path_sans_ext(file)),'_frames'),latex.filename=paste0(basename(file_path_sans_ext(file)),'.tex'),
animation::saveLatex(expr,img.name=paste0(basename(tools::file_path_sans_ext(file)),'_frames'),latex.filename=paste0(basename(file_path_sans_ext(file)),'.tex'),
ani.dev='pdf',ani.type='pdf',ani.height=height,ani.width=width)
if(clean) {
file.remove('animate.sty','animfp.sty',paste0(basename(file_path_sans_ext(file)),'.tex'),paste0(basename(file_path_sans_ext(file)),'.log'),paste0(basename(file_path_sans_ext(file)),'.aux'),paste0(basename(file_path_sans_ext(file)),'_frames.pdf'))
file.remove('animate.sty','animfp.sty',paste0(basename(tools::file_path_sans_ext(file)),'.tex'),paste0(basename(file_path_sans_ext(file)),'.log'),paste0(basename(file_path_sans_ext(file)),'.aux'),paste0(basename(file_path_sans_ext(file)),'_frames.pdf'))
}
} else if(type == 'html') {
saveHTML(expr,img.name=paste0(basename(file_path_sans_ext(file)),'_frame'),htmlfile=basename(file),
ani.dev='png',ani.type='png',ani.width=width,ani.height=height, clean = clean, interval = interval, verbose = FALSE)
animation::saveHTML(expr,img.name=paste0(basename(tools::file_path_sans_ext(file)),'_frame'),htmlfile=basename(file),
ani.dev='png',ani.type='png',ani.width=width,ani.height=height, clean = clean, interval = interval, verbose = FALSE)
} else {
stop('Please provide valid animation type.')
}
Expand Down
63 changes: 63 additions & 0 deletions R/examples.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#' Path to example file
#'
#' @param filename filename of the example file
#'
#' @return path to example file
#' @export
#'
#' @examples
rmf_example_file <- function(filename = NULL) {
filename <- system.file(paste0("extdata/", filename), package = "RMODFLOW")
if(filename[1] == "") {
stop("Example file not found. Please check the list of example files with rmf_example_files().")
} else {
return(filename)
}
}

#' Path to example files
#'
#' @param pattern pattern to match example file filenames. If NULL (default), returns vector of all example file filenames.
#'
#' @return path to example files
#' @export
#'
#' @examples
rmf_example_files <- function(pattern = NULL) {
example_files <- dir(system.file("extdata", package = "RMODFLOW"))
if(is.null(pattern)) {
return(example_files)
} else {
filenames <- grep(pattern, example_files, value = TRUE)
if(length(filenames) == 0) {
stop("Example files not found given the provided pattern. Please check the list of example files with rmf_example_files().")
} else {
return(filenames)
}
}
}

#' List example model files
#'
#' @param model
#'
#' @return example model files
#' @export
#'
#' @examples
rmf_example_model <- function(model) {
rmf_example_files(model) %>%
rmf_example_file()
}

#' List example models
#'
#' @return example model names
#' @export
#'
#' @examples
rmf_example_models <- function() {
example_files <- dir(system.file("extdata", package = "RMODFLOW"))
example_files <- gsub(".nam", "", example_files[grep(".nam", example_files)])
return(example_files)
}
Loading

0 comments on commit 2019c39

Please sign in to comment.