diff --git a/Project.toml b/Project.toml index 1438780..9aa778f 100644 --- a/Project.toml +++ b/Project.toml @@ -4,9 +4,9 @@ authors = ["Felix Cremer and contributors"] version = "0.1.0-DEV" [deps] +CFTime = "179af706-886a-5703-950a-314cd64e0468" CommonDataModel = "1fbeeb36-5f17-413c-809b-666fb144f157" DimensionalData = "0703355e-b756-11e9-17c0-8b28908087d0" -DiskArrayTools = "fcd2136c-9f69-4db6-97e5-f31981721d63" DiskArrays = "3c3547ce-8d99-4f5e-a174-61eb10b00ae3" Rasters = "a3a2b9e3-a471-40c9-b274-f788e487c689" YAXArrayBase = "90b8fcef-0c2d-428d-9c56-5f86629e9d14" @@ -15,13 +15,13 @@ Zarr = "0a941bbe-ad1d-11e8-39d9-ab76183a1d99" ZarrDatasets = "519a4cdf-1362-424a-9ea1-b1d782dbb24b" [compat] -CommonDataModel = "0.3.8" +CFTime = "0.2.1" +CommonDataModel = "0.3.8, 0.4" DimensionalData = "0.29.12" -DiskArrayTools = "0.1.12" DiskArrays = "0.4.11" Rasters = "0.14.4" YAXArrayBase = "0.7.5" YAXArrays = "0.6.1" Zarr = "0.9.4" ZarrDatasets = "0.1.3" -julia = "1.6.7" +julia = "1.6.7" \ No newline at end of file diff --git a/docs/introduction.qmd b/docs/introduction.qmd new file mode 100644 index 0000000..3c46f3e --- /dev/null +++ b/docs/introduction.qmd @@ -0,0 +1,57 @@ +# Introduction to the SentinelDataSource julia package + +A user friendly way to open the EOPF Zarr products in Julia. + + +## Introduction + +SentinelDataSource is a julia package that extends the DimensionalData.jl ecosystem to enable seamless access to ESA EOPF data products stored in the Zarr format. +This notebook demonstrates how to use SentinelDataSource.jl to explore and analyse EOPF Zarr datasets. +It highlights the key features currently supported. + +## Install SentinelDataSource.jl + +To install the SentinelDataSource.jl package use the julia package manager. + +In the julia REPL first press `]` to enter the pkg mode and then do + +``` +add SentinelDataSource +``` + +This will install SentinelDataSource into your current environment. + +## Import Modules + +```{julia} +using Pkg +Pkg.activate(".") +Pkg.instantiate() +``` + +```{julia} +using SentinelDataSource: SentinelDataSource as SDS +using ZarrDatasets +``` + + +# Open the product in Native Mode + +## Sentinel-2 Level-2A + +```{julia} +path ="https://objectstore.eodc.eu:2222/e05ab01a9d56408d82ac32d69a5aae2a:202505-s02msil2a/18/products/cpm_v256/S2B_MSIL2A_20250518T112119_N0511_R037_T29RLL_20250518T140519.zarr" +``` + +```{julia} +dt = SDS.open_tree(path) +``` + +```{julia} +dt.quality.l2a_quicklook.r60m[:tci] +``` + +```{julia} +using GLMakie +plot() +``` \ No newline at end of file diff --git a/src/SentinelDataSource.jl b/src/SentinelDataSource.jl index a9f9549..559399e 100644 --- a/src/SentinelDataSource.jl +++ b/src/SentinelDataSource.jl @@ -5,18 +5,22 @@ using ZarrDatasets: ZarrDataset using CommonDataModel: CommonDataModel as CDM using Rasters:Raster -open_tree(path::AbstractString) = open_tree(ZarrDataset(path)) +export open_tree -function open_tree(dataset::ZarrDataset) +open_tree(path::AbstractString;kwargs...) = open_tree(ZarrDataset(path);kwargs...) + +function open_tree(dataset; prefer_datetime=true) stem = DimTree() groupnames = CDM.groupnames(dataset) varnames = CDM.varnames(dataset) alldimnames = nesteddimnames(dataset) + @show varnames for v in setdiff(varnames, alldimnames) - setindex!(stem, Raster(CDM.variable(dataset, v), lazy=true),Symbol(v)) + r = Raster(CDM.variable(dataset, v); lazy=true, prefer_datetime) + setindex!(stem, r,Symbol(v)) end for g in groupnames - setindex!(stem, open_tree(CDM.group(dataset, g)),Symbol(g)) + setindex!(stem, open_tree(CDM.group(dataset, g);prefer_datetime),Symbol(g)) end stem end diff --git a/test/Project.toml b/test/Project.toml index 18aa358..0c5ff45 100644 --- a/test/Project.toml +++ b/test/Project.toml @@ -1,4 +1,5 @@ [deps] Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595" +DimensionalData = "0703355e-b756-11e9-17c0-8b28908087d0" Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" Zarr = "0a941bbe-ad1d-11e8-39d9-ab76183a1d99" diff --git a/test/runtests.jl b/test/runtests.jl index 81c609f..4bf6133 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -2,7 +2,7 @@ using SentinelDataSource using Test using Aqua using Zarr -using ZarrDatasets +using DimensionalData @testset "SentinelDataSource.jl" begin @testset "Code quality (Aqua.jl)" begin @@ -12,33 +12,33 @@ using ZarrDatasets @testset "S1 L1 GRD" begin s1grdpath = "https://objectstore.eodc.eu:2222/e05ab01a9d56408d82ac32d69a5aae2a:sample-data/tutorial_data/cpm_v253/S1A_IW_GRDH_1SDV_20240201T164915_20240201T164940_052368_065517_750E.zarr" - s1grd = ZarrDataset(s1grdpath) - s1grdtree = SentinelDataSource.open_tree(s1grd) + s1grdtree = open_tree(s1grdpath) + @test s1grdtree isa DimTree end @testset "S1 L1 SLC" begin s1slcpath = "https://objectstore.eodc.eu:2222/e05ab01a9d56408d82ac32d69a5aae2a:sample-data/tutorial_data/cpm_v253/S1A_IW_SLC__1SDV_20231119T170635_20231119T170702_051289_063021_178F.zarr" - s1slc = zopen(s1slcpath) - @test s1slc isa ZGroup + s1slc = open_tree(s1slcpath) + @test s1slc isa DimTree end @testset "S1 L1 NRB" begin s1nrbpath = "https://objectstore.eodc.eu:2222/e05ab01a9d56408d82ac32d69a5aae2a:sample-data/tutorial_data/cpm_v253/S1A_IW_SLC__1SDV_20240106T170607_20240106T170635_051989_064848_04A6.zarr" - s1nrb = zopen(s1nrbpath) - @test s1nrb isa ZGroup + s1nrb = open_tree(s1nrbpath) + @test s1nrb isa DimTree end @testset "S1 L2 OCN" begin s1ocnpath = "https://objectstore.eodc.eu:2222/e05ab01a9d56408d82ac32d69a5aae2a:sample-data/tutorial_data/cpm_v253/S1A_IW_OCN__2SDV_20250224T054940_20250224T055005_058034_072A26_160E.zarr" - s1ocn = zopen(s1ocnpath) - @test s1ocn isa ZGroup + s1ocn = open_tree(s1ocnpath) + @test s1ocn isa DimTree end @testset "S2 L1C MSI" begin s2l1cpath = "https://objectstore.eodc.eu:2222/e05ab01a9d56408d82ac32d69a5aae2a:sample-data/tutorial_data/cpm_v253/S2B_MSIL1C_20250113T103309_N0511_R108_T32TLQ_20250113T122458.zarr" - s2l1c = zopen(s2l1cpath) - @test s2l1c isa ZGroup + s2l1c = open_tree(s2l1cpath) + @test s2l1c isa DimTree end @testset "S2 L2A MSI" begin s2l2apath = "https://objectstore.eodc.eu:2222/e05ab01a9d56408d82ac32d69a5aae2a:sample-data/tutorial_data/cpm_v253/S2A_MSIL2A_20240101T102431_N0510_R065_T32TNT_20240101T144052.zarr" - s2l2a = zopen(s2l2apath) - @test s2l2a isa ZGroup + s2l2a = open_tree(s2l2apath) + @test s2l2a isa DimTree end end