Skip to content

Commit

Permalink
Merge branch 'master' into V0p3p2b
Browse files Browse the repository at this point in the history
  • Loading branch information
gaelforget authored Apr 1, 2024
2 parents c290b8c + c1eae88 commit 928a174
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 2 deletions.
1 change: 1 addition & 0 deletions docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ makedocs(
sitename = "MeshArrays",
format = Documenter.HTML(),
modules = [MeshArrays],
warnonly = [:cross_references,:missing_docs],
pages = [
"Home" => "index.md",
"Get Started" => "start.md",
Expand Down
6 changes: 5 additions & 1 deletion examples/geography.jl
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,9 @@ end
#simple_heatmap(data)
plot_examples(:projmap,data,trans)

# ╔═╡ b4b1d8d1-f97d-4cd2-ace7-82ae65643573
data

# ╔═╡ 7fc02644-b037-425a-b660-cc6904a95037
md"""#### Code"""

Expand Down Expand Up @@ -2263,7 +2266,8 @@ version = "3.5.0+0"
# ╟─ca8a8f1b-a225-46c4-93c1-ce1a4b016461
# ╟─be38ff51-3526-44a0-9d8c-9209355e4a4a
# ╟─85aac4c5-bf04-4f9a-a233-a3f24231762e
# ╟─9c30b8df-b95d-40e1-b7e3-2dacbdda49ed
# ╠═9c30b8df-b95d-40e1-b7e3-2dacbdda49ed
# ╠═b4b1d8d1-f97d-4cd2-ace7-82ae65643573
# ╟─303b2f54-a446-4dbe-a9a4-e6f424003722
# ╟─d9a53bc6-19e2-48d9-b9c3-f76c3a533197
# ╟─6aab5feb-06b6-4fbd-8732-83b70f397f00
Expand Down
29 changes: 29 additions & 0 deletions src/Operations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,18 @@ nanmax(x,y) = mapslices(nanmax,x,dims=y)
nanmin(x) = minimum(filter(!isnan,x))
nanmin(x,y) = mapslices(nanmin,x,dims=y)

function nanmean(a::Number,b::Number)
if isnan(a)&&isnan(b)
NaN
elseif isnan(a)
b
elseif isnan(b)
a
else
(a+b)/2
end
end

## gradient methods

"""
Expand Down Expand Up @@ -429,6 +441,23 @@ function UVtoUEVN(u::MeshArray,v::MeshArray,G::NamedTuple)
return uC.*G.AngleCS-vC.*G.AngleSN, uC.*G.AngleSN+vC.*G.AngleCS
end

function UVtoSpeed!(u::MeshArray,v::MeshArray,G::NamedTuple,dD)
(u,v)=exch_UV(u,v)
for iF=1:u.grid.nFaces
for i in 1:size(vC[iF],1)
for j in 1:size(vC[iF],2)
u0=nanmean(u[iF][i,j],u[iF][i+1,j])
v0=nanmean(v[iF][i,j],v[iF][i,j+1])
u1=u0*G.AngleCS[iF][i,j]-v0*G.AngleSN[iF][i,j]
v1=u0*G.AngleSN[iF][i,j]+v0*G.AngleCS[iF][i,j]
dD[iF][i,j]=sqrt(u1^2 + v1^2)
#uC[iF][i,j]=u0*G.AngleCS[iF][i,j]-v0*G.AngleSN[iF][i,j]
#vC[iF][i,j]=u0*G.AngleSN[iF][i,j]+v0*G.AngleCS[iF][i,j]
end
end
end
end

"""
UVtoTransport(U,V,G::NamedTuple)
Expand Down
2 changes: 1 addition & 1 deletion src/demo.jl
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ module demo
pth=tempdir()
unzipfil="" #if provided then need to unzip + return this file name
if ID=="ne_110m_admin_0_countries.shp"
url="https://www.naturalearthdata.com/http//www.naturalearthdata.com/download/110m/cultural/ne_110m_admin_0_countries.zip"
url="https://naturalearth.s3.amazonaws.com/110m_cultural/ne_110m_admin_0_countries.zip"
fil=joinpath(pth,"ne_110m_admin_0_countries.zip")
unzipfil=joinpath(pth,"ne_110m_admin_0_countries.shp")
elseif ID=="countries.geojson"
Expand Down

0 comments on commit 928a174

Please sign in to comment.