Skip to content

Commit

Permalink
tweaked metadata in downloadSource
Browse files Browse the repository at this point in the history
  • Loading branch information
tscheypidi committed Nov 20, 2020
1 parent 50f008a commit e92a1a4
Show file tree
Hide file tree
Showing 8 changed files with 54 additions and 31 deletions.
2 changes: 1 addition & 1 deletion .buildlibrary
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ValidationKey: '34196400'
ValidationKey: '34569960'
AcceptedWarnings:
- 'Warning: package ''.*'' was built under R version'
- 'Warning: namespace ''.*'' is not available and has been replaced'
Expand Down
2 changes: 1 addition & 1 deletion .zenodo.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"title": "madrat: May All Data be Reproducible and Transparent (MADRaT) *",
"version": "1.85.0",
"version": "1.86.0",
"description": "<p>Provides a framework which should improve reproducibility and transparency in data processing. It provides functionality such as automatic meta data creation and management, rudimentary quality management, data caching, work-flow management and data aggregation.\n * The title is a wish not a promise. By no means we expect this package to deliver everything what is needed to achieve full reproducibility and transparency, but we believe that it supports efforts in this direction.<\/p>",
"creators": [
{
Expand Down
3 changes: 1 addition & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: madrat
Type: Package
Title: May All Data be Reproducible and Transparent (MADRaT) *
Version: 1.85.0
Version: 1.86.0
Date: 2020-11-20
Authors@R: c(person("Jan Philipp", "Dietrich", email = "dietrich@pik-potsdam.de", role = c("aut","cre")),
person("Lavinia", "Baumstark", email = "lavinia@pik-potsdam.de", role = "aut"),
Expand Down Expand Up @@ -40,4 +40,3 @@ LazyData: no
Encoding: UTF-8
RoxygenNote: 7.1.1
VignetteBuilder: knitr
ValidationKey: 34384100
4 changes: 2 additions & 2 deletions R/calcTauTotal.R
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ calcTauTotal <- function(source="paper") {
note=c('data based on Dietrich J.P., Schmitz C., M\uFCller C., Fader M., Lotze-Campen H., Popp A.,',
'Measuring agricultural land-use intensity - A global analysis using a model-assisted approach',
'Ecological Modelling, Volume 232, 10 May 2012, Pages 109-118, ISSN 0304-3800, 10.1016/j.ecolmodel.2012.03.002.',
'preprint available \u40 http://edoc.gfz-potsdam.de/pik/display.epl?mode=doc&id=5281'),
'preprint available \u40 https://doi.org/10.1016/j.ecolmodel.2012.03.002'),
source=bibentry("Article",
title="Measuring agricultural land-use intensity - A global analysis using a model-assisted approach",
author=c(person("Jan Philipp","Dietrich"),person("Christoph","Schmitz"),person("Christoph","Mueller"),person("Marianela","Fader"),
Expand All @@ -43,6 +43,6 @@ calcTauTotal <- function(source="paper") {
journal="Ecological Modelling",
volume="232",
pages="109-118",
url="http://edoc.gfz-potsdam.de/pik/display.epl?mode=doc&id=5281",
url="https://doi.org/10.1016/j.ecolmodel.2012.03.002",
doi="10.1016/j.ecolmodel.2012.03.002")))
}
13 changes: 9 additions & 4 deletions R/downloadSource.R
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,20 @@ downloadSource <- function(type,subtype=NULL,overwrite=FALSE) {
if(!all(mandatory %in% names(meta))) {vcat(0, paste0("Missing entries in the meta data of function '",functionname[1],"': ",mandatory[!mandatory %in% names(meta)]))}

# define reserved elements of meta data and check if they already exist
reserved <- c("type","subtype","origin","date")
reserved <- c("type","subtype","origin","date_downloaded","source_quality")
if(any(reserved %in% names(meta))) {vcat(0, paste0("The following entries in the meta data of the function '",functionname[1],"' are reserved and will be overwritten: ",reserved[reserved %in% names(meta)]))}

# set reserved meta data elements
meta$type <- type
meta$subtype <- ifelse(is.null(subtype), "none",subtype)
meta$origin <- paste0(gsub("\\s{2,}"," ",paste(deparse(match.call()),collapse=""))," -> ",functionname," (madrat ",packageDescription("madrat")$Version," | ",attr(functionname,"pkgcomment"),")")
meta$date <- date()
#meta$quality <- quality()
meta$date_downloaded <- date()
meta$source_quality <- ifelse(!is.null(meta$doi),"gold","silver")

write_yaml(meta,"DOWNLOAD.yml")
# reorder meta entries
preferred_order <- c("title","authors","doi","url","license","version","date_released","date_downloaded","origin",
"type","subtype", "source_quality","source")
order <- c(intersect(preferred_order,names(meta)),setdiff(names(meta),preferred_order))

write_yaml(meta[order],"DOWNLOAD.yml")
}
45 changes: 32 additions & 13 deletions R/downloadTau.R
Original file line number Diff line number Diff line change
@@ -1,19 +1,38 @@
#' @importFrom utils download.file unzip
downloadTau <- function(subtype="paper") {

settings <- list( paper = list(title = "Cellular (0.5deg), crop-specific land use intensity (tau) for 1995 and 2000",
url = "https://zenodo.org/record/4282581/files/tau-paper.zip",
doi = "10.5281/zenodo.4282581"),
historical = list(title = "Historic land use intensity (tau) development",
url = "https://zenodo.org/record/4282548/files/tau-historical.zip",
doi = "10.5281/zenodo.4282548"))
meta <- toolSubtypeSelect(subtype,settings)

# Meta data to be provided by the user
meta <- list(url = "http://www.pik-potsdam.de/members/dietrich/",
title = "Agricultural Land Use Intensity Tau",
authors = "Jan Philipp Dietrich",
license = "Creative Commons Attribution-ShareAlike 4.0 International License"
#version <-
#date_released <-
#doi <-
)

file <- toolSubtypeSelect(subtype,c(paper="tau-paper.zip",historical="tau-historical.zip"))
download.file(paste0(meta$url,file), destfile = "tau.zip")
download.file(meta$url, destfile = "tau.zip")
unzip("tau.zip")
unlink("tau.zip")
return(meta)

return(list(url = meta$url,
doi = meta$doi,
title = meta$title,
authors = person("Jan Philipp","Dietrich", email="dietrich@pik-potsdam.de", comment=c(ORCID="0000-0002-4309-6431")),
version = "1.0",
date_released = "2012-05-10",
license = "Creative Commons Attribution-ShareAlike 4.0 International License (CC BY-SA 4.0)",
source = bibentry("Article",
title="Measuring agricultural land-use intensity - A global analysis using a model-assisted approach",
author=c(person("Jan Philipp","Dietrich", email="dietrich@pik-potsdam.de", comment=c(ORCID="0000-0002-4309-6431")),
person("Christoph","Schmitz"),
person("Christoph","Mueller"),
person("Marianela","Fader"),
person("Hermann","Lotze-Campen"),
person("Alexander","Popp")),
year="2012",
journal="Ecological Modelling",
volume="232",
pages="109-118",
url="https://doi.org/10.1016/j.ecolmodel.2012.03.002",
doi="10.1016/j.ecolmodel.2012.03.002"))
)
}
4 changes: 2 additions & 2 deletions R/toolSubtypeSelect.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#'
#'
#' @param subtype A chosen subtype (character)
#' @param files A named vector. The names of the vector correspond to the
#' @param files A named vector or list. The names of the vector correspond to the
#' allowed subtypes and the content of the vector are the corresponding file
#' names.
#' @return The file name corresponding to the given subtype
Expand All @@ -23,5 +23,5 @@
toolSubtypeSelect <- function(subtype, files) {
if(is.null(subtype)) stop('Subtype has to be set! Available subtypes are: ',paste(names(files),collapse=", "))
if(!(subtype %in% names(files))) stop('Unknown subtype "',subtype,'"! Available subtypes are: ',paste(names(files),collapse=", "))
return(files[subtype])
return(files[[subtype]])
}
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# May All Data be Reproducible and Transparent (MADRaT) *

R package **madrat**, version **1.85.0**
R package **madrat**, version **1.86.0**

[![Travis build status](https://travis-ci.com/pik-piam/madrat.svg?branch=master)](https://travis-ci.com/pik-piam/madrat) [![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.1115490.svg)](https://doi.org/10.5281/zenodo.1115490) [![codecov](https://codecov.io/gh/pik-piam/madrat/branch/master/graph/badge.svg)](https://codecov.io/gh/pik-piam/madrat)

Expand Down Expand Up @@ -36,7 +36,7 @@ update.packages()
The package comes with a vignette describing the basic functionality of the package and how to use it. You can load it with the following command (the package needs to be installed):

```r
vignette(madrat) # Data preparation with MADRaT
vignette("madrat") # Data preparation with MADRaT
```

## Questions / Problems
Expand All @@ -47,9 +47,9 @@ In case of questions / problems please contact Jan Philipp Dietrich <dietrich@pi

To cite package **madrat** in publications use:

Dietrich J, Baumstark L, Wirth S, Giannousakis A, Rodrigues R, Bodirsky B, Kreidenweis U, Klein D (2020). _madrat: May All Data be Reproducible
and Transparent (MADRaT)_. doi: 10.5281/zenodo.1115490 (URL: https://doi.org/10.5281/zenodo.1115490), R package version 1.85.0, <URL:
https://github.com/pik-piam/madrat>.
Dietrich J, Baumstark L, Wirth S, Giannousakis A, Rodrigues R, Bodirsky B, Kreidenweis U, Klein D (2020). _madrat:
May All Data be Reproducible and Transparent (MADRaT)_. doi: 10.5281/zenodo.1115490 (URL:
https://doi.org/10.5281/zenodo.1115490), R package version 1.86.0, <URL: https://github.com/pik-piam/madrat>.

A BibTeX entry for LaTeX users is

Expand All @@ -58,7 +58,7 @@ A BibTeX entry for LaTeX users is
title = {madrat: May All Data be Reproducible and Transparent (MADRaT)},
author = {Jan Philipp Dietrich and Lavinia Baumstark and Stephen Wirth and Anastasis Giannousakis and Renato Rodrigues and Benjamin Leon Bodirsky and Ulrich Kreidenweis and David Klein},
year = {2020},
note = {R package version 1.85.0},
note = {R package version 1.86.0},
doi = {10.5281/zenodo.1115490},
url = {https://github.com/pik-piam/madrat},
}
Expand Down

0 comments on commit e92a1a4

Please sign in to comment.