millerlp / rtide

R package to calculate tide heights
https://poissonconsulting.github.io/rtide/
GNU General Public License v3.0
14 stars 4 forks source link

Unable to access San Francisco Bay tides #10

Closed j-sadowski closed 7 years ago

j-sadowski commented 7 years ago

The San Francisco (Golden Gate) station is the harmonic station for a few places in N. California. I think it matches up to the "San Francisco Bay, San Francisco, California" station in the tide_stations() list.

However, when I try to access the tidal heights for that particular station this error message keeps popping up:

Error in `$<-.data.frame`(`*tmp*`, "TideHeight", value = c(7.8027656496034,  : 
  replacement has 2 rows, data has 1
In addition: Warning message:
In h$Node$Speed * (hours_year(d$DateTime) - h$Station$Hours) :
  longer object length is not a multiple of shorter object length

The code below works for other stations such as "Drakes Bay, Point Reyes, California". I wonder if this is a problem with the harmonics on the "San Francisco Bay, San Francisco, California" station?

See code below:

library(rtide)  
site  = tide_stations(stations='San Francisco')[11]  #the 11th station in this list
begin = as.Date('2016-12-01')
end   = as.Date('2016-12-05')
dat = tide_height(stations=site, from = begin, to = end, minutes = 60, tz ='PST8PDT')

#alternatively you can choose it as the 32nd California station, either way it doesn't work
#dat = tide_height(stations=tide_stations('California')[32], from = begin, to = end, minutes = 60, tz ='PST8PDT')
joethorley commented 7 years ago

Thanks for the bug report.

You are absolutely right.

I have just fixed the issue and pushed it to the master branch of GitHub.

FWIW the issue was arising because there is site "San Francisco, San Francisco Bay, California" which also matches site "North Point, Pier 41, San Francisco, San Francisco Bay, California". Now the call tide_stations(stations='San Francisco Bay, San Francisco, California') will give you the tide heights for both stations. To only get the tide heights for the first station use tide_stations(stations='^San Francisco Bay, San Francisco, California$').

j-sadowski commented 7 years ago

Ah OK that makes sense. Thanks for the quick response.