Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 18 additions & 18 deletions ext/MeshArraysMakieExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,15 @@ end
##

"""
scatter(XC::MeshArray,YC::MeshArray;color=:black,colorrange=[],colorbar=true,title="",kwargs...)
scatter(XC::AbstractMeshArray,YC::AbstractMeshArray;color=:black,colorrange=[],colorbar=true,title="",kwargs...)

```
scatter(Γ.XC,Γ.YC,color=:black)
MS=log10.(Γ.RAC)*μ
scatter(Γ.XC,Γ.YC,color=MS)
```
"""
function scatter(XC::MeshArray,YC::MeshArray;
function scatter(XC::AbstractMeshArray,YC::AbstractMeshArray;
color=:black,colorrange=[],colorbar=true,title="",kwargs...)

if isa(color,MeshArray)
Expand All @@ -68,22 +68,22 @@ function scatter(XC::MeshArray,YC::MeshArray;

fig = Figure(size = (900,600), backgroundcolor = :grey95)
ax = Axis(fig[1,1],xlabel="longitude",ylabel="latitude",title=title)
scatter!(ax,XC::MeshArray,YC::MeshArray;
scatter!(ax,XC::AbstractMeshArray,YC::AbstractMeshArray;
color=color, colorrange=colorrange, colorbar=colorbar, kwargs...)

fig
end

"""
scatter!(ax,XC::MeshArray,YC::MeshArray;color=:black,colorrange=[],colormap=:viridis)
scatter!(ax,XC::AbstractMeshArray,YC::AbstractMeshArray;color=:black,colorrange=[],colormap=:viridis)

```
fig=heatmap(Γ.Depth,interpolation=λ)
scatter!(current_axis(),Γ.XC,Γ.YC,color=:red)
fig
```
"""
function scatter!(ax,XC::MeshArray,YC::MeshArray;
function scatter!(ax,XC::AbstractMeshArray,YC::AbstractMeshArray;
color=:black,colorrange=[],colorbar=true,colormap=:veridis,kwargs...)

if isa(color,MeshArray)&&isempty(colorrange)
Expand Down Expand Up @@ -111,7 +111,7 @@ function scatter!(ax,XC::MeshArray,YC::MeshArray;
end

"""
heatmap(MS::MeshArray; interpolation=nothing,globalmap=false,x=nothing,y=nothing,colorbar=true,title="",kwargs...)
heatmap(MS::AbstractMeshArray; interpolation=nothing,globalmap=false,x=nothing,y=nothing,colorbar=true,title="",kwargs...)

Represent a `MeshArray` as a `heatmap`, or several, depending on keyword parameter choices.

Expand All @@ -124,11 +124,11 @@ heatmap(MS,interpolation=λ,title="ocean depth") #same but w title
heatmap(MS,x=lon,y=lat) #only for simple domains; will show MS[1]
```
"""
heatmap(MS::MeshArray;interpolation=nothing,globalmap=false,x=nothing,y=nothing,colorbar=true,title="",kwargs...)=begin
heatmap(MS::AbstractMeshArray;interpolation=nothing,globalmap=false,x=nothing,y=nothing,colorbar=true,title="",kwargs...)=begin
if (!isnothing(interpolation))||globalmap||(!isnothing(x))
f=Figure()
ax=Axis(f[1,1],title=title)
hm1=heatmap!(ax,MS::MeshArray;
hm1=heatmap!(ax,MS::AbstractMeshArray;
interpolation=interpolation,globalmap=globalmap,x=x,y=y,
kwargs...)
colorbar ? Colorbar(f[1,2], hm1, height = Relative(0.65)) : nothing
Expand All @@ -138,7 +138,7 @@ heatmap(MS::MeshArray;interpolation=nothing,globalmap=false,x=nothing,y=nothing,
end
end

function heatmap!(ax::Axis,MS::MeshArray;interpolation=nothing,globalmap=false,x=nothing,y=nothing,kwargs...)
function heatmap!(ax::Axis,MS::AbstractMeshArray;interpolation=nothing,globalmap=false,x=nothing,y=nothing,kwargs...)
if !isnothing(interpolation)
heatmap_interpolation!(ax,MS,interpolation;kwargs...)
elseif globalmap
Expand All @@ -150,47 +150,47 @@ function heatmap!(ax::Axis,MS::MeshArray;interpolation=nothing,globalmap=false,x
end
end

function heatmap_globalmap!(ax,MS::MeshArray;kwargs...)
function heatmap_globalmap!(ax,MS::AbstractMeshArray;kwargs...)
γ=MS.grid
DD=γ.write(MS)
# !isempty(colorrange) ? cr=colorrange : cr=(nanmin(DD),nanmax(DD))
hm1=heatmap!(ax,DD;kwargs...)
end

function heatmap_globalmap(MS::MeshArray;title="",colorbar=true,kwargs...)
function heatmap_globalmap(MS::AbstractMeshArray;title="",colorbar=true,kwargs...)
fig = Figure(size = (900,900), backgroundcolor = :grey95)
ax = Axis(fig[1,1],xlabel="i index",ylabel="j index",title=title)
hm1=heatmap_globalmap!(ax,MS;kwargs...)
colorbar ? Colorbar(fig[1,2], hm1, height = Relative(0.65)) : nothing
fig
end

heatmap_xy!(ax,MS::MeshArray,x::Union{UnitRange,Array},y::Union{UnitRange,Array};kwargs...) = heatmap!(ax,x,y,MS[1];kwargs...)
#heatmap_xy!(ax,MS::MeshArray,x::Union{UnitRange,Array},y::Union{UnitRange,Array};kwargs...) = surface!(ax,x,y,0*x;color=MS[1],shading=NoShading, kwargs...)
heatmap_xy!(ax,MS::AbstractMeshArray,x::Union{UnitRange,Array},y::Union{UnitRange,Array};kwargs...) = heatmap!(ax,x,y,MS[1];kwargs...)
#heatmap_xy!(ax,MS::AbstractMeshArray,x::Union{UnitRange,Array},y::Union{UnitRange,Array};kwargs...) = surface!(ax,x,y,0*x;color=MS[1],shading=NoShading, kwargs...)

function heatmap_xy(MS::MeshArray,x::Union{UnitRange,Array},y::Union{UnitRange,Array};title="",colorbar=true,kwargs...)
function heatmap_xy(MS::AbstractMeshArray,x::Union{UnitRange,Array},y::Union{UnitRange,Array};title="",colorbar=true,kwargs...)
fig = Figure(size = (900,400), backgroundcolor = :grey95)
ax = Axis(fig[1,1],xlabel="longitude",ylabel="latitude",title=title)
hm1=heatmap_xy!(ax,MS,x,y;kwargs...)
colorbar ? Colorbar(fig[1,2], hm1, height = Relative(0.65)) : nothing
fig
end

function heatmap_interpolation!(ax,MS::MeshArray,λ::NamedTuple;kwargs...)
function heatmap_interpolation!(ax,MS::AbstractMeshArray,λ::NamedTuple;kwargs...)
DD=Interpolate(MS,λ.f,λ.i,λ.j,λ.w)
DD=reshape(DD,size(λ.lon))
hm1=heatmap!(ax,λ.lon[:,1],λ.lat[1,:],DD;kwargs...)
end

function heatmap_interpolation(MS::MeshArray,λ::NamedTuple;title="",colorbar=true,kwargs...)
function heatmap_interpolation(MS::AbstractMeshArray,λ::NamedTuple;title="",colorbar=true,kwargs...)
fig = Figure(size = (900,400), backgroundcolor = :grey95)
ax = Axis(fig[1,1],xlabel="longitude",ylabel="latitude",title=title)
hm1=heatmap_interpolation!(ax,MS,λ;kwargs...)
colorbar ? Colorbar(fig[1,2], hm1, height = Relative(0.65)) : nothing
fig
end

function heatmap_tiled(MS::MeshArray;title="",
function heatmap_tiled(MS::AbstractMeshArray;title="",
colorbar=true,colorrange=[],colormap=:viridis,kwargs...)
fig = Figure(size = (900,900), backgroundcolor = :grey95)
nf=length(MS.fSize)
Expand Down Expand Up @@ -717,7 +717,7 @@ function scatter!(pr_ax::PrAxis,lon,lat,kargs...; kwargs...)
scatter!(pr_ax.ax,x,y,kargs...; kwargs...)
end

plot(x::MeshArray; kwargs...) = begin
plot(x::AbstractMeshArray; kwargs...) = begin
if ndims(x) == 1
heatmap(x; kwargs...)
else
Expand Down
26 changes: 13 additions & 13 deletions src/Exchanges.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,27 @@
## User Front Ends

"""
exchange(fld::MeshArray)
exchange(fld::AbstractMeshArray)
Exchange / transfer data between neighboring arrays. Other methods are
exchange(fld::MeshArray,N::Integer)
exchange(u::MeshArray,v::MeshArray)
exchange(u::MeshArray,v::MeshArray,N::Integer)
exchange(fld::AbstractMeshArray,N::Integer)
exchange(u::AbstractMeshArray,v::AbstractMeshArray)
exchange(u::AbstractMeshArray,v::AbstractMeshArray,N::Integer)
"""
function exchange(fld::MeshArray)
function exchange(fld::AbstractMeshArray)
MeshArray_wh(exch_T_N(fld,1),1)
end

function exchange(fld::MeshArray,N::Integer)
function exchange(fld::AbstractMeshArray,N::Integer)
MeshArray_wh(exch_T_N(fld,N),N)
end

function exchange(u::MeshArray,v::MeshArray)
function exchange(u::AbstractMeshArray,v::AbstractMeshArray)
MeshArray_wh.(exch_UV_N(u,v,1),1)
end

function exchange(u::MeshArray,v::MeshArray,N::Integer)
function exchange(u::AbstractMeshArray,v::AbstractMeshArray,N::Integer)
MeshArray_wh.(exch_UV_N(u,v,N),N)
end

Expand Down Expand Up @@ -89,7 +89,7 @@ end

## Grid-specific implementations: PeriodicDomain case

function exch_T_N_dpdo(fld::MeshArray,N::Integer)
function exch_T_N_dpdo(fld::AbstractMeshArray,N::Integer)

fillval=0.0

Expand Down Expand Up @@ -189,7 +189,7 @@ end

## Grid-specific implementations: PeriodicChannel case

function exch_T_N_ll(fld::MeshArray,N::Integer)
function exch_T_N_ll(fld::AbstractMeshArray,N::Integer)

fillval=0.0

Expand Down Expand Up @@ -253,7 +253,7 @@ end

#note: the "CubeSphere" implementation covers both cs and llc

function exch_T_N_cs(fld::MeshArray,N::Integer)
function exch_T_N_cs(fld::AbstractMeshArray,N::Integer)

fillval=0.0

Expand Down Expand Up @@ -301,7 +301,7 @@ end

##

function exch_UV_N_cs(fldU::MeshArray,fldV::MeshArray,N::Integer)
function exch_UV_N_cs(fldU::AbstractMeshArray,fldV::AbstractMeshArray,N::Integer)

fillval=0.0

Expand Down Expand Up @@ -355,7 +355,7 @@ end

##

function exch_UV_cs(fldU::MeshArray,fldV::MeshArray)
function exch_UV_cs(fldU::AbstractMeshArray,fldV::AbstractMeshArray)

fillval=0.0

Expand Down
4 changes: 2 additions & 2 deletions src/Integration.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module Integration
using Distributed, SharedArrays, Glob
import MeshArrays: read_jld2, write_jld2
import MeshArrays: GridLoad, GridLoadVar, GridSpec
import MeshArrays: demo, MeshArray, gridmask
import MeshArrays: demo, AbstractMeshArray, MeshArray, gridmask

##

Expand Down Expand Up @@ -244,7 +244,7 @@ function streamlined_loop(mask::gridmask; files=String[], var=:THETA, rd=read)
Array(BA)
end

function one_comp(mask::gridmask, tmp::MeshArray)
function one_comp(mask::gridmask, tmp::AbstractMeshArray)
nh=length(mask.names)
nv=length(mask.depths)
BA=zeros(nh,nv)
Expand Down
14 changes: 7 additions & 7 deletions src/Interpolation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ using NearestNeighbors
import NearestNeighbors: knn

"""
knn(xgrid,ygrid::MeshArray,x,y::Array{T,1},k::Int)
knn(xgrid,ygrid::AbstractMeshArray,x,y::Array{T,1},k::Int)

Find k nearest neighbors to each point in x,y on xgrid,ygrid

Expand All @@ -12,7 +12,7 @@ lon=collect(0.1:0.5:2.1); lat=collect(0.1:0.5:2.1);
(f,i,j,c)=knn(Γ.XC,Γ.YC,lon,lat)
```
"""
function knn(xgrid::MeshArray,ygrid::MeshArray,
function knn(xgrid::AbstractMeshArray,ygrid::AbstractMeshArray,
xvec::Array{T,1},yvec::Array{T,1},k=1::Int) where {T}

#ancillary variables
Expand Down Expand Up @@ -49,10 +49,10 @@ function knn(xgrid::MeshArray,ygrid::MeshArray,
return a_f[kk[idxs]],a_i[kk[idxs]],a_j[kk[idxs]],kk[idxs]
end

knn(xgrid::MeshArray,ygrid::MeshArray,lon::Number,lat::Number) = knn(xgrid::MeshArray,ygrid::MeshArray,[lon],[lat])
knn(xgrid::AbstractMeshArray,ygrid::AbstractMeshArray,lon::Number,lat::Number) = knn(xgrid::AbstractMeshArray,ygrid::AbstractMeshArray,[lon],[lat])

"""
Interpolate(z_in::MeshArray,f,i,j,w)
Interpolate(z_in::AbstractMeshArray,f,i,j,w)

```
using MeshArrays
Expand All @@ -69,7 +69,7 @@ using CairoMakie
heatmap(vec(lon[:,1]),vec(lat[1,:]),DD,colorrange=(0.,6000.))
```
"""
function Interpolate(z_in::MeshArray,f,i,j,w)
function Interpolate(z_in::AbstractMeshArray,f,i,j,w)
z_out=NaN*similar(f[:,1])
for jj=1:size(f,1)
if (!isnan(sum(w[jj,:])))&&(sum(f[jj,:].==0)==0)
Expand All @@ -82,7 +82,7 @@ function Interpolate(z_in::MeshArray,f,i,j,w)
end

"""
Interpolate(z_in::MeshArray,f,i,j,w)
Interpolate(z_in::AbstractMeshArray,f,i,j,w)

```
using MeshArrays
Expand All @@ -105,7 +105,7 @@ or
heatmap(Γ.Depth,interpolation=L,colorrange=(0.,6000.))
```
"""
function Interpolate(z_in::MeshArray,λ::NamedTuple)
function Interpolate(z_in::AbstractMeshArray,λ::NamedTuple)
z=Interpolate(z_in,λ.f,λ.i,λ.j,λ.w)
z=reshape(z,size(λ.lon))
return λ.lon[:,1],λ.lat[1,:],z
Expand Down
Loading
Loading