Closed dankelley closed 2 years ago
PS check out the wave height in the last page of the second plot. I mislabelled it as m/s but of course it's m. And it is over 15m, maybe 18m. Note that 3m is the height of a story in a building. Imagine standing at the bottom of a building that tall looking up. And then imagine you're in a sailboat.
I think we have the dod.ctd()
system set up well enough to copy it for this purpose. Remember, the only goal is to download the file, not to read it, so we don't need to do any more than figure out some URL structures. I'd start by making it work on the Halifax buoy and the Banqureau (sp?) one, too.
@AnnieHow -- I unassigned myself and JH, since I think you can do this easily. (We can Z if you want to discuss -- you know my timetable.)
For the Canadian buoys, I am guessing the URLs for the zipfiles will follow a pattern like below
https://www.meds-sdmm.dfo-mpo.gc.ca/alphapro/wave/waveshare/csvData/c44258_csv.zip
https://www.meds-sdmm.dfo-mpo.gc.ca/alphapro/wave/waveshare/csvData/c44139_csv.zip
since those are two files I've been reading for the past few weeks.
Perhaps the code can incorporate something like below
if (program == "MEDS") {
server <- "https://www.meds-sdmm.dfo-mpo.gc.ca/alphapro/wave/waveshare/csvData"
url <- paste0(server, "/c", ID, "_csv.zip")
zipfile <- paste0("c", ID, "_csv.zip")
download.file(url, zipfile)
unzip(zipfile)
# NOTE: we should delete the zipfile too; see ?unlink
return(paste0("c", ID, ".csv"))
}
where I'm suggesting a program name, given that this is the common abbreviation for the agency is Canada's Marine Environmental Data Service.
Also, as a convenience, I think some buoy names should be handled also, like if the user says ID="Banquereau Bank"
then ID
should be changed to "44139"
. See https://www.meds-sdmm.dfo-mpo.gc.ca/isdm-gdsi/waves-vagues/data-donnees/index-eng.asp#wavetable for lists of buoy names.
Note: it is convenient to set up nicknames using list
s, e.g.
> l <- list("dan"="d", "annie"="a")
> names(l)[match("d",l)]
[1] "dan"
@dankelley I've been working on this and running into errors with the package unzip
. My RStudio says it's not available for my version of R. Are there work arounds for this?
Hm, that's not good, because it might apply to other users as well. Maybe try web-searching on "R unzip file" or something like that, to see if there's another package. I can Z if that would help.
I got to https://www.rdocumentation.org/packages/utils/versions/3.6.2/topics/unzip and it tells me that unzip
is in the utils
package, so maybe try install.packages("utils")
will work?]
We will need to declare a dependency on utils within the DESCRIPTION file.
Also, I see https://www.rdocumentation.org/packages/base/versions/3.6.2/topics/connections which has a function we can use that doesn't require more than base
(which is always available).
@dankelley Utils is already depended on in dod.buoy for download.file
so that's totally fine for unzip
! I misread a Check error and thought it wanted the package unzip added- not the function! Sorry Dan!!
No worries.
Latest updates to new dod.buoy
function can be seen in commit 2c0dff7a5dc3ad8f8112e0241f29da1ade837468. Names will continue to be added. Closing this!
Possibly it would be along the
hurl
parts of the attached.PS. the attached R file tries to download also recent data, which I don't think we want -- at least not to start with. It also plots some stuff, which is possibly of interest for a vignette ... or, it will be when they resume streaming data into the historical parts of their database. I see in the PDFs created by the attached that both of these buoys stopped getting entries in the historical stream. Maybe there's a computer somewhere in Halifax that is supposed to do this, but that needs to be restarted when the power comes back on. Sheesh, what's with these hurricanes? Don't they respect anything?
edit: oh, it's only the Halifax buoy that stopped on Sep 22. I blame Damien Rice for my error.
buoy2.zip