Skip to content

Commit

Permalink
CRAN
Browse files Browse the repository at this point in the history
  • Loading branch information
ibarraespinosa committed Sep 27, 2023
1 parent 167f609 commit f8a0c66
Show file tree
Hide file tree
Showing 69 changed files with 8,137 additions and 8,122 deletions.
6 changes: 3 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: eixport
Title: Export Emissions to Atmospheric Models
Version: 0.5.4
Date: 2023-03-27
Version: 0.6.0
Date: 2023-09-26
Authors@R: c(
person(given = "Sergio",
family = "Ibarra-Espinosa",
Expand All @@ -23,7 +23,7 @@ License: MIT + file LICENSE
URL: https://atmoschem.github.io/eixport/
BugReports: https://github.com/atmoschem/eixport/issues/
Depends: R (>= 3.5.0)
Imports: sf, ncdf4, raster, methods, cptcity, utils, parallel, data.table
Imports: sf, ncdf4, raster, methods, cptcity, utils, data.table
Encoding: UTF-8
LazyData: no
RoxygenNote: 7.2.3
Expand Down
9 changes: 9 additions & 0 deletions R/eixport-deprecated.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
## eixport-deprecated.r
#' @title Deprecated functions in package \pkg{eixport}.
#' @description The functions listed below are deprecated and will be defunct in
#' the near future. When possible, alternative functions with similar
#' functionality are also mentioned. Help pages for deprecated functions are
#' available at \code{help("-deprecated")}.
#' @name eixport-deprecated
#' @keywords internal
NULL
189 changes: 97 additions & 92 deletions R/get_edgar.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#' Download datasets of EDGAR emissions
#' DEPRECATED Download datasets of EDGAR emissions
#'
#' @description The Emissions Database for Global Atmospheric Research (EDGAR) is a
#' project from the Joint Research Centre. They provide provides global past and
Expand All @@ -7,6 +7,7 @@
#' functions to download any of the EDGAR datasets.
#'
#'
#' @name eixport-deprecated
#' @param dataset Character; name of the datasets: "v50_AP", "v432_AP", "v432_VOC_spec",
#' "htap_v2_2", "v50_GHG
#' @param pol Character; one of the pollutants shown on note.
Expand Down Expand Up @@ -106,7 +107,7 @@
#' @importFrom utils download.file askYesNo data
#' @importFrom parallel detectCores mclapply
#' @export
#' @examples \donttest{
#' @examples \dontrun{
#' # see all the links:
#' data(edgar)
#' head(edgar)
Expand All @@ -119,6 +120,7 @@
#' type = "nc",
#' ask = FALSE)
#' }

get_edgar <- function(dataset = "v50_AP",
pol,
sector,
Expand All @@ -129,94 +131,97 @@ get_edgar <- function(dataset = "v50_AP",
ask = TRUE,
copyright = TRUE,
verbose = TRUE){
if(copyright) message(
paste0(c(
" Copyright notice\n",
"------------------\n",
" (c) European Union, 1995-2019\n\n",
" Reuse is authorised, provided the source is acknowledged. The reuse policy \n",
" of the European Commission is implemented by a Decision of 12 December 2011, see\n",
" http://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=OJ:L:2011:330:0039:0042:EN:PDF\n\n"
))
)
ed <- sysdata$edgar

eda <- ed
ed <- ed[ed$data %in% dataset, ]
if(nrow(ed) == 0) {
cat("Please, choose one of the following datasets:\n", unique(eda$data), "\n") # nocov
stop("No dataset") # nocov
}

eda <- ed
if(missing(year)){
warning("Downloading all available years") # nocov
} else {
ed <- ed[ed$year %in% year, ]
if(nrow(ed) == 0) {
cat("Please, choose one of the following years:\n", unique(eda$year), "\n") # nocov
stop("No Year") # nocov
}
}

eda <- ed
if(missing(sector)){
warning("Downloading all available sector") # nocov
} else {
ed <- ed[ed$sector %in% sector, ]
if(nrow(ed) == 0) {
cat("Please, choose one of the following sector:\n", unique(eda$sector), "\n") # nocov
stop("No sector") # nocov
}
}

eda <- ed
if(missing(pol)){
warning("Downloading all available pollutants") # nocov
} else {
ed <- ed[ed$pol %in% pol, ]
if(nrow(ed) == 0) {
cat("Please, choose one of the following pollutants:\n", unique(eda$pol), "\n")
stop("No pollutants")
}
}

# nocov start

eda <- ed
if(missing(type)){
warning("Downloading all available pollutants")
} else {
ed <- ed[ed$type %in% type, ]
if(nrow(ed) == 0) {
cat("Please, choose one of the following pollutants:\n", unique(eda$type), "\n")
stop("No type")
}
}

if(verbose) cat("Downloading the following data:\n")
if(verbose) cat(ed$url)

if(ask){ # nocov start
a <- utils::askYesNo("Are these links ok?")
if(!a) stop("Make a selection again. Remember, you can see the urls with data(edgar)")
} # nocov end


# paths
if(missing(n)) {
for (i in 1:length(ed$url)){
utils::download.file(url = ed$url[i],
destfile = paste0(destpath, "/", ed$links[i]))
message(paste0(
"Files at ", destpath, "\n"))
}
} else {
parallel::mclapply(seq_along(ed$url), function(i) {
utils::download.file(paste0(url = ed$url[i]),
destfile = paste0(destpath, "/", ed$links[i]))

}, mc.cores = n)
}
# nocov end
.Deprecated("Internet")
"get_edgar"
#
# if(copyright) message(
# paste0(c(
# " Copyright notice\n",
# "------------------\n",
# " (c) European Union, 1995-2019\n\n",
# " Reuse is authorised, provided the source is acknowledged. The reuse policy \n",
# " of the European Commission is implemented by a Decision of 12 December 2011, see\n",
# " http://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=OJ:L:2011:330:0039:0042:EN:PDF\n\n"
# ))
# )
# ed <- sysdata$edgar
#
# eda <- ed
# ed <- ed[ed$data %in% dataset, ]
# if(nrow(ed) == 0) {
# cat("Please, choose one of the following datasets:\n", unique(eda$data), "\n") # nocov
# stop("No dataset") # nocov
# }
#
# eda <- ed
# if(missing(year)){
# warning("Downloading all available years") # nocov
# } else {
# ed <- ed[ed$year %in% year, ]
# if(nrow(ed) == 0) {
# cat("Please, choose one of the following years:\n", unique(eda$year), "\n") # nocov
# stop("No Year") # nocov
# }
# }
#
# eda <- ed
# if(missing(sector)){
# warning("Downloading all available sector") # nocov
# } else {
# ed <- ed[ed$sector %in% sector, ]
# if(nrow(ed) == 0) {
# cat("Please, choose one of the following sector:\n", unique(eda$sector), "\n") # nocov
# stop("No sector") # nocov
# }
# }
#
# eda <- ed
# if(missing(pol)){
# warning("Downloading all available pollutants") # nocov
# } else {
# ed <- ed[ed$pol %in% pol, ]
# if(nrow(ed) == 0) {
# cat("Please, choose one of the following pollutants:\n", unique(eda$pol), "\n")
# stop("No pollutants")
# }
# }
#
# # nocov start
#
# eda <- ed
# if(missing(type)){
# warning("Downloading all available pollutants")
# } else {
# ed <- ed[ed$type %in% type, ]
# if(nrow(ed) == 0) {
# cat("Please, choose one of the following pollutants:\n", unique(eda$type), "\n")
# stop("No type")
# }
# }
#
# if(verbose) cat("Downloading the following data:\n")
# if(verbose) cat(ed$url)
#
# if(ask){ # nocov start
# a <- utils::askYesNo("Are these links ok?")
# if(!a) stop("Make a selection again. Remember, you can see the urls with data(edgar)")
# } # nocov end
#
#
# # paths
# if(missing(n)) {
# for (i in 1:length(ed$url)){
# utils::download.file(url = ed$url[i],
# destfile = paste0(destpath, "/", ed$links[i]))
# message(paste0(
# "Files at ", destpath, "\n"))
# }
# } else {
# parallel::mclapply(seq_along(ed$url), function(i) {
# utils::download.file(paste0(url = ed$url[i]),
# destfile = paste0(destpath, "/", ed$links[i]))
#
# }, mc.cores = n)
# }
# # nocov end
}
9 changes: 7 additions & 2 deletions R/to_as4wrf.R
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,12 @@
#' tz = "America/Sao_Paulo")
#' head(df2)
#' }
to_as4wrf <- function(sdf, nr = 1, dmyhm, tz, crs = 4326, islist){
to_as4wrf <- function(sdf,
nr = 1,
dmyhm,
tz,
crs = 4326,
islist){
if(nr <= 0){
stop("The argument 'nr' must be positive") # nocov
} else if (class(sdf)[1] != "list") {
Expand Down Expand Up @@ -88,7 +93,7 @@ to_as4wrf <- function(sdf, nr = 1, dmyhm, tz, crs = 4326, islist){
strftime(dft$time_utc, timezone = tz, format = "%d"),
strftime(dft$time_utc, timezone = tz, format = "%H")
))
} else if (class(sdf) == "list") {
} else if (class(sdf)[1] == "list") {
# if(class(sdf)[1] == "sf"){
# sdf <- lapply(sdf, methods::as, "Spatial")
# }
Expand Down
2 changes: 1 addition & 1 deletion R/wrf_put.R
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ wrf_put <- function (file = file.choose(),
warning(paste0(n_neg,' negative values found!\nreplaced by zeros'))
}
} # nocov end
if(class(POL[1]) =="POSIXlt" || class(POL[1]) == "POSIXt"){
if(class(POL[1])[1] =="POSIXlt" || class(POL[1])[1] == "POSIXt"){
cat('converting POSIXlt to string\n') # nocov
POL <- format(POL,"%Y-%m-%d_%H:%M:%OS") # nocov
if(name == 'time') # nocov
Expand Down
81 changes: 47 additions & 34 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,23 @@
<!-- README.md is generated from README.Rmd. Please edit that file -->

# eixport <img src="man/figures/logo.gif" align="right" alt="" width="140" />
<!-- badges: start -->
[![Build status](https://ci.appveyor.com/api/projects/status/frk36kmayf8yff70?svg=true)](https://ci.appveyor.com/project/Schuch666/eixport)
[![Coverage Status](https://img.shields.io/codecov/c/github/atmoschem/eixport/master.svg)](https://codecov.io/github/atmoschem/eixport?branch=master)
[![cran checks](https://badges.cranchecks.info/worst/eixport.svg)](https://cran.r-project.org/web/checks/check_results_eixport.html)
[![CRAN\_Status\_Badge](http://www.r-pkg.org/badges/version/eixport)](http://cran.r-project.org/web/packages/eixport)
[![CRAN Downloads](http://cranlogs.r-pkg.org/badges/grand-total/eixport?color=orange)](http://cran.r-project.org/package=eixport)

[![Travis-CI Build
Status](https://travis-ci.org/atmoschem/eixport.svg?branch=master)](https://travis-ci.org/atmoschem/eixport)[![Build
status](https://ci.appveyor.com/api/projects/status/frk36kmayf8yff70?svg=true)](https://ci.appveyor.com/project/Schuch666/eixport)
[![Coverage
Status](https://img.shields.io/codecov/c/github/atmoschem/eixport/master.svg)](https://codecov.io/github/atmoschem/eixport?branch=master)
[![DOI](https://zenodo.org/badge/106145968.svg)](https://zenodo.org/badge/latestdoi/106145968)
[![CRAN_Status_Badge](http://www.r-pkg.org/badges/version/eixport)](http://cran.r-project.org/web/packages/eixport)
[![CRAN
Downloads](http://cranlogs.r-pkg.org/badges/grand-total/eixport?color=orange)](http://cran.r-project.org/package=eixport)
[![DOI](http://joss.theoj.org/papers/10.21105/joss.00607/status.svg)](https://doi.org/10.21105/joss.00607)
[![DOI](https://zenodo.org/badge/106145968.svg)](https://zenodo.org/badge/latestdoi/106145968)
[![Github Stars](https://img.shields.io/github/stars/atmoschem/eixport.svg?style=social&label=Github)](https://github.com/atmoschem/eixport)
<!-- badges: end -->
[![cran
checks](https://cranchecks.info/badges/worst/eixport)](https://cran.r-project.org/web/checks/check_results_eixport.html)
[![Github
Stars](https://img.shields.io/github/stars/atmoschem/eixport.svg?style=social&label=Github)](https://github.com/atmoschem/eixport)

## Exporting emissions to atmospheric models, eixport: 0.5.1
## Exporting emissions to atmospheric models, eixport: 0.6.0

Emissions are mass that affects atmosphere in complex ways, not only
physical, but also, in the health of humans, ecosystems, economically,
Expand Down Expand Up @@ -44,42 +49,50 @@ devtools::install_github("atmoschem/eixport")

## Some functions:

- [get\_edgar](https://atmoschem.github.io/eixport/reference/get_edgar.html):
Download EDGAR emissions data.
- [to\_rline](https://atmoschem.github.io/eixport/reference/to_rline.html):
Export emissions to other formats
- [to\_wrf](https://atmoschem.github.io/eixport/reference/to_wrf.html):
Combine total/spatial/temporal/split and write emission to file
- [to\_brams\_spm](https://atmoschem.github.io/eixport/reference/to_brams_spm.html):
inputs for SPM BRAMS
- [wrf\_profile](https://atmoschem.github.io/eixport/reference/wrf_profile.html):
Create spatial profile for WRF-Chem
- [wrf\_create](https://atmoschem.github.io/eixport/reference/wrf_create.html):
Create emission files to the WRF-Chem
- [wrf\_plot](https://atmoschem.github.io/eixport/reference/wrf_plot.html):
simple but useful plot
- [wrf\_get](https://atmoschem.github.io/eixport/reference/wrf_get.html):
Read variables
- [wrf\_put](https://atmoschem.github.io/eixport/reference/wrf_put.html):
Write variables
- [to\_as4wrf](https://atmoschem.github.io/eixport/reference/to_as4wrf.html):
Create WRF-Chem inputs using NCL scrip AS4WRF.ncl.
- [to\_munich](https://atmoschem.github.io/eixport/reference/to_munich.html):
To generate inputs for MUNICH model.
- [get_edgar](https://atmoschem.github.io/eixport/reference/get_edgar.html):
Download EDGAR emissions data.
- [to_rline](https://atmoschem.github.io/eixport/reference/to_rline.html):
Export emissions to other formats
- [to_wrf](https://atmoschem.github.io/eixport/reference/to_wrf.html):
Combine total/spatial/temporal/split and write emission to file
- [to_brams_spm](https://atmoschem.github.io/eixport/reference/to_brams_spm.html):
inputs for SPM BRAMS
- [wrf_profile](https://atmoschem.github.io/eixport/reference/wrf_profile.html):
Create spatial profile for WRF-Chem
- [wrf_create](https://atmoschem.github.io/eixport/reference/wrf_create.html):
Create emission files to the WRF-Chem
- [wrf_plot](https://atmoschem.github.io/eixport/reference/wrf_plot.html):
simple but useful plot
- [wrf_get](https://atmoschem.github.io/eixport/reference/wrf_get.html):
Read variables
- [wrf_put](https://atmoschem.github.io/eixport/reference/wrf_put.html):
Write variables
- [to_as4wrf](https://atmoschem.github.io/eixport/reference/to_as4wrf.html):
Create WRF-Chem inputs using NCL scrip AS4WRF.ncl.
- [to_munich](https://atmoschem.github.io/eixport/reference/to_munich.html):
To generate inputs for MUNICH model.

### Summary

``` r
library(eixport)
#> The legacy packages maptools, rgdal, and rgeos, underpinning the sp package,
#> which was just loaded, will retire in October 2023.
#> Please refer to R-spatial evolution reports for details, especially
#> https://r-spatial.org/r/2023/05/15/evolution4.html.
#> It may be desirable to make the sf package available;
#> package maintainers should consider adding sf to Suggests:.
#> The sp package is now running under evolution status 2
#> (status 2 uses the sf package in place of rgdal)
file = paste0(system.file("extdata", package = "eixport"),"/wrfinput_d02")
wrf_summary(file = file)
#> | | | 0% | |======================= | 33% | |=============================================== | 67% | |======================================================================| 100%
#> Min. 1st Qu. Median Mean 3rd Qu.
#> Times 1.312168e+09 1.312168e+09 1.312168e+09 1.312168e+09 1.312168e+09
#> Times 1.312178e+09 1.312178e+09 1.312178e+09 1.312178e+09 1.312178e+09
#> XLAT -2.438538e+01 -2.405025e+01 -2.370471e+01 -2.370379e+01 -2.335773e+01
#> XLONG -4.742899e+01 -4.696930e+01 -4.650305e+01 -4.650304e+01 -4.603427e+01
#> Max. sum
#> Times 1.312168e+09 NA
#> Times 1.312178e+09 NA
#> XLAT -2.301877e+01 -76160.28
#> XLONG -4.558643e+01 -149414.28
```
Expand Down
Loading

0 comments on commit f8a0c66

Please sign in to comment.