https://github.com/simularia/simulariatools
Tools 🧰 to preprocess and post process data for air quality assessment.
https://github.com/simularia/simulariatools
air-quality atmospheric-modelling pollution-prediction r r-package rstats visualization
Last synced: 5 months ago
JSON representation
Tools 🧰 to preprocess and post process data for air quality assessment.
- Host: GitHub
- URL: https://github.com/simularia/simulariatools
- Owner: Simularia
- License: gpl-2.0
- Created: 2014-03-03T17:12:30.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2024-08-27T13:22:17.000Z (almost 2 years ago)
- Last Synced: 2025-03-02T05:43:33.567Z (over 1 year ago)
- Topics: air-quality, atmospheric-modelling, pollution-prediction, r, r-package, rstats, visualization
- Language: R
- Homepage: https://www.simularia.it/simulariatools
- Size: 3.5 MB
- Stars: 5
- Watchers: 3
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.Rmd
- Changelog: NEWS.md
- License: LICENSE.md
Awesome Lists containing this project
README
---
output: github_document
---
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
fig.retina = 2,
dpi = 300,
out.width = "80%",
out.height = "80%"
)
```
[](https://github.com/Simularia/simulariatools/actions/workflows/R-CMD-check.yaml)
[](https://CRAN.R-project.org/package=simulariatools)
[](https://CRAN.R-project.org/package=simulariatools)
[](https://doi.org/10.5281/zenodo.596741)
## Overview
**simulariatools** is an open source package with a collection of functions and
tools useful to pre and post process data for air quality modelling and
assessment:
- `contourPlot2()` plots a production-ready contour map of a pollutant concentration field.
- `plotAvgRad()` plots the hourly average of solar radiation.
- `plotAvgTemp()` plots the average atmospheric temperature.
- `plotStabilityClass()` plots histograms of atmospheric stability class.
- `vectorField()` plots a simple vector field given two components.
- `importRaster()` imports a generic raster file.
- `importADSOBIN()` imports an ADSO/BIN raster file.
- `importSurferGrd()` imports a grid file.
- `stabilityClass()` computes atmospheric stability class.
- `turnerStabilityClass()` computes atmospheric PGT stability class with Turner method.
- `downloadBasemap()` downloads GeoTIFF basemaps from the Italian [PCN](https://gn.mase.gov.it/portale/home).
- `removeOutliers()` removes time series outliers based on interquartile range.
- `rollingMax()` computes rolling max of a time series.
The package is developed and maintained at [Simularia](https://www.simularia.it)
and it is widely used in their daily work.
If you use this package in your work, please consider citing it.
Refer to its [Zenodo DOI](https://doi.org/10.5281/zenodo.596741) to cite it.
## Installation
To install the latest release of **simulariatools** from CRAN:
```{r eval=FALSE, include=TRUE}
install.packages("simulariatools")
```
> NOTE:
> To import *ADSO/BIN* data files via `importADSOBIN()`, a working installation
> of *Python3* is required. For more information about *R* and *Python*
> interoperability, refer to the documentation of
> [`reticulate`](https://rstudio.github.io/reticulate/).
### Development version
To get bug fixes or to use a feature from the development version, install the
development version from GitHub:
```{r eval=FALSE, include=TRUE}
# install.packages("pak")
pak::pkg_install("Simularia/simulariatools")
```
## Examples
### Contour Plot
First, import air quality data from *NetCDF* or *ADSO/BIN* files with the
appropriate convenience function:
```{r echo=TRUE}
library(simulariatools)
nox_concentration <- importRaster(
file = "./development/conc_avg.nc",
k = 1000,
destaggering = TRUE,
variable = "nox",
verbose = TRUE
)
```
Concentration data are imported as a `data.frame` with `x`, `y` columns corresponding to
the coordinates of the cell centre and a `z` column for grid values.
```{r echo=TRUE}
str(nox_concentration)
```
A quick contour plot, with default configuration, can be easily obtained by
running `contourPlot2()` without any argument:
```{r}
contourPlot2(nox_concentration)
```
The plot is customisable by using `contourPlot2()` arguments and by piping
**ggplot2** instructions together with the `+` operator.
In the following example, the original domain is cropped, colour levels are
explicitly assigned and a legend name is provided through function arguments.
Furthermore, `labs()` and `theme_minimal()` functions from **ggplot2** are used
to remove axis labels and to change the overall theme:
```{r echo=TRUE}
library(ggplot2)
contourPlot2(
nox_concentration,
xlim = c(502000, 519000),
ylim = c(4943125, 4955125),
nticks = 5,
levels = c(-Inf, 0.5, 1, 1.5, 2, Inf),
legend = "NOx [ug/m3]"
) +
labs(x = NULL, y = NULL) +
theme_minimal()
```
In order to save the last plot to file, you can directly use the **ggplot2**
function `ggsave()`:
```{r eval=FALSE}
ggsave(filename = "~/path/to/myplot.png", width = 7, height = 6, dpi = 300)
```
Optional arguments can be used to create special versions of the plot.
For example, use `tile = TRUE` to produce a non-spatially interpolated plot:
```{r echo=TRUE}
contourPlot2(
nox_concentration,
tile = TRUE,
legend = "NOx [ug/m3]"
)
```
## Contact
Contact person:
> [Giuseppe Carlino](https://github.com/gcarlino) (Simularia srl)
## Contributors
[Matteo Paolo Costa](https://github.com/teocos)
