From 5de8eb5088be931d45e026ed55a47c15346eb368 Mon Sep 17 00:00:00 2001 From: Felix Cremer Date: Fri, 14 Feb 2025 11:02:31 +0100 Subject: [PATCH 1/4] Skipmissing before starting the inner loop --- src/rqatrend.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rqatrend.jl b/src/rqatrend.jl index cc388cf..da9ae24 100644 --- a/src/rqatrend.jl +++ b/src/rqatrend.jl @@ -49,7 +49,7 @@ Compute the RQA trend metric for the non-missing time steps of xin, and save it `thresh` specifies the epsilon threshold of the Recurrence Plot computation """ function rqatrend(pix_trend, pix, thresh=2) - pix_trend .= rqatrend_impl(pix; thresh) + pix_trend .= rqatrend_impl(collect(skipmissing(pix)); thresh) end From 6bca6f11e9c8e996aa896f450a0db7bb48c38159 Mon Sep 17 00:00:00 2001 From: Felix Cremer Date: Fri, 14 Feb 2025 11:49:00 +0100 Subject: [PATCH 2/4] Add check for number of significant change pixels on main run This is an indicator, that the run is probably correct. We might want to also include the checked result of a test run to the testdata folder and then compare against that one --- test/testdata.jl | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/test/testdata.jl b/test/testdata.jl index c203934..4079966 100644 --- a/test/testdata.jl +++ b/test/testdata.jl @@ -1,6 +1,7 @@ @testitem "testdata julia_main" begin import Pkg: Artifacts.@artifact_str, ensure_artifact_installed + using YAXArrays, Zarr ensure_artifact_installed("rqatestdata", "Artifacts.toml") testdatapath = joinpath(artifact"rqatestdata", "RQADeforestationTestData-2.0") @@ -8,7 +9,7 @@ testdir = "tmp/testdata" rm(testdir, recursive=true, force=true) mkpath(testdir) - outdir = "$testdir/out.zarr" + outdir = "$testdir/out" indir = "$testdir/in" cp(testdatapath, indir) @@ -18,10 +19,15 @@ "--continent", "EU", "--in-dir", indir, "--out-dir", outdir, + "--years", "2021" ]) # test normal execution RQADeforestation.julia_main() # test short cut implementation using cache files RQADeforestation.julia_main() + + outpath = joinpath(outdir, "E051N018T3_rqatrend_VH_022_thresh_3.0_year_2021.zarr") + c = Cube(outpath) + @test count(c .< -1.28) > 200 copy!(ARGS, OLD_ARGS) end \ No newline at end of file From 738673c674105d26d8f72e3edbdaffdc2d4608c5 Mon Sep 17 00:00:00 2001 From: Felix Cremer Date: Fri, 14 Feb 2025 12:05:06 +0100 Subject: [PATCH 3/4] Remove unnecessary show statements --- src/main.jl | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/main.jl b/src/main.jl index 1d21782..b82d8bf 100644 --- a/src/main.jl +++ b/src/main.jl @@ -84,10 +84,8 @@ function main(; filenamelist = [glob("$(sub)/*$(continent)*20M/$(tilefolder)/*$(polarisation)_$(orbit)*.tif", indir) for sub in folders] allfilenames = collect(Iterators.flatten(filenamelist)) - @show allfilenames relorbits = unique([split(basename(x), "_")[5][2:end] for x in allfilenames]) - @show relorbits for relorbit in relorbits for y in years @@ -95,13 +93,11 @@ function main(; @time cube = gdalcube(filenames) path = joinpath(YAXDefaults.workdir[], "$(tilefolder)_rqatrend_$(polarisation)_$(relorbit)_thresh_$(threshold)_year_$(y)") - @show path ispath(path * ".done") && continue ispath(path * "_zerotimesteps.done") && continue tcube = cube[Time=Date(y - 1, 7, 1) .. Date(y + 1, 7, 1)] - @show size(cube) - @show size(tcube) + if size(tcube, 3) == 0 touch(path * "_zerotimesteps.done") continue From 2c2a7508da00cb3af1b043319a9cad3d19f99e32 Mon Sep 17 00:00:00 2001 From: Felix Cremer Date: Fri, 14 Feb 2025 12:07:52 +0100 Subject: [PATCH 4/4] Remove folder with legacy versions of the input from default kwarg --- src/main.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.jl b/src/main.jl index b82d8bf..b85e751 100644 --- a/src/main.jl +++ b/src/main.jl @@ -65,7 +65,7 @@ function main(; polarisation="VH", orbit="*", threshold=3.0, - folders=["V01R01", "V0M2R4", "V1M0R1", "V1M1R1", "V1M1R2"] + folders=[ "V0M2R4", "V1M1R1", "V1M1R2"] ) if isdir(indir) && isempty(indir) error("Input directory $indir must not be empty")