Skip to content

Commit

Permalink
Merge pull request #113 from JuliaOcean/v0p2p7e
Browse files Browse the repository at this point in the history
allow non numeric ID for NOAAbuoy, fix notebook (till v0.2.7 released)
  • Loading branch information
gaelforget authored Oct 7, 2024
2 parents ca0ac07 + f6478d8 commit 2208ae4
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 9 deletions.
23 changes: 18 additions & 5 deletions examples/Buoy_NWP_NOAA.jl
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,18 @@ md"""## Code and Data
# ╔═╡ db662fb4-7413-11ec-1af6-43b18c0c15a9
begin
#See https://www.ndbc.noaa.gov/
stations=[41046, 44065,
31005, 41047, 41117, 42058, 44027, 44084, 45002, 45136, 45164,
45206, 46028, 46077, 46146, 46237, 46277, 51208, 62121, 64045]
all_stations=NOAA.list_realtime(ext=:txt)
n=Int(floor.(length(all_stations)/10))
stations=all_stations[n:n:length(all_stations)]

#temporary fix
tmp_stations=[try
parse(Int,sta)
catch
0
end for sta in stations]
stations=tmp_stations[tmp_stations.!==0]

NOAA.download(stations)
"Done with downloading data"
end
Expand Down Expand Up @@ -89,6 +98,9 @@ md"""
- `Variable Units. :` $(buoy.units[var])
- `Variable Description :` $(buoy.descriptions[var])"""

# ╔═╡ 110d82f8-cdab-48ae-b21b-75829079aa40
stations

# ╔═╡ 06d96eef-f99d-44fe-8c6f-344ab29f3a48
md"""## Additional Information
Expand Down Expand Up @@ -131,7 +143,7 @@ PlutoUI = "7f904dfe-b85e-4ff6-b463-dae2292396a8"
PLUTO_MANIFEST_TOML_CONTENTS = """
# This file is machine-generated - editing it directly is not advised
julia_version = "1.10.4"
julia_version = "1.10.5"
manifest_format = "2.0"
project_hash = "dab0cebf879211c8791496c0ee2161abb0037489"
Expand Down Expand Up @@ -1886,7 +1898,7 @@ version = "0.15.2+0"
[[deps.libblastrampoline_jll]]
deps = ["Artifacts", "Libdl"]
uuid = "8e850b90-86db-534c-a0d3-1478176c7d93"
version = "5.8.0+1"
version = "5.11.0+0"
[[deps.libfdk_aac_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl"]
Expand Down Expand Up @@ -1958,6 +1970,7 @@ version = "3.6.0+0"
# ╟─c8d36a50-0473-410a-91fa-102f3d071388
# ╟─db662fb4-7413-11ec-1af6-43b18c0c15a9
# ╟─a1698e0e-db0d-4cd2-91b3-d530f77cd609
# ╠═110d82f8-cdab-48ae-b21b-75829079aa40
# ╟─06d96eef-f99d-44fe-8c6f-344ab29f3a48
# ╟─38a48b6b-4e07-4965-8947-6b758318462b
# ╟─00000000-0000-0000-0000-000000000001
Expand Down
7 changes: 4 additions & 3 deletions src/files.jl
Original file line number Diff line number Diff line change
Expand Up @@ -234,13 +234,14 @@ function list_realtime(;ext=:all)
txt0=String(HTTP.get(myurl0).body)
txt1=split(txt0,"<tr><td valign=\"top\"><img src=\"/icons/text.gif\"")[3:end]
lst1=[split(split(t,"href=\"")[2],"\">")[1] for t in txt1]
if ext!==:all
lst2=(if ext!==:all
extxt=String(ext)
lst2=lst1[[split(t,".")[2]==string(ext) for t in lst1]]
[split(t,".")[1] for t in lst2]
else
lst1
end
end)
string.(lst2)
end

"""
Expand Down Expand Up @@ -304,7 +305,7 @@ read(x::NOAAbuoy_monthly,args...) = read_monthly(args...)
Read station file from specified path, and add meta-data (`units` and `descriptions`).
"""
function read_station(station::Int,path=tempdir())
function read_station(station::Union{Int,String},path=tempdir())
fil1=joinpath(path,"$station.txt")
!isfile(fil1) ? download(station,path) : nothing

Expand Down
2 changes: 1 addition & 1 deletion src/types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ using DataFrames, NCDatasets
abstract type AbstractOceanRobotData <: Any end

struct NOAAbuoy <: AbstractOceanRobotData
ID::Int64
ID::Union{Int64,String}
data::DataFrame
units::Dict
descriptions::Dict
Expand Down

0 comments on commit 2208ae4

Please sign in to comment.