Commit 0d241d92 authored by ibarraespinosa's avatar ibarraespinosa

Moving to gitlab

parents
^.*\.Rproj$
^\.Rproj\.user$
^README.Rmd$
^README.html$
^vein.pdf$
^\.travis\.yml$
^appveyor.yml$
^docs$
^_pkgdown\.yml$
^logovein_small.png$
^codecov\.yml$
^CODE_OF_CONDUCT.md$
^CONTRIBUTING.md$
^README.md$
^.github$
^all_comp.gif$
^pkgdown$
^projects$
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: ''
assignees: ibarraespinosa
---
**Describe the bug**
A clear and concise description of what the bug is.
**To Reproduce**
Steps to reproduce the behavior:
```
"CODE"
```
**Expected behavior**
A clear and concise description of what you expected to happen.
**Screenshots**
If applicable, add screenshots to help explain your problem.
**Desktop (please complete the following information):**
```
sessionInfo()
version
packageVersion("vein")
```
**Additional context**
Add any other context about the problem here.
---
name: Feature request
about: Suggest an idea for this project
title: ''
labels: ''
assignees: ''
---
**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
**Describe the solution you'd like**
A clear and concise description of what you want to happen.
**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.
**Additional context**
Add any other context or screenshots about the feature request here.
inst/doc
.Rproj.user
.Rhistory
language: r
r:
- release
# - oldrel
# - devel
# cache: packages
sudo: required
dist: trusty
addons:
postgresql: "9.6"
"addons": {
"apt": {
"packages": [
"libmagickcore-dev",
"libmagickwand-dev"
]
}}
before_install:
- sudo add-apt-repository ppa:ubuntugis/ubuntugis-unstable --yes
- sudo apt-get --yes --force-yes update -qq
- sudo apt-get install --yes libpng12-dev
# units/udunits2 dependency:
- sudo apt-get install --yes libudunits2-dev
# sf dependencies:
- sudo apt-get install --yes libproj-dev libgeos-dev libgdal-dev gdal-bin libnetcdf-dev netcdf-bin
warnings_are_errors: false
r_packages:
- covr
after_success:
- Rscript -e 'library(covr); codecov()'
# Contributor Covenant Code of Conduct
## Our Pledge
In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.
## Our Standards
Examples of behavior that contributes to creating a positive environment include:
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members
Examples of unacceptable behavior by participants include:
* The use of sexualized language or imagery and unwelcome sexual attention or advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a professional setting
## Our Responsibilities
Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
## Scope
This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.
## Enforcement
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at sergio.ibarra@usp.br. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.
## Attribution
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version]
[homepage]: http://contributor-covenant.org
[version]: http://contributor-covenant.org/version/1/4/
## How to contribute
- Contributions of all sorts are welcome, [issues](https://github.com/atmoschem/vein/issues/) and [pull requests](https://github.com/atmoschem/vein/pulls) are the preferred ways of sharing them.
- When contributing pull requests, please follow the [Google's R Style Guide](https://google.github.io/styleguide/Rguide.xml).
- This project is released with a [Contributor Code of Conduct](https://github.com/atmoschem/vein/blob/master/CODE_OF_CONDUCT.md). By participating in this project you agree to abide by its terms.
- If you are new to GitHub, you might start with a [basic tutorial](https://help.github.com/articles/set-up-git) and check out a more detailed guide to [pull requests](https://help.github.com/articles/using-pull-requests/).
- Pull requests will be evaluated by the repository guardians on a schedule and if deemed beneficial will be committed to the master.
- All contributors retain the original copyright to their stuff, but by contributing to this project, you grant a world-wide, royalty-free, perpetual, irrevocable, non-exclusive, transferable license to all users **under the terms of the license under which this project is distributed.**
### Bugs?
- Submit an issue on the [Issues page](https://github.com/atmoschem/vein/issues)
### Code contributions
- Fork this repo to your Github account
- Clone your version on your account down to your machine from your account, e.g,. `git clone https://github.com/atmoschem/vein.git`
- Make sure to track progress upstream (i.e., on our version of `tidyhydat` at `atmoschem/vein`) by doing `git remote add upstream https://github.com/atmoschem/vein.git`. Before making changes make sure to pull changes in from upstream by doing either `git fetch upstream` then merge later or `git pull upstream` to fetch and merge in one step
- Make your changes (bonus points for making changes on a new feature branch)
- Push up to your account
- Submit a pull request to home base (likely master branch, but check to make sure) at `atmoschem/vein`
### Also, check out our [discussion forum](https://github.com/atmoschem/Conversas)
- Start an issue in english, português or español [here](https://github.com/atmoschem/Conversas/issues).
### Prefer to Email? Email the person listed as maintainer in the `DESCRIPTION` file of this repo.
### Thanks for contributing! c:
Package: vein
Type: Package
Title: Vehicular Emissions Inventories
Version: 0.8.9
Date: 2020-02-17
Authors@R: c(
person(given = "Sergio", family = "Ibarra-Espinosa",
role = c("aut", "cre"),
email = "sergio.ibarra@usp.br",
comment = c(ORCID = "0000-0002-3162-1905")))
Description: Elaboration of vehicular emissions inventories,
consisting in four stages, pre-processing activity data, preparing
emissions factors, estimating the emissions and post-processing of emissions
in maps and databases. More details in Ibarra-Espinosa et al (2018) <doi:10.5194/gmd-11-2209-2018>.
Before using VEIN you need to know the vehicular composition of your study area, in other words,
the combination of of type of vehicles, size and fuel of the fleet. Then, it is recommended to
start with the project to download a template to create a structure of directories and scripts.
License: MIT + file LICENSE
URL: https://atmoschem.github.io/vein/
BugReports: https://github.com/atmoschem/vein/issues/
LazyData: no
Depends: R (>= 3.5.0)
Imports: sf, data.table, units, graphics, stats, methods
Suggests: knitr, rmarkdown, testthat, covr, lwgeom, cptcity
RoxygenNote: 7.0.2
Encoding: UTF-8
NeedsCompilation: yes
Packaged: 2016-10-21 10:31:39 UTC; sergio
YEAR: 2018
COPYRIGHT HOLDER: SERGIO ALEJANDRO IBARRA ESPINOSA
# Generated by roxygen2: do not edit by hand
S3method(plot,EmissionFactors)
S3method(plot,EmissionFactorsList)
S3method(plot,Emissions)
S3method(plot,EmissionsArray)
S3method(plot,GriddedEmissionsArray)
S3method(plot,Speed)
S3method(plot,Vehicles)
S3method(print,EmissionFactors)
S3method(print,EmissionFactorsList)
S3method(print,Emissions)
S3method(print,EmissionsArray)
S3method(print,GriddedEmissionsArray)
S3method(print,Speed)
S3method(print,Vehicles)
S3method(summary,EmissionFactors)
S3method(summary,EmissionFactorsList)
S3method(summary,Emissions)
S3method(summary,EmissionsArray)
S3method(summary,GriddedEmissionsArray)
S3method(summary,Speed)
S3method(summary,Vehicles)
export(EmissionFactors)
export(EmissionFactorsList)
export(Emissions)
export(EmissionsArray)
export(EmissionsList)
export(Evaporative)
export(GriddedEmissionsArray)
export(Speed)
export(Vehicles)
export(add_polid)
export(adt)
export(age)
export(age_hdv)
export(age_ldv)
export(age_moto)
export(aw)
export(celsius)
export(cold_mileage)
export(ef_cetesb)
export(ef_china)
export(ef_evap)
export(ef_fun)
export(ef_hdv_scaled)
export(ef_hdv_speed)
export(ef_im)
export(ef_ive)
export(ef_ldv_cold)
export(ef_ldv_cold_list)
export(ef_ldv_scaled)
export(ef_ldv_speed)
export(ef_local)
export(ef_nitro)
export(ef_wear)
export(ef_whe)
export(emis)
export(emis_chem)
export(emis_cold)
export(emis_cold_td)
export(emis_det)
export(emis_dist)
export(emis_evap)
export(emis_evap2)
export(emis_grid)
export(emis_hot_td)
export(emis_merge)
export(emis_order)
export(emis_order2)
export(emis_paved)
export(emis_post)
export(emis_source)
export(emis_to_streets)
export(emis_wear)
export(emis_wrf)
export(fuel_corr)
export(get_project)
export(grid_emis)
export(hot_soak)
export(invcop)
export(inventory)
export(long_to_wide)
export(make_grid)
export(matvect)
export(my_age)
export(netspeed)
export(remove_units)
export(running_losses)
export(speciate)
export(split_emis)
export(temp_fact)
export(to_latex)
export(vein_notes)
export(vkm)
export(wide_to_long)
importFrom(data.table,':=')
importFrom(data.table,.SD)
importFrom(data.table,as.data.table)
importFrom(data.table,data.table)
importFrom(data.table,rbindlist)
importFrom(data.table,setDF)
importFrom(sf,st_area)
importFrom(sf,st_as_sf)
importFrom(sf,st_as_sfc)
importFrom(sf,st_bbox)
importFrom(sf,st_cast)
importFrom(sf,st_crop)
importFrom(sf,st_crs)
importFrom(sf,st_dimension)
importFrom(sf,st_geometry)
importFrom(sf,st_geometry_type)
importFrom(sf,st_intersection)
importFrom(sf,st_length)
importFrom(sf,st_set_geometry)
importFrom(sf,st_sf)
importFrom(sf,st_sfc)
importFrom(sf,st_transform)
importFrom(stats,median)
importFrom(stats,quantile)
importFrom(stats,sd)
importFrom(units,as_units)
importFrom(units,install_symbolic_unit)
importFrom(utils,data)
importFrom(utils,download.file)
importFrom(utils,file.edit)
importFrom(utils,head)
importFrom(utils,menu)
importFrom(utils,object.size)
importFrom(utils,packageVersion)
importFrom(utils,sessionInfo)
importFrom(utils,untar)
useDynLib(vein, .registration = TRUE)
This diff is collapsed.
#' Construction function for class "EmissionFactors"
#'
#' @description \code{EmissionFactors} returns a tranformed object with class
#' "EmissionFactors" and units g/km.
#'
#' @return Objects of class "EmissionFactors" or "units"
#'
#' @param x Object with class "data.frame", "matrix" or "numeric"
#' @param object Object with class "EmissionFactors"
#' @importFrom units as_units
#' @param ... ignored
#' @rdname EmissionFactors
#' @aliases EmissionFactors print.EmissionFactors summary.EmissionFactors
#' plot.EmissionFactors
#' @examples \dontrun{
#' data(fe2015)
#' names(fe2015)
#' class(fe2015)
#' df <- fe2015[fe2015$Pollutant=="CO", c(ncol(fe2015)-1,ncol(fe2015))]
#' ef1 <- EmissionFactors(df)
#' class(ef1)
#' summary(ef1)
#' plot(ef1)
#' print(ef1)
#' }
#' @export
EmissionFactors <- function(x, ...) {
if ( is.matrix(x) ) {
ef <- as.data.frame(x)
for(i in 1:ncol(ef)){
ef[,i] <- ef[,i]*units::as_units("g km-1")
}
class(ef) <- c("EmissionFactors",class(ef))
efx <- ef
} else if ( is.data.frame(x) ) {
ef <- x
for(i in 1:ncol(ef)){
ef[,i] <- ef[,i]*units::as_units("g km-1")
}
class(ef) <- c("EmissionFactors",class(ef))
} else if ( class(x) == "units" ) {
ef <- x
warning("Check units are g/km")
} else if( class(x) == "numeric" | class(x) == "integer" ) {
ef <- x*units::as_units("g km-1")
}
return(ef)
}
#' @rdname EmissionFactors
#' @method print EmissionFactors
#' @export
print.EmissionFactors <- function(x, ...) {
nr <- ifelse(nrow(x) <= 5, nrow(x), 5)
if(ncol(x) == 1) {
ndf <- names(x)
df <- data.frame(ndf = x[1:nr, ])
names(df) <- ndf
print.data.frame(df)
} else {
print.data.frame(x[1:nr, ])
}
if(nrow(x) > 5) cat(paste0("... and ", nrow(x) - 5, " more rows\n"))
}
#' @rdname EmissionFactors
#' @method summary EmissionFactors
#' @export
summary.EmissionFactors <- function(object, ...) {
cat("Mean EmissionFactors in study area = \n")
print(summary.data.frame(object))
}
#' @rdname EmissionFactors
#' @method plot EmissionFactors
#' @export
plot.EmissionFactors <- function(x, ...) {
ef <- x
if (ncol(ef) >= 1 & ncol(ef) <= 3) {
graphics::par(mfrow=c(1, ncol(ef)), tcl = -0.5)
} else if (ncol(ef) == 4) {
graphics::par(mfrow=c(2, 2), tcl = -0.5)
} else if (ncol(ef) >= 5 & ncol(ef) <= 6 ) {
graphics::par(mfrow=c(2, 3), tcl = -0.5)
} else if (ncol(ef) >= 7 & ncol(ef) <= 9 ) {
graphics::par(mfrow=c(3, 3), tcl = -0.5)
} else {
message("Plotting first 9 plots")
graphics::par(mfrow=c(3, 3), tcl = -0.5)
}
nc <- ifelse(ncol(ef) <= 9, ncol(ef), 9)
for (i in 1:nc) {
graphics::plot(ef[,i], type = "l", ...)
}
graphics::par(mfrow=c(1,1))
}
#' Construction function for class "EmissionFactorsList"
#'
#' @description \code{EmissionFactorsList} returns a tranformed object with
#' class"EmissionsFactorsList".
#'
#' @return Objects of class "EmissionFactorsList"
#'
#' @param x Object with class "list"
#' @param object Object with class "EmissionFactorsList"
#' @param default Logical value. When TRUE prints default list, when FALSE
#' prints messages with description of list
#' @param ... ignored
#' @rdname EmissionFactorsList
#' @aliases EmissionFactorsList print.EmissionFactorsList
#' summary.EmissionFactorsList plot.EmissionFactorsList
#' @examples \dontrun{
#' data(fe2015)
#' names(fe2015)
#' class(fe2015)
#' df <- fe2015[fe2015$Pollutant=="CO", c(ncol(fe2015)-1,ncol(fe2015))]
#' ef1 <- EmissionFactorsList(df)
#' class(ef1)
#' length(ef1)
#' length(ef1[[1]])
#' summary(ef1)
#' ef1
#' }
#' @export
EmissionFactorsList <- function(x, ...) {
if ( is.matrix(x) || is.data.frame(x) ) {
efx <- lapply(1:ncol(x), function(i) {
lapply(1:nrow(x), function(j) {
function(V) x[j,i]
})
})
class(efx) <- c("EmissionFactorsList",class(x))
} else if ( is.numeric(x) ) {
efx <- lapply(1:length(x), function(i) {function(V) x[i] })
class(efx) <- c("EmissionFactorsList",class(efx))
} else if ( is.list(x) && is.function(x[[1]]) ) {
efx <- x
class(efx) <- c("EmissionFactorsList",class(x))
}
return(efx)
}
#' @rdname EmissionFactorsList
#' @method print EmissionFactorsList
#' @export
print.EmissionFactorsList <- function(x, ..., default = FALSE) {
if ( default ) {
print.default(x)
} else if ( is.function( x[[1]] ) ){
cat("This EmissionFactorsList has ", length(x),
" functions")
} else if ( is.list(x) && is.list(x[[1]]) ) {
cat("This EmissionFactorsList has ", length(x), " lists\n")
cat("First has ",length(x[[1]]), " functions\n")
cat("Last has ", length(x[[length(x)]]), " functions")
}
}
#' @rdname EmissionFactorsList
#' @method summary EmissionFactorsList
#' @export
summary.EmissionFactorsList <- function(object, ...) {
ef <- object
if ( is.function( ef[[1]] ) ){
cat("This EmissionFactorsList has", length(ef),
"functions")
} else if ( is.list(ef) && is.list(ef[[1]]) ) {
cat("This EmissionFactorsList has ", length(ef), "lists\n")
cat("First has",length(ef[[1]]), "functions\n")
cat("Last has", length(ef[[length(ef)]]), "functions")
}
}
#' @rdname EmissionFactorsList
#' @method plot EmissionFactorsList
#' @export
plot.EmissionFactorsList <- function(x, ...) {
ef <- x
if ( is.function( ef[[1]] ) ){
cat("This EmissionFactorsList has", length(ef),
"functions")
graphics::plot(unlist(lapply(1:length(ef), function(i) ef[[i]](34) )),
ylab = "Emission factors at 34 [km/h]")
} else {
cat("Try other methods")
}
}
#' Construction function for class "Emissions"
#'
#' @description \code{Emissions} returns a tranformed object with class "Emissions".
#' The type of objects supported are of classes "matrix", "data.frame" and
#' "numeric". If the class of the object is "matrix" this function returns a
#' dataframe.
#'
#' @return Objects of class "Emissions" or "units"
#'
#' @param x Object with class "data.frame", "matrix" or "numeric"
#' @param object object with class "Emissions"
#' @param time Character to be the time units as denominator, eg "1/h"
#' @param ... ignored
#' @importFrom units as_units as_units
#'
#' @rdname Emissions
#' @aliases Emissions print.Emissions summary.Emissions plot.Emissions
#' @examples \dontrun{
#' data(net)
#' data(pc_profile)
#' data(fe2015)
#' data(fkm)
#' PC_G <- c(33491,22340,24818,31808,46458,28574,24856,28972,37818,49050,87923,
#' 133833,138441,142682,171029,151048,115228,98664,126444,101027,
#' 84771,55864,36306,21079,20138,17439, 7854,2215,656,1262,476,512,
#' 1181, 4991, 3711, 5653, 7039, 5839, 4257,3824, 3068)
#' veh <- data.frame(PC_G = PC_G)
#' pc1 <- my_age(x = net$ldv, y = PC_G, name = "PC")
#' pcw <- temp_fact(net$ldv+net$hdv, pc_profile)
#' speed <- netspeed(pcw, net$ps, net$ffs, net$capacity, net$lkm, alpha = 1)