Skip to content

Commit

Permalink
clean and debug examples
Browse files Browse the repository at this point in the history
  • Loading branch information
lazarusA committed Jan 5, 2024
1 parent de82a3c commit 215d4ed
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 37 deletions.
2 changes: 1 addition & 1 deletion docs/examples/UserGuide/basic_features.jl
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ delta = 1;
extent = Extent(X = (lon - delta/2, lon + delta/2), Y = (lat-delta/2, lat+delta/2));

## show map
m = Tyler.Map(extent; provider, figure=Figure(resolution=(1000, 600)))
m = Tyler.Map(extent; provider, figure=Figure(; size=(1000, 600)))
## wait for tiles to fully load
wait(m)

Expand Down
51 changes: 27 additions & 24 deletions docs/examples/UserGuide/iceloss_ex.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,10 @@ using Extents
using Colors
using Dates
using HTTP
GLMakie.activate!()

url = "https://github.com/JuliaGeo/JuliaGeoData/blob/365a09596bfca59e0977c20c2c2f566c0b29dbaa/assets/data/iceloss_subset.arrow?raw=true";

## parameter for scaling figure size
scale = 1;

## load ice loss data [courtesy of Chad Greene @ JPL]
resp = HTTP.get(url);
df = DataFrame(Arrow.Table(resp.body));
Expand Down Expand Up @@ -42,7 +40,7 @@ cmap = Colors.alphacolor.(Makie.to_colormap(:thermal), alpha);
cmap = Observable(cmap);

## show map
m = Tyler.Map(extent; provider, figure=Figure(resolution=(1912 * scale, 2284 * scale)));
m = Tyler.Map(extent; provider, figure=Figure(; size=(700,600)));

## create initial scatter plot
scatter!(m.axis, X, Y; color = Z, colormap = cmap, colorrange = [0, n], markersize = 10);
Expand All @@ -51,7 +49,8 @@ scatter!(m.axis, X, Y; color = Z, colormap = cmap, colorrange = [0, n], markersi
a,b = extrema(df.Date);
a = year(a);
b = year(b);
Colorbar(m.figure[1,2]; colormap = cmap, colorrange = [a,b], ticklabelsize = 50 * scale, width = 100 * scale);
Colorbar(m.figure[1,2]; colormap = cmap, colorrange = [a,b],
height=Relative(0.5), width = 15);

## hide ticks, grid and lables
hidedecorations!(m.axis);
Expand All @@ -61,29 +60,33 @@ hidespines!(m.axis);

## wait for tiles to fully load
wait(m)
#

record(m.figure, "iceloss.mp4", framerate=24) do io
for k = 1:15
# reset apha
alpha[:] = zeros(nc);
cmap[] = Colors.alphacolor.(cmap[], alpha)

for i in 2:10:n
# modify alpha
alpha[1:maximum([1,round(Int64,i*nc/n)])] = alpha[1:maximum([1,round(Int64,i*nc/n)])] .* (1.05^-1.5)
alpha[maximum([1,round(Int64,i*nc/n)])] = 1
cmap[] = Colors.alphacolor.(cmap[], alpha)
recordframe!(io) # record a new frame
end
end
end
## ------ uncomment to create interactive-animated figure -----
## The Documenter does not allow creations of interactive plots

# loop to create animation
#=
# if interactive
# for k = 1:15
# # reset apha
# alpha[:] = zeros(nc);
# cmap[] = Colors.alphacolor.(cmap[], alpha)
# for i in 2:1:n
# # modify alpha
# alpha[1:maximum([1,round(Int64,i*nc/n)])] = alpha[1:maximum([1,round(Int64,i*nc/n)])] .* (1.05^-1.5);
# alpha[maximum([1,round(Int64,i*nc/n)])] = 1;
# cmap[] = Colors.alphacolor.(cmap[], alpha);
# sleep(0.001);
# end
# end
# end
=#

# -----------------------------------------------------------

# !!! info
# Ice loss from the Greenland Ice Sheet: 1972-2022.
#
# Contact person: Alex Gardner & Chad Greene

# <video src="https://github.com/JuliaGeo/JuliaGeoData/raw/main/assets/videos/iceloss.mp4" width="400" />

# ![type:video](iceloss.mp4)
# <video src="https://github.com/JuliaGeo/JuliaGeoData/raw/main/assets/videos/iceloss.mp4" width="400" />
9 changes: 0 additions & 9 deletions docs/examples/UserGuide/providers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,3 @@ using MapTiles
providers = TileProviders.list_providers()

# Try and see which ones work, and report back please.

##london = Rect2f(-0.0921, 51.5, 0.04, 0.025)
##ptopo = TileProviders.USGS(:USTopo)
##pclouds = TileProviders.OpenWeatherMap(:Clouds)
##pbright = TileProviders.MapTiler(:Bright)
##ppositron = TileProviders.CartoDB(:Positron)
##providers = [ptopo, pclouds, pbright, ppositron]
##m = Tyler.Map(london; provider=ppositron,
## figure=Figure(resolution=(600, 600)))
2 changes: 1 addition & 1 deletion docs/examples/UserGuide/whale_ex.jl
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ provider = TileProviders.NASAGIBS(:ViirsEarthAtNight2012)

set_theme!(theme_black())
m = Tyler.Map(Rect2f(Rect2f(lomn - δlon/2, lamn-δlat/2, 2δlon, 2δlat));
provider, figure=Figure(resolution=(1000, 600)))
provider, figure=Figure(; size=(1000, 600)))
wait(m)

nt = 30
Expand Down
7 changes: 6 additions & 1 deletion docs/genfiles.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,12 @@ function getfiles()
srcsfiles = []
for f in folders
names = readdir(joinpath(@__DIR__, ".", "examples", f))
setdiff!(names, [".DS_Store"])
setdiff!(names, [".DS_Store",
# "iceloss_ex.jl",
#"interpolation.jl",
#"providers.jl",
# "whale_ex.jl"
])
fpaths = "$(f)/" .* names
srcsfiles = vcat(srcsfiles, fpaths...)
end
Expand Down
2 changes: 1 addition & 1 deletion docs/mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ theme:
# - navigation.instant
# - navigation.prune
#- navigation.sections
#- navigation.tabs
- navigation.tabs
# - navigation.tabs.sticky
- navigation.top
#- navigation.tracking
Expand Down

0 comments on commit 215d4ed

Please sign in to comment.