Skip to content

Commit c1a09b4

Browse files
committed
update precip data
1 parent 4a0dfd1 commit c1a09b4

23 files changed

+1906
-836
lines changed

DESCRIPTION

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
Package: SardineForecast
22
Type: Package
33
Title: Indian Oil Sardine Data, Code and References for Papers on Forecasting
4-
Version: 1.9
5-
Date: 2019-11-20
4+
Version: 1.10
5+
Date: 2020-04-11
66
Depends:
77
R (>= 2.15.0),
88
stringr,
@@ -16,7 +16,8 @@ Depends:
1616
mapdata,
1717
MARSS,
1818
ggplot2,
19-
grid
19+
grid,
20+
here
2021
Imports: Rdpack
2122
Author: Eli Holmes, NOAA, Seattle, USA
2223
Maintainer: Elizabeth Holmes - NOAA Federal <eli.holmes@noaa.gov>
@@ -28,6 +29,6 @@ ByteCompile: TRUE
2829
RdMacros: Rdpack
2930
Suggests: XML, RCurl, httr, ncdf4
3031
VignetteBuilder: knitr
31-
RoxygenNote: 7.0.2
32+
RoxygenNote: 7.1.0
3233
Remotes: github::rstudio/rmarkdown
3334
Encoding: UTF-8

R/data.R

Lines changed: 34 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,12 @@
9393
#' @description Three precipition datasets off the SW coast of India. Two are satellite derived and one is based on land gauges.
9494
#'
9595
#' @details
96-
#' The National Climatic Data Center provides basic information on the GPCP Precipitation dataset. The dataset consists of monthly precipitation estimates (average mm/day) from January 1979 to the present. The precipitation estimates merge several satellite and in situ sources into a final product. Data are provided on a 2.5 degree grid. The GPCP Precipitation data are provided by the NOAA/NCEI Global Precipitation Climatology Project and were downloaded from \url{https://www.ncei.noaa.gov/data/global-precipitation-climatology-project-gpcp-monthly}. Two boxes were defined, one off the Kerala coast and one off the Karnataka coast, and the average values of all grid points within these boxes were used.
96+
#' The National Climatic Data Center provides basic information on the GPCP Precipitation dataset.
97+
#' The dataset consists of monthly precipitation estimates (average mm/day) from January 1979 to
98+
#' the present. The precipitation estimates merge several satellite and in situ sources into a
99+
#' final product. Data are provided on a 2.5 degree grid. The GPCP Precipitation data are
100+
#' provided by the NOAA/NCEI Global Precipitation Climatology Project and were downloaded from
101+
#' \url{https://www.ncei.noaa.gov/data/global-precipitation-climatology-project-gpcp-monthly}. Two boxes were defined, one off the Kerala coast and one off the Karnataka coast, and the average values of all grid points within these boxes were used.
97102
#' \preformatted{
98103
#' The boxes are
99104
#' Kerala Lat(8.75, 11.25), Lon(73.25, 75.75)
@@ -108,9 +113,9 @@
108113
#' \describe{
109114
#' \item{Year}{}
110115
#' \item{Month}{}
111-
#' \item{precip.gpcp.kerala}{Monthly GPCP precipitation in the box off the Kerala coast.}
112-
#' \item{precip.gpcp.karnataka}{Monthly GPCP precipitation in the box off the Karnataka coast.}
113-
#' \item{PrecipTRMM}{Monthly precipitation estimates from the Tropical Rainfall Measuring Mission (TRMM). Data are averaged in the boxes used for the other satellite data.}
116+
#' \item{precip.gpcp.kerala}{Monthly GPCP precipitation in the box off the Kerala coast. Units are average mm/day.}
117+
#' \item{precip.gpcp.karnataka}{Monthly GPCP precipitation in the box off the Karnataka coast. Units are average mm/day.}
118+
#' \item{PrecipTRMM}{Monthly precipitation estimates from the Tropical Rainfall Measuring Mission (TRMM). Data are averaged in the boxes 1 to 13 used for the other satellite data.}
114119
#' \item{Precip.Kerala}{Monthly precipitation (mm) from landgauges.}
115120
#' }
116121
#'
@@ -150,10 +155,10 @@
150155

151156
#' Sea surface temperature data from remote-sensing products
152157
#'
153-
#' @description The SST satellite data were downloaded from the NOAA ERDDAP server using R Mendels
154-
#' \code{rerddapXtracto} R package which uses the ropensci \code{rerddap} R package. The R code used
158+
#' @description The SST satellite data were downloaded from the NOAA ERDDAP server using Roy Mendelssohn's
159+
#' \strong{rerddapXtracto} R package which uses the ropensci\strong{rerddap} R package available on CRAN. The R code used
155160
#' to download the data is in the \code{extdata/get_satelite_data} folder. See examples for how to find
156-
#' the file.
161+
#' the file. Units are degree Celcius.
157162
#'
158163
#' @details
159164
#' For 1981 to 2003, We used the Pathfinder Version 5.2
@@ -181,7 +186,7 @@
181186
#' \describe{
182187
#' \item{Year}{The year}
183188
#' \item{Month}{The month}
184-
#' \item{SST.1 to SST.13}{Average monthly SST averaged over boxes 1 to 13.}
189+
#' \item{SST.1 to SST.13}{Average monthly SST averaged over boxes 1 to 13. Units are degree Celcius.}
185190
#' }
186191
#'
187192
#' @references
@@ -197,6 +202,10 @@
197202
#'
198203
#' \insertRef{Waltonetal1998}{SardineForecast}
199204
#'
205+
#' \insertRef{rerddap}{SardineForecast}
206+
#'
207+
#' \insertRef{rerddapXtracto}{SardineForecast}
208+
#'
200209
#' @examples
201210
#' \dontrun{
202211
#' # Show the R code that downloaded the data
@@ -213,8 +222,9 @@
213222

