Skip to content

Commit

Permalink
Fix the ITS_LIVE tutorial
Browse files Browse the repository at this point in the history
  • Loading branch information
asinghvi17 committed Oct 15, 2024
1 parent 5bdf32a commit 1467c6d
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions docs/src/tutorials/its_live.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,21 @@
# ITS_LIVE data
=#

using Rasters, ZarrDatasets
using Kerchunk
using Statistics

rs = RasterStack("reference://$(joinpath(dirname(dirname(pathof(Kerchunk))), "test", "data", "its_live_catalog.json"))")
#
using Rasters # Raster data analysis in Julia
using ZarrDatasets # Zarr support for Rasters
using Kerchunk # Kerchunk support for Zarr
using Statistics # Basic statistics
# We can load the catalog from the catalog file that we ship in the repo:
catalog_path = joinpath(dirname(dirname(pathof(Kerchunk))), "test", "data", "its_live_catalog.json")
rs = RasterStack("reference://$(catalog_path)"; source = Rasters.Zarrsource())
# We've now loaded the dataset lazily in a `RasterStack`, which is essentially a stack of multiple variables.
# Now, we can apply arbitrary Rasters.jl functions to the stack, or plot it, and treat it as a general Julia array!
#
# Let's plot first:
using CairoMakie
heatmap(rs.v)
# We can also aggregate the data to a lower resolution, which downloads the entire dataset.
# Here, we aggregate by a factor of 10 in both dimensions, so a 10x10 window is aggregated to a single pixel.
vs2 = Rasters.aggregate(rs, mean, 10) # now everything is loaded in disk
#
# and plot this aggregated data:
arrows(dims(vs2, X) |> collect, dims(vs2, Y) |> collect, vs2.vx .* 20, vs2.vy .* 20; arrowsize = 5)

0 comments on commit 1467c6d

Please sign in to comment.