ropensci / rerddap

R client for working with ERDDAP servers
https://docs.ropensci.org/rerddap
Other
40 stars 14 forks source link

Errors using rxtracto #107

Closed AlexMcInturf closed 1 year ago

AlexMcInturf commented 1 year ago

Hello -

I'm trying to use rxtracto to assign multiple environmental variables to 200,000+ data points. I was able to get rxtracto to run on smaller subsets of the data; however, I keep encountering the following error while trying to access a few of the datasets.

zIndex[1] <- which.min(abs(extract[[5]] - zmin)) : replacement has length zero

I have tried to divvy up the data further to identify which row(s) might be causing this error, but the code works fine on the smaller subsets (1-100 points) regardless of which points are selected, but not the entire group (1-2000 points). Also, this code has worked for most points so far in the data. Because I have so many, I'd like to figure out the broader issue and/or a workaround.

My code is here for reference:

sshInfo <- rerddap::info('erdNavgem05D500mb') xyt.ssh <- xyt[xyt$t >"2013-02-16",] xyt.ssh <- xyt.ssh ssh <- rxtracto(sshInfo, parameter = 'geop_ht_isobaric', xcoord = xyt.ssh$x, ycoord = xyt.ssh$y, tcoord = xyt.ssh$t, zcoord = xyt.ssh$i, zName = "isobaric", xlen = 0.5, ylen = 0.5, progress_bar=T) sshDat <- as.data.frame(cbind("id" = xyt.ssh$id, "MeanSSH" = ssh$mean geop_ht_isobaric, "StDevSSH" = ssh$stdev geop_ht_isobaric))

Thanks!

rmendels commented 1 year ago

@AlexMcInturf Could you do the following when you have a chance. Find one of the datasets that has been failing, the smaller the better. Run it with verbose=TRUE. From that you should be able to figure out about where it failed. Send me the four or five x,y,t values around that, or if not too large just send me the data. I need to be able to run any problems in a debugger, and to reproduce your problem.

AlexMcInturf commented 1 year ago

Thanks for getting back to me so quickly! The data causing the issue is attached.

Alexandra G. McInturf, PhD (she/her) CICOES https://cicoes.uw.edu/education/postdoc-program/ Postdoctoral Fellow Big Fish Lab https://marineresearch.oregonstate.edu/big-fish Oregon State University

@. @.> @. @.> https://alexandramcinturf.squarespace.com https://alexandramcinturf.squarespace.com/

On Dec 3, 2022, at 18:40, Roy Mendelssohn @.***> wrote:

@AlexMcInturf https://github.com/AlexMcInturf Could you do the following when you have a chance. Find one of the datasets that has been failing, the smaller the better. Run it with verbose=TRUE. From that you should be able to figure out about where it failed. Send me the four or five x,y,t values around that, or if not too large just send me the data. I need to be able to run any problems in a debugger, and to reproduce your problem.

— Reply to this email directly, view it on GitHub https://github.com/ropensci/rerddap/issues/107#issuecomment-1336306297, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEDQEHQNVHOK6AD6GZFJQMTWLQACZANCNFSM6AAAAAASTCFICM. You are receiving this because you were mentioned.

rmendels commented 1 year ago

@AlexMcInturf I must be missing something, Don't see an attached file.

rmendels commented 1 year ago

@AlexMcInturf And if it is easier email directly to me, roy.mendelssohn@noaa.gov

rmendels commented 1 year ago

@AlexMcInturf - Okay the problem is this line:

"2593",50164,0.03635012,0.03635012,75.19537,2013-05-27,0,500

when you +- the "radius" with 0.5, it puts the longitude value negative. That is something I try to check for, but clearly am failing on this one. Should I find the fix, it would only mean the function would stop right at the beginning. You can see this if you set "xlen = 0.08" and it will run. Note xlen can be a vector. So what you can do for now is making certain that (x +- (xlen/2)) and (y +- (yen/2)) are within the datasets bounds, if not, change that particular xlen so the it is within the dataset. (and yes you might not think 0.08 would work but it is an interaction with rerddap::griddap trying to set up the proper call and what ERDDAP sees - but the safest way is to do as described above).

HTH