Skip to content

Commit

Permalink
documentation and tarball 0.2.2
Browse files Browse the repository at this point in the history
  • Loading branch information
jobonaf committed Mar 27, 2015
1 parent bd01de8 commit ce6cc8e
Show file tree
Hide file tree
Showing 85 changed files with 621,688 additions and 100 deletions.
2 changes: 2 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
^.*\.Rproj$
^\.Rproj\.user$
tmp/
tar/
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Package: pesco
Type: Package
Title: Data fusion for air quality data
Version: 0.2
Date: 2015-02-26
Version: 0.2.2
Date: 2015-02-27
Author: Lucia Paci, Giovanni Bonafe'
Maintainer: G.Bonafe' <[email protected]>
Imports: geoR, akima, fields, caTools, ncdf, timeDate, chron
Expand Down
5 changes: 5 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Changes in pesco 0.2.2 [2015-03-27]
=====================================
* added documentation (man/*.Rd files)


10 changes: 6 additions & 4 deletions R/daily_synthesis.R
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,17 @@ dailyObs <- function(data, statistic, pollutant,
Time="Time", Code="Code",
others=c("Name","Municipality",
"Lat","Lon","Elev","Type")) {
codes <- unique(data[,Code])
codes <- unique(data[,Code]) ## extract station codes
flag=TRUE
for (code in codes) {
#print(code)
dat <- data[data[,Code]==code,]
dat <- data[data[,Code]==code,] ## select data of a single station
ttt <- dat[,Time]
sta <- dailyStat(x=dat[,pollutant],time=ttt,statistic,necess=0.75)
out <- data.frame(sta, names(sta),
dat[rep(1,length(sta)),
## build a dataframe with...
out <- data.frame(sta, ## ...daily statistic,...
names(sta), ## ...dates and...
dat[rep(1,length(sta)), ## ...station attributes
c(Code,others)])
colnames(out) <- c(pollutant, Time, Code, others)
if(flag) {
Expand Down
17 changes: 17 additions & 0 deletions R/geo.functions.R
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,20 @@ ll2utm.grid <- function(lat,lon,round=-2,iz=32) {
y=round(utm$y,round))
return(coords)
}

## euclidean distance
Dist <- function(x,y,xi,yi) sqrt((x-xi)^2+(y-yi)^2)

## find nearest
which.nearest <- function(xo,yo,xi,yi) {
out <- rep(NA,length(xo))
xo <- as.vector(xo)
yo <- as.vector(yo)
xi <- as.vector(xi)
yi <- as.vector(yi)
for(i in 1:length(xo)) {
out[i] <- which.min(Dist(xo[i],yo[i],xi,yi))[1]
}
return(out)
}

16 changes: 0 additions & 16 deletions R/interpolate.R
Original file line number Diff line number Diff line change
@@ -1,19 +1,3 @@
## euclidean distance
Dist <- function(x,y,xi,yi) sqrt((x-xi)^2+(y-yi)^2)

## find nearest
which.nearest <- function(x,y,xi,yi) {
out <- rep(NA,length(x))
x <- as.vector(x)
y <- as.vector(y)
xi <- as.vector(xi)
yi <- as.vector(yi)
for(i in 1:length(x)) {
out[i] <- which.min(Dist(x[i],y[i],xi,yi))[1]
}
return(out)
}

## interpolation (to grid or to sparse points)
Interp <- function(x,y,z,xp,yp,
method="linear",
Expand Down
10 changes: 5 additions & 5 deletions R/read.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ read.ncdf.arpaer <- function(con=NULL, pollutant="pm10", lev=1,
lat <- get.var.ncdf(nc,varid="lat")
Time <- as.POSIXct(get.var.ncdf(nc,varid="Times"),
format="%Y-%m-%d_%H:%M:%S", tz=tz.in)
Time <- tz.change(time.in=Time,tz.in=tz.in,tz.out=tz.out)
Time <- tz.change(x=Time,tz.in=tz.in,tz.out=tz.out)
value <- get.var.ncdf(nc,varid=pollutant)
if(length(dim(value))==4) {
value <- value[,,lev,]
Expand Down Expand Up @@ -161,13 +161,13 @@ read.grads <- function(filectl) {
}

# Funzione R per la lettura di file in formato estra_qaria.
read.qaria <- function(filename) {
hourly <- scan(filename,skip=2,what="",nlines=1)[4]=="hh"
dat <- read.fwf(file = filename,
read.qaria <- function(file) {
hourly <- scan(file,skip=2,what="",nlines=1)[4]=="hh"
dat <- read.fwf(file = file,
na.strings=c(" -9999.0"," -999.0"),
widths=c(4,rep(3,2+as.integer(hourly)),11),
header=FALSE,skip=3)
header=scan(filename, skip=2, what="", n=4++as.integer(hourly))
header=scan(file, skip=2, what="", n=4++as.integer(hourly))
names(dat) <- header
strTime <- paste(dat$aaaa,dat$mm,dat$gg,sep="-")
if(hourly) {
Expand Down
22 changes: 2 additions & 20 deletions R/time.functions.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,26 +21,8 @@ Ndays.in.year <- function(year,tz="Africa/Algiers") {
return(nd)
}

squeeze<- function(x) {
if(length(x)==0) {
out <- "-"
} else {
x <- sort(x,decreasing=F)
xb <- c(NA,x)[1:length(x)]
xa <- c(x,NA)[2:(1+length(x))]
ext <- (xa-x)>1 | (x-xb)>1
sel <- which(is.na(ext)|ext)
x.sel <- x[sel]
sela <- c(sel,NA)[2:(1+length(sel))]
sym <- c("-",",")[as.numeric(sela-sel==1)+1]
sym[is.na(sym)] <- ""
out <- paste(rbind(x.sel,sym),collapse="")
}
return(out)
}

tz.change <- function(time.in,tz.in="UTC",tz.out="Africa/Algiers") {
time.txt <- format(time.in, format="%Y-%m-%d %H:%M:%S")
tz.change <- function(x,tz.in="UTC",tz.out="Africa/Algiers") {
time.txt <- format(x, format="%Y-%m-%d %H:%M:%S")
time.out <- as.POSIXct(time.txt, tz=tz.in)
attributes(time.out)$tzone <- tz.out
return(time.out)
Expand Down
13 changes: 12 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,16 @@ Data fusion for air quality data
###### Authors
Lucia Paci, [Giovanni Bonafè](mailto:[email protected])

######Description
###### Description
PESCO stands for "Post-processing and Evaluation with Statistical methods of a Chemistry-transport-model Output". The package provides functions to perform data fusion for air quality data, correcting the output of a deterministic CTM with observed data, with a Trans-Gaussian Kriging approach.

###### Installation
You can install the package by downloading the tarball and (in R)
```
install.packages("/path/to/tarball/pesco_0.2.2.tar.gz", repos = NULL, type = "source")
```
Otherwise, you can install the latest version directly from GitHub
```
require(devtools)
install_github("jobonaf/pesco")
```
70 changes: 35 additions & 35 deletions TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,48 +3,48 @@ TODO

#### Datasets

* ~~observed PM10 (estra_qaria)~~
* ~~observed NO2 (estra_qaria)~~
* ~~CTM concentrations (NetCDF, one day)~~
* ~~emissions (ASCII table)~~
* ~~elevation (ASCII table)~~
* ~~population (ASCII table)~~
- [x] observed PM10 (estra_qaria)
- [x] observed NO2 (estra_qaria)
- [x] CTM concentrations (NetCDF, one day)
- [x] emissions (ASCII table)
- [x] elevation (ASCII table)
- [x] population (ASCII table)

#### Essentials

* ~~read data~~
* ~~prepare data~~
* ~~kriging~~
* ~~test the kriging~~
* ~~all-inclusive function to prepare all you need to process a day~~
* build source package
- [x] read data
- [x] prepare data
- [x] kriging
- [x] test the kriging
- [x] all-inclusive function to prepare all you need to process a day
- [ ] build source package

#### Extras

* write the output of kriging
* cross-validation
* functions to manage annual runs
* functions to calculate annual indicators
- [ ] write the output of kriging
- [ ] cross-validation
- [ ] functions to manage annual runs
- [ ] functions to calculate annual indicators

#### Documentation

* doc of functions:
* ~~aqstat.functions.Rd~~
* ~~date.functions.Rd~~
* ~~time.functions.Rd~~
* ~~char.functions.Rd~~
* ~~geo.functions.Rd~~
* read.Rd
* prepare.Rd
* daily_synthesis.Rd
* boxcox.Rd
* kriging.Rd
* interpolate.Rd
* crossval.Rd
* ~~doc of datasets~~
* ~~demo for reading data~~
* ~~demo for preparing data~~
* ~~demo for kriging~~
* demo for cross-validation
* references
* description of the theory
- [x] aqstat.functions.Rd
- [x] date.functions.Rd
- [x] time.functions.Rd
- [x] char.functions.Rd
- [x] geo.functions.Rd
- [x] read.functions.Rd
- [x] prepare.functions.Rd
- [x] daily_synthesis.Rd
- [x] boxcox.Rd
- [x] kriging.Rd
- [x] interpolate.Rd
- [ ] crossval.Rd
- [x] doc of datasets
- [x] demo for reading data
- [x] demo for preparing data
- [x] demo for kriging
- [ ] demo for cross-validation
- [ ] references
- [ ] description of the theory
Loading

0 comments on commit ce6cc8e

Please sign in to comment.