Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Function "get.env" from -dev branch seems to throw errors when trying to download oisst data. #70

Open
tomwhorton opened this issue Jun 24, 2022 · 1 comment

Comments

@tomwhorton
Copy link

Function "get.env" from -dev branch seems to throw errors when trying to download oisst data.

devtools::install_github('camrinbraun/HMMoce', ref='dev')
library(HMMoce)

cat("\014")
rm(list=ls())

dates <- seq(as.Date("2020-01-01"),as.Date("2020-01-20"),"days")
sp.lim <- list(lonmin = -50, lonmax = 25, latmin = 0, latmax = 60)
sst.dir <- dir.create(paste0(getwd(),"/test"))
get.env(dates, filename='oisst', type = 'sst', sst.type='oi', spatLim = sp.lim, save.dir = sst.dir) # errors
"Error in setwd(dir) : character argument expected"
get.env(dates, filename='hycom', type = 'hycom', spatLim = sp.lim, save.dir = sst.dir) # works

@bwwolfe
Copy link

bwwolfe commented Jun 25, 2022

this: sst.dir <- dir.create(paste0(getwd(),"/test"))

is probably returning a logical class. To create the character string to indicate the directory for get.env() to store the downloaded sst files, remove the dir.create() call: sst.dir <- paste0(getwd(),"/test")

dir.create() only needed to create the directory described by that path in the file system, by using the assignment arrow you are getting what is usually a invisible logical vector that indicates if the directory was successfully created.

Personally I set up the folders and removed all the dir.create() calls, because the function temporarily changes your working directory and apparently doesn't change it back if you hit an error, then especially with dir.create(..., recursive = TRUE) as in the vignette you can quickly end up with 10+ additional levels of directories when trying to download environmental data. (or wrap them in if(!dir.exists(path)) { }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants