Skip to content

Commit

Permalink
Merge pull request #72 from JuliaOcean/v0p1p23c
Browse files Browse the repository at this point in the history
add SeaLevelAnomaly type
  • Loading branch information
gaelforget authored May 27, 2024
2 parents bfdd502 + f5f0aa6 commit 2b23a7f
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 9 deletions.
2 changes: 2 additions & 0 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ CFTime = "179af706-886a-5703-950a-314cd64e0468"
CSV = "336ed68f-0bac-5ca0-87d4-7b16caf5d00b"
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
DataStructures = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8"
Dataverse = "9c0b9be8-e31e-490f-90fe-77697562404d"
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
Downloads = "f43a241f-c20a-4ad4-852c-f6b1247861c6"
FTPClient = "01fcc997-4f28-56b8-8a06-30002c134abb"
Expand All @@ -32,6 +33,7 @@ CFTime = "0.1"
CSV = "0.10"
DataFrames = "1"
DataStructures = "0.18"
Dataverse = "0.2"
Downloads = "1"
FTPClient = "1"
Glob = "1.3"
Expand Down
14 changes: 10 additions & 4 deletions ext/OceanRobotsMakieExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,14 @@ cmems_all_dates=cmems_date.(1:10632)

sla_dates(fil) = ( fil=="sla_podaac.nc" ? podaac_all_dates : cmems_all_dates)

function prep_movie(ds, topo; colormap=:PRGn, color=:black,
time=1, dates=[], showTopo=true, resolution = (600, 400))
plot(b::SeaLevelAnomaly; dates=[], kwargs...) = begin
ds=(isempty(dates) ? sla_dates(b.file) : dates)
fig,_,_=prep_movie(b.data; dates=ds, kwargs...)
fig
end

function prep_movie(ds; topo=[], colormap=:PRGn, color=:black,
time=1, dates=[], resolution = (600, 400))
lon=ds["lon"][:]
lat=ds["lat"][:]
store=ds["SLA"][:,:,:]
Expand All @@ -132,7 +138,7 @@ function prep_movie(ds, topo; colormap=:PRGn, color=:black,
ax=Axis(fig[1,1])
hm=heatmap!(lon,lat,SLA2,colorrange=0.25.*(-1.0,1.0),colormap=colormap)

if showTopo
if !isempty(topo)
lon[1]>0.0 ? lon_off=360.0 : lon_off=0.0
contour!(lon_off.+topo.lon,topo.lat,topo.z,levels=-300:100:300,color=color,linewidth=1)
contour!(lon_off.+topo.lon,topo.lat,topo.z,levels=-2500:500:-500,color=color,linewidth=0.25)
Expand Down Expand Up @@ -213,7 +219,7 @@ end
function plot_standard(wmo,arr,spd,T_std,S_std; markersize=2,pol=Any[])

xlims=xrng(arr.lon)
ylims=xrng(arr.lat)
ylims=yrng(arr.lat)

fig1=Figure(size=(900,900))

Expand Down
8 changes: 5 additions & 3 deletions src/OceanRobots.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@ import Base: read
include("types.jl")
include("thredds_servers.jl")
include("files.jl")
include("gridded_data.jl")

export GDP, GDP_CloudDrift, NOAA, GliderFiles, ArgoFiles, OceanSites, OceanOPS
export THREDDS, cmems_sla, podaac_sla
#export THREDDS

include("gridded_data.jl")
export cmems_sla, podaac_sla

export NOAAbuoy, NOAAbuoy_monthly, ArgoFloat, SurfaceDrifter, Gliders, OceanSite, CloudDrift
export NOAAbuoy, NOAAbuoy_monthly, ArgoFloat, SurfaceDrifter, Gliders, OceanSite, CloudDrift, SeaLevelAnomaly

end # module
25 changes: 25 additions & 0 deletions src/files.jl
Original file line number Diff line number Diff line change
Expand Up @@ -879,3 +879,28 @@ list_platform_types() = begin
end

end

##

module SLA

using Dataverse, NCDatasets
import OceanRobots: SeaLevelAnomaly
import Base: read

#fil=["sla_podaac.nc","sla_cmems.nc"]
function read(x::SeaLevelAnomaly,ID=:sla_podaac,path=tempdir())
DOI="doi:10.7910/DVN/OYBLGK"
lst=Dataverse.file_list(DOI)

fil=string(ID)*".nc"
sla_file=joinpath(path,fil)
!isdir(path) ? mkdir(path) : nothing
!isfile(sla_file) ? Dataverse.file_download(lst,fil,path) : nothing

ds=Dataset(sla_file)
#data=(lon=ds["lon"],lat=ds["lat"],SLA=ds["SLA"])
SeaLevelAnomaly(Symbol(fil[1:end-3]),ds,sla_file)
end

end
8 changes: 8 additions & 0 deletions src/types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,11 @@ struct OceanSite <: AbstractOceanRobotData
end

OceanSite() = OceanSite(:unknown,NamedTuple(),NamedTuple())

struct SeaLevelAnomaly <: AbstractOceanRobotData
ID::Symbol
data::Union{Array,Dataset}
file::String
end

SeaLevelAnomaly() = SeaLevelAnomaly(:unknown,[],"")
11 changes: 9 additions & 2 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ using Test
@testset "OceanRobots.jl" begin

url="https://dods.ndbc.noaa.gov/thredds/catalog/oceansites/long_timeseries/WHOTS/catalog.xml"
files,folders=THREDDS.parse_catalog(url)
files,folders=OceanRobots.THREDDS.parse_catalog(url)

@test isa(files[1],String)
@test isempty(folders)
Expand Down Expand Up @@ -86,7 +86,7 @@ using Test
b=plot(a;option=:demo)
@test isa(b,Figure)

files_year,files_url=THREDDS.parse_catalog_NOAA_buoy()
files_year,files_url=OceanRobots.THREDDS.parse_catalog_NOAA_buoy()
@test !isempty(files_url)

##
Expand All @@ -102,4 +102,11 @@ using Test

tmp=OceanOPS.list_platform_types()
@test isa(tmp.name,Vector)

##

b=read(SeaLevelAnomaly(),:sla_podaac)
f3=plot(b)
@test isa(f3,Figure)

end

0 comments on commit 2b23a7f

Please sign in to comment.