From 2263a038f289c475ec8715614291f144d5fa9c79 Mon Sep 17 00:00:00 2001 From: imohamme Date: Fri, 14 Apr 2023 16:33:47 -0400 Subject: [PATCH] V3.4.2 --- DESCRIPTION | 8 ++++---- NAMESPACE | 1 + NEWS.md | 3 +++ R/GLDASpolyCentroid.R | 2 +- R/GLDASwat.R | 2 +- R/GPM_NRT.R | 2 +- R/GPMployCentroid.R | 2 +- R/GPMswat.R | 2 +- R/NEXGDDP.R | 8 ++++---- R/NEXGDDP_CMIP6.R | 8 ++++---- inst/scripts/netrc.R | 2 +- 11 files changed, 22 insertions(+), 18 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 6c3153a..4e95435 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: NASAaccess -Version: 3.4.1 -Date: 2023-03-21 +Version: 3.4.2 +Date: 2023-04-14 Type: Package Title: Downloading and Reformatting Tool for NASA Earth Observation Data Products Authors@R: c(person("Ibrahim", "Mohammed", role = c("aut", "cre"), @@ -13,7 +13,7 @@ Description: A tool to generate gridded ascii tables and station files needed by Creating the ".netrc" file at the user machine 'Home' directory and storing the NASA GES DISC user logging information in it is needed to execute the package commands. URL: https://github.com/nasa/NASAaccess BugReports: https://github.com/nasa/NASAaccess/issues -Imports: ncdf4, stats, shapefiles, rgeos, maptools, httr, stringr, rgdal, XML, sp, utils, raster, methods +Imports: ncdf4, stats, shapefiles, rgeos, maptools, httr, stringr, rgdal, XML, sp, utils, raster, methods, getPass License: file LICENSE Encoding: UTF-8 Language: en-US @@ -25,5 +25,5 @@ Suggests: ggmap, sf, ggplot2, - getPass + codetools VignetteBuilder: knitr diff --git a/NAMESPACE b/NAMESPACE index ed4138c..274171f 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -8,6 +8,7 @@ export(GPMswat) export(NEX_GDDP_CMIP5) export(NEX_GDDP_CMIP6) import(XML) +import(getPass) import(httr) import(maptools) import(methods) diff --git a/NEWS.md b/NEWS.md index 78747f1..e66fa55 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,6 @@ +# NASAaccess 3.4.2 +* Adding getPass library in Imports. Addressing curl Certificate Verification for NEX-GDDP. + # NASAaccess 3.4.1 * no need for _netrc file creation in windows diff --git a/R/GLDASpolyCentroid.R b/R/GLDASpolyCentroid.R index 9ce2218..1f818b2 100644 --- a/R/GLDASpolyCentroid.R +++ b/R/GLDASpolyCentroid.R @@ -28,7 +28,7 @@ #' #Lower Mekong basin example #' \dontrun{GLDASpolyCentroid(Dir = "./SWAT_INPUT/", watershed = "LowerMekong.shp", #' DEM = "LowerMekong_dem.tif", start = "2015-12-1", end = "2015-12-3")} -#' @import ncdf4 httr stringr rgdal XML utils sp rgeos +#' @import ncdf4 httr stringr rgdal XML utils sp rgeos getPass #' @importFrom stats na.exclude #' @importFrom raster raster cellFromPolygon xyFromCell rowColFromCell extract #' @importFrom rgeos gCentroid diff --git a/R/GLDASwat.R b/R/GLDASwat.R index 3cc55bf..3b34531 100644 --- a/R/GLDASwat.R +++ b/R/GLDASwat.R @@ -28,7 +28,7 @@ #' #Lower Mekong basin example #' \dontrun{GLDASwat(Dir = "./SWAT_INPUT/", watershed = "LowerMekong.shp", #' DEM = "LowerMekong_dem.tif", start = "2015-12-1", end = "2015-12-3")} -#' @import ncdf4 httr stringr rgdal XML utils sp +#' @import ncdf4 httr stringr rgdal XML utils sp getPass #' @importFrom stats na.exclude #' @importFrom raster raster cellFromPolygon xyFromCell rowColFromCell extract #' @export diff --git a/R/GPM_NRT.R b/R/GPM_NRT.R index 351265a..f20c9cc 100644 --- a/R/GPM_NRT.R +++ b/R/GPM_NRT.R @@ -27,7 +27,7 @@ #' #Lower Mekong basin example #' \dontrun{GPM_NRT(Dir = "./INPUT/", watershed = "LowerMekong.shp", #' DEM = "LowerMekong_dem.tif", start = "2022-6-1", end = "2022-6-10")} -#' @import ncdf4 shapefiles rgeos maptools httr stringr rgdal XML utils sp methods +#' @import ncdf4 shapefiles rgeos maptools httr stringr rgdal XML utils sp methods getPass #' @importFrom stats na.exclude #' @importFrom raster raster cellFromPolygon xyFromCell rowColFromCell extract #' @export diff --git a/R/GPMployCentroid.R b/R/GPMployCentroid.R index 0d1078f..0f36d5f 100644 --- a/R/GPMployCentroid.R +++ b/R/GPMployCentroid.R @@ -27,7 +27,7 @@ #' #Lower Mekong basin example #' \dontrun{GPMpolyCentroid(Dir = "./SWAT_INPUT/", watershed = "LowerMekong.shp", #' DEM = "LowerMekong_dem.tif", start = "2015-12-1", end = "2015-12-3")} -#' @import ncdf4 shapefiles rgeos maptools httr stringr rgdal XML utils sp methods +#' @import ncdf4 shapefiles rgeos maptools httr stringr rgdal XML utils sp methods getPass #' @importFrom stats na.exclude #' @importFrom raster raster cellFromPolygon xyFromCell rowColFromCell extract #' @importFrom rgeos gCentroid diff --git a/R/GPMswat.R b/R/GPMswat.R index ee70209..82f1a7a 100644 --- a/R/GPMswat.R +++ b/R/GPMswat.R @@ -27,7 +27,7 @@ #' #Lower Mekong basin example #' \dontrun{GPMswat(Dir = "./SWAT_INPUT/", watershed = "LowerMekong.shp", #' DEM = "LowerMekong_dem.tif", start = "2015-12-1", end = "2015-12-3")} -#' @import ncdf4 shapefiles rgeos maptools httr stringr rgdal XML utils sp methods +#' @import ncdf4 shapefiles rgeos maptools httr stringr rgdal XML utils sp methods getPass #' @importFrom stats na.exclude #' @importFrom raster raster cellFromPolygon xyFromCell rowColFromCell extract #' @export diff --git a/R/NEXGDDP.R b/R/NEXGDDP.R index 18ca414..b83a0ba 100644 --- a/R/NEXGDDP.R +++ b/R/NEXGDDP.R @@ -39,7 +39,7 @@ #' \dontrun{NEX_GDDP_CMIP5(Dir = "./INPUT/", watershed = "LowerMekong.shp", #' DEM = "LowerMekong_dem.tif", start = "2060-12-1", end = "2060-12-3", #' model = 'IPSL-CM5A-MR', type = 'pr', slice = 'rcp85')} -#' @import ncdf4 shapefiles rgeos maptools httr stringr rgdal XML utils sp methods +#' @import ncdf4 shapefiles rgeos maptools httr stringr rgdal XML utils sp methods getPass #' @importFrom stats na.exclude #' @importFrom raster raster cellFromPolygon xyFromCell rowColFromCell extract #' @export @@ -139,7 +139,7 @@ NEX_GDDP_CMIP5=function(Dir='./INPUT/', watershed ='LowerMekong.shp', DEM = 'Low filename.start <- paste(paste(type.start,'day','BCSD',slice,'r1i1p1',model,format(time_period[1],"%Y"),sep = '_'),'.nc',sep="") myurl <- paste(ifelse(isTRUE(type=="pr")==TRUE,ftp,ftp_min),filename.start,sep = '') - utils::download.file(quiet = T, method = 'curl', url = myurl, destfile = paste('./temp/',filename.start,sep= ''), mode = 'wb', extra = '-L') + utils::download.file(quiet = T, method = 'curl', url = myurl, destfile = paste('./temp/',filename.start,sep= ''), mode = 'wb', extra = '-k') test2<-file.info(paste('./temp/',filename.start,sep= ''))$size stopifnot('The NEX GDDP server is temporarily unable to service your request due to maintenance downtime or capacity problems. Please try again later.' = test2 > 7.0e6) @@ -222,7 +222,7 @@ NEX_GDDP_CMIP5=function(Dir='./INPUT/', watershed ='LowerMekong.shp', DEM = 'Low myurl <- paste(ftp,filename,sep = '') # downloading file if(dir.exists('./temp/')==FALSE){dir.create('./temp/')} - if(file.exists(paste('./temp/',filename,sep= ''))==FALSE){utils::download.file(quiet = T, method = 'curl', url = myurl, destfile = paste('./temp/',filename,sep= ''), mode = 'wb', extra = '-L')} + if(file.exists(paste('./temp/',filename,sep= ''))==FALSE){utils::download.file(quiet = T, method = 'curl', url = myurl, destfile = paste('./temp/',filename,sep= ''), mode = 'wb', extra = '-k')} # Reading the ncdf file test3<-file.info(paste('./temp/',filename,sep= ''))$size stopifnot('The NEX GDDP server is temporarily unable to service your request due to maintenance downtime or capacity problems. Please try again later.' = test3 > 6.0e6) @@ -276,7 +276,7 @@ NEX_GDDP_CMIP5=function(Dir='./INPUT/', watershed ='LowerMekong.shp', DEM = 'Low myurl_max <- paste(ftp_max,filename_max,sep = '') # downloading file if(dir.exists('./temp/')==FALSE){dir.create('./temp/')} - if(file.exists(paste('./temp/',filename_min,sep= ''))==FALSE|file.exists(paste('./temp/',filename_max,sep= ''))==FALSE){utils::download.file(quiet = T, method = 'curl', url = myurl_min, destfile = paste('./temp/',filename_min,sep= ''), mode = 'wb', extra = '-L');utils::download.file(quiet = T, method = 'curl', url = myurl_max, destfile = paste('./temp/',filename_max,sep= ''), mode = 'wb', extra = '-L')} + if(file.exists(paste('./temp/',filename_min,sep= ''))==FALSE|file.exists(paste('./temp/',filename_max,sep= ''))==FALSE){utils::download.file(quiet = T, method = 'curl', url = myurl_min, destfile = paste('./temp/',filename_min,sep= ''), mode = 'wb', extra = '-k');utils::download.file(quiet = T, method = 'curl', url = myurl_max, destfile = paste('./temp/',filename_max,sep= ''), mode = 'wb', extra = '-k')} # Reading the tasmin ncdf file test4<-file.info(paste('./temp/',filename_min,sep= ''))$size stopifnot('The NEX GDDP server is temporarily unable to service your request due to maintenance downtime or capacity problems. Please try again later.' = test4 > 6.0e6) diff --git a/R/NEXGDDP_CMIP6.R b/R/NEXGDDP_CMIP6.R index a42025c..2b8911a 100644 --- a/R/NEXGDDP_CMIP6.R +++ b/R/NEXGDDP_CMIP6.R @@ -48,7 +48,7 @@ #' \dontrun{NEX_GDDP_CMIP6(Dir = "./INPUT/", watershed = "LowerMekong.shp", #' DEM = "LowerMekong_dem.tif", start = "2060-12-1", end = "2060-12-3", #' model = 'MIROC6', type = 'pr', slice = 'ssp245')} -#' @import ncdf4 shapefiles rgeos maptools httr stringr rgdal XML utils sp methods +#' @import ncdf4 shapefiles rgeos maptools httr stringr rgdal XML utils sp methods getPass #' @importFrom stats na.exclude #' @importFrom raster raster cellFromPolygon xyFromCell rowColFromCell extract #' @export @@ -152,7 +152,7 @@ NEX_GDDP_CMIP6=function(Dir='./INPUT/', watershed ='LowerMekong.shp', DEM = 'Low # Using dummy date and file info for a file in the NEX-GDDP-CMIP6 dataset # downloading one file if(dir.exists('./temp/')==FALSE){dir.create('./temp/')} - utils::download.file(quiet = T, method = 'curl', url = 'https://ds.nccs.nasa.gov/thredds/ncss/AMES/NEX/GDDP-CMIP6/ACCESS-CM2/ssp585/r1i1p1f1/tasmax/tasmax_day_ACCESS-CM2_ssp585_r1i1p1f1_gn_2015.nc?var=tasmax&disableLLSubset=on&disableProjSubset=on&horizStride=1&time_start=2015-09-01T12%3A00%3A00Z&time_end=2015-09-02T12%3A00%3A00Z&timeStride=1', destfile = paste('./temp/','tasmax_day_ssp585_r1i1p1f1_ACCESS-CM2_2015.nc',sep= ''), mode = 'wb', extra = '-L') + utils::download.file(quiet = T, method = 'curl', url = 'https://ds.nccs.nasa.gov/thredds/ncss/AMES/NEX/GDDP-CMIP6/ACCESS-CM2/ssp585/r1i1p1f1/tasmax/tasmax_day_ACCESS-CM2_ssp585_r1i1p1f1_gn_2015.nc?var=tasmax&disableLLSubset=on&disableProjSubset=on&horizStride=1&time_start=2015-09-01T12%3A00%3A00Z&time_end=2015-09-02T12%3A00%3A00Z&timeStride=1', destfile = paste('./temp/','tasmax_day_ssp585_r1i1p1f1_ACCESS-CM2_2015.nc',sep= ''), mode = 'wb', extra = '-k') test2<-file.info(paste('./temp/','tasmax_day_ssp585_r1i1p1f1_ACCESS-CM2_2015.nc',sep= ''))$size stopifnot('The NEX GDDP server is temporarily unable to service your request due to maintenance downtime or capacity problems. Please try again later.' = test2 > 6.0e6) #reading ncdf file @@ -232,7 +232,7 @@ NEX_GDDP_CMIP6=function(Dir='./INPUT/', watershed ='LowerMekong.shp', DEM = 'Low # downloading file if(dir.exists('./temp/')==FALSE){dir.create('./temp/')} - if(file.exists(paste('./temp/',filename,sep= ''))==FALSE){utils::download.file(quiet = T, method = 'curl', url = myurl, destfile = paste('./temp/',filename,sep= ''), mode = 'wb', extra = '-L')} + if(file.exists(paste('./temp/',filename,sep= ''))==FALSE){utils::download.file(quiet = T, method = 'curl', url = myurl, destfile = paste('./temp/',filename,sep= ''), mode = 'wb', extra = '-k')} # Reading the ncdf file test3<-file.info(paste('./temp/',filename,sep= ''))$size stopifnot('The NEX GDDP server is temporarily unable to service your request due to maintenance downtime or capacity problems. Please try again later.' = test3 > 3.0e6) @@ -275,7 +275,7 @@ NEX_GDDP_CMIP6=function(Dir='./INPUT/', watershed ='LowerMekong.shp', DEM = 'Low myurl_max <- paste(ftp_max,timeyear,'.nc?','var=',type,'max','&disableLLSubset=on&disableProjSubset=on&horizStride=1&time_start=',as.character(timestart),'T12%3A00%3A00Z&time_duration=P1D','&timeStride=1',sep = '') # downloading file if(dir.exists('./temp/')==FALSE){dir.create('./temp/')} - if(file.exists(paste('./temp/',filename_min,sep= ''))==FALSE|file.exists(paste('./temp/',filename_max,sep= ''))==FALSE){utils::download.file(quiet = T, method = 'curl', url = myurl_min, destfile = paste('./temp/',filename_min,sep= ''), mode = 'wb', extra = '-L');utils::download.file(quiet = T, method = 'curl', url = myurl_max, destfile = paste('./temp/',filename_max,sep= ''), mode = 'wb', extra = '-L')} + if(file.exists(paste('./temp/',filename_min,sep= ''))==FALSE|file.exists(paste('./temp/',filename_max,sep= ''))==FALSE){utils::download.file(quiet = T, method = 'curl', url = myurl_min, destfile = paste('./temp/',filename_min,sep= ''), mode = 'wb', extra = '-k');utils::download.file(quiet = T, method = 'curl', url = myurl_max, destfile = paste('./temp/',filename_max,sep= ''), mode = 'wb', extra = '-k')} # Reading the tmin ncdf file test4<-file.info(paste('./temp/',filename_min,sep= ''))$size stopifnot('The NEX GDDP server is temporarily unable to service your request due to maintenance downtime or capacity problems. Please try again later.' = test4 > 3.0e6) diff --git a/inst/scripts/netrc.R b/inst/scripts/netrc.R index 115d453..599fc65 100644 --- a/inst/scripts/netrc.R +++ b/inst/scripts/netrc.R @@ -1,5 +1,5 @@ ###code to save user credentials into netrc file -library(getPass) +#' @import getPass repeat {