Skip to content

Commit

Permalink
doc: cut one example
Browse files Browse the repository at this point in the history
  • Loading branch information
tpoisot committed Sep 26, 2024
1 parent 1ab2b84 commit e7095a5
Showing 1 changed file with 1 addition and 53 deletions.
54 changes: 1 addition & 53 deletions docs/src/tutorials/sdemo.jl
Original file line number Diff line number Diff line change
Expand Up @@ -199,56 +199,4 @@ contour!(ax, predict(sdm, layers); color = :black, linewidth = 0.5) #hide
lines!(ax, CHE.geometry[1]; color = :black) #hide
hidedecorations!(ax) #hide
hidespines!(ax) #hide
current_figure() #hide

# ## Future predictions and range change

# Making a prediction with future data is trivial as long as we get the same
# layers in a vector:

projection = Projection(SSP370, GFDL_ESM4)
futurelayers = [
SDMLayer(
provider, projection;
timespan = Year(2071) => Year(2100),
layer = x,
left = 0.0,
right = 20.0,
bottom = 35.0,
top = 55.0,
) for x in bio_vars
]
futurelayers = [trim(mask!(layer, CHE)) for layer in futurelayers];
futurelayers = map(l -> convert(SDMLayer{Float32}, l), futurelayers);

# This gives the predicted presences under SSP370:

fprd = predict(sdm, futurelayers; threshold = false)

# We can also express the prediction in terms of range, using the thresholded
# prediction:

contemporary_range = predict(sdm, layers)
future_range = predict(sdm, futurelayers)

# The `gainloss` function returns the difference between the two:

rangediff = gainloss(contemporary_range, future_range)

# And we can now compare both of these maps:

f = Figure(; size = (600, 600))
ax = Axis(f[1, 1]; aspect = DataAspect(), title = "Future range")
hm = heatmap!(ax, prd; colormap = :linear_wcmr_100_45_c42_n256, colorrange = (0, 1))
Colorbar(f[1, 2], hm)
contour!(ax, future_range; color = :black, linewidth = 0.5) #hide
lines!(ax, CHE.geometry[1]; color = :black) #hide
hidedecorations!(ax) #hide
hidespines!(ax) #hide
ax2 = Axis(f[2, 1]; aspect = DataAspect(), title = "Range gain/loss")
heatmap!(ax2, rangediff; colormap = :diverging_isoluminant_cjo_70_c25_n256)
contour!(ax2, future_range; color = :black, linewidth = 0.5) #hide
lines!(ax2, CHE.geometry[1]; color = :black) #hide
hidedecorations!(ax2) #hide
hidespines!(ax2) #hide
current_figure() #hide
current_figure() #hide

0 comments on commit e7095a5

Please sign in to comment.