214223
#' Chlorophyll-a data from remote-sensing products
215224
#'
216-
#' @description The CHL satellite data were downloaded from the NOAA ERDDAP server using R Mendels
217-
#' \code{rerddapXtracto} R package which uses the ropensci \code{rerddap} R package. The R code used
225+
#' @description The CHL satellite data (mg/m$^3$) were downloaded from the NOAA ERDDAP server using
226+
#' Roy Mendelssohn's
227+
#' \strong{rerddapXtracto} R package which uses the ropensci\strong{rerddap} R packages available on CRAN. The R code used
218228
#' to download the data is in the \code{extdata/get_satelite_data} folder. See examples for how to find
219229
#' the file.
220230
#'
@@ -224,7 +234,7 @@
224234
#' Ocean Biology Processing Group in the Ocean Ecology Laboratory
225235
#' at the NASA Goddard Space Flight Center.
226236
#'
227-
#' For 1997 to 2002, we used the Chlorophyll-a 2014.0 Reprocessing (R2014.0) product
237+
#' For September 1997 to 2002, we used the Chlorophyll-a 2014.0 Reprocessing (R2014.0) product
228238
#' from the Sea-viewing Wide Field-of-view
229239
#' Sensor (SeaWiFS) on the Orbview-2 satellite. These data are on a 0.1 degree grid. See reference below.
230240
#'
@@ -248,7 +258,7 @@
248258
#' \describe{
249259
#' \item{Year}{The year}
250260
#' \item{Month}{The month}
251-
#' \item{CHL.1 to CHL.13}{Average monthly CHL averaged over boxes 1 to 13.}
261+
#' \item{CHL.1 to CHL.13}{Average monthly CHL averaged over boxes 1 to 13. Units are mg/m$^3$.}
252262
#' }
253263
#'
254264
#' @references
@@ -263,8 +273,13 @@
263273
#' Spectroradiometer (MODIS) Aqua Chlorophyll Data; 2014 Reprocessing.
264274
#' NASA OB.DAAC, Greenbelt, MD, USA. \url{https://dx.doi.org/10.5067/AQUA/MODIS/L3M/CHL/2014}
265275
#'
276+
#'
266277
#' \insertRef{Huetal2012}{SardineForecast}
267278
#'
279+
#' \insertRef{rerddap}{SardineForecast}
280+
#'
281+
#' \insertRef{rerddapXtracto}{SardineForecast}
282+
#'
268283
#'
269284
#' @examples
270285
#' \dontrun{
@@ -431,8 +446,8 @@
431446
#' @details
432447
#'
433448
#' The Wind-based monthly upwelling indices were downloaded from the NOAA ERDDAP server. The first is
434-
#' 1999-2009 on a 0.125 degree grid. The second is 2009 to present on a 0.25 degree grid.
435-
#' and the second is See
449+
#' 1999-2009 on a 0.125 degree grid. The second is 2009 to present on a 0.25 degree grid. Units are m/s.
450+
#' See
436451
#' \url{https://coastwatch.pfeg.noaa.gov/erddap/info/erdQSstressmday/index.html} and
437452
#' \url{https://coastwatch.pfeg.noaa.gov/erddap/info/erdQAstressmday/index.html}.
438453
#'
@@ -446,8 +461,8 @@
446461
#'
447462
#' The Bakun index (The Bakun 1973) is calculated based upon Ekman's theory of mass transport
448463
#' due to wind stress. The index is computed from the ektrx and ektry, which
449-
#' are the x- and y- components of Ekman Transport obtained from the ERDDAP link
450-
#' below, and coast_angle is 158 degrees for the India west coast near Kochi.
464+
#' are the x- and y- components of Ekman Transport (kg m$^{-1}$ s$^-1$) obtained from the ERDDAP link
465+
#' below, and coast_angle is 158 degrees for the India west coast near Kochi (74.5E 11.5N coast angle 158 degrees).
451466
#' \url{https://coastwatch.pfeg.noaa.gov/erddap/info/erdlasFnWPr/index.html}.
452467
#' The function to compute the Bakun index is
453468
#' (from \url{https://oceanview.pfeg.noaa.gov/products/upwelling/bakun})
@@ -473,9 +488,9 @@
473488
#' \describe{
474489
#' \item{Year}{The year}
475490
#' \item{Month}{The month}
476-
#' \item{Wind.UPW.1 to Wind.UPW.5}{Average monthly UPW averaged over boxes 1 to 5.}
477-
#' \item{SST.UPW.1 to SST.UPW.5}{Average monthly SST differential averaged over boxes 1 to 5.}
478-
#' \item{Bakun.UPW}{Average monthly SST differential averaged over boxes 1 to 5.}
491+
#' \item{Wind.UPW.1 to Wind.UPW.5}{Average monthly wind-based upwelling index averaged over boxes 1 to 5. Units are m/s.}
492+
#' \item{SST.UPW.1 to SST.UPW.5}{Average monthly SST differential averaged over boxes 1 to 5. Units are degree Celcius.}
493+
#' \item{Bakun.UPW}{Bakun index at 74.5E 11.5N (near Kochi, India) at a coast angle of 158 degrees. Units are kg m$^{-1}$ s$^-1$.}
479494
#' }
480495
#'
481496
#' @references

R/loogam.R

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
#' loogam(m)$MAE
1919
loogam <- function(mod, k=1, n=100, LOO=FALSE){
2020
dat1 <- mod$model
21-
dat2 <- mod$model
21+
dat2 <- mod$model # needed because gam and lm deal with predict data differently
2222
# to allow it to work on models with offset
2323
if(any(stringr::str_detect(colnames(dat1),"offset"))){
2424
a <- colnames(dat1)
@@ -27,6 +27,22 @@ loogam <- function(mod, k=1, n=100, LOO=FALSE){
2727
colnames(dat1) <- a
2828
if(class(mod)[1]=="lm") colnames(dat2) <- a
2929
}
30+
if(any(stringr::str_detect(colnames(dat1),"poly"))){
31+
a <- colnames(dat1)
32+
test1 <- stringr::str_detect(colnames(dat1),"poly")
33+
test2 <- stringr::str_detect(colnames(dat1),"raw = TRUE")
34+
if(!isTRUE(all.equal(test1, test2))) stop("If poly used in loogam model, then raw=TRUE must be used")
35+
for(i in which(test1 & test2)){
36+
tmp <- dat1[,i][,1, drop=FALSE]
37+
thename <- a[i]
38+
thename <- stringr::str_split(thename,"[(]")[[1]][2]
39+
thename <- stringr::str_split(thename, ",")[[1]][1]
40+
colnames(tmp) <- thename
41+
dat1 <- cbind(dat1, tmp)
42+
if(class(mod)[1]=="lm") dat2 <- cbind(dat2, tmp)
43+
}
44+
}
45+
3046
if(class(mod)[1]=="gam") mod.formula <- mod$formula
3147
if(class(mod)[1]=="lm") mod.formula <- mod$terms
3248
pred <- actual <- aics <- aiccs <- r2s <- loos <- loomds <- NULL

data/precip.rdata

84 Bytes
Binary file not shown.

data/seio_covariates_mon.rdata

56.1 KB
Binary file not shown.

data/seio_covariates_qtr.rdata

22.7 KB
Binary file not shown.

inst/REFERENCES.bib

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,23 @@ @article{Raja1969
125125
type = {Journal Article}
126126
}
127127

128+
129+
@Manual{rerddap,
130+
title = {rerddap: General Purpose Client for 'ERDDAP' Servers},
131+
author = {Scott Chamberlain},
132+
year = {2019},
133+
note = {R package version 0.6.5},
134+
url = {https://CRAN.R-project.org/package=rerddap},
135+
}
136+
137+
@Manual{rerddapXtracto,
138+
title = {rerddapXtracto: Extracts Environmental Data from 'ERDDAP' Web Services},
139+
author = {Roy Mendelssohn},
140+
year = {2020},
141+
note = {R package version 0.4.7},
142+
url = {https://CRAN.R-project.org/package=rerddapXtracto},
143+
}
144+
128145
@article{SajiYamagata2003,
129146
author = {Saji, N. H. and Yamagata, T.},
130147
title = {Possible impacts of {I}ndian {O}cean {D}ipole mode events on global climate},

inst/extdata/raw data files and code/create_monthly_covariates_csv.r

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@ covfiles=c(
77
"precipitation_gpcp.csv",
88
"precipitation_TRMM.csv",
99
"enso.csv",
10-
"precip_kerala.csv")
11-
current.year = as.numeric(format(Sys.Date(),"%Y"))
10+
"precip_kerala.csv",
11+
"tide_mon.csv")
12+
current.year = 2019
1213
years=1956:current.year
1314

1415
#set up the data frame

inst/extdata/raw data files and code/create_precip_kerala_csv.r

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,5 @@ for(yr in years){
1515
}
1616
}
1717
fil="precip_kerala.csv"
18-
filename=read.csv(paste("inst/extdata/raw data files and code/",fil,sep=""))
18+
filename=paste("inst/extdata/raw data files and code/",fil,sep="")
1919
write.csv(precip_kerala, file=filename,row.names=FALSE)

0 commit comments

Comments
 (0)