From a8ff4b2fa131291f6347758ae3718caa8c0eb644 Mon Sep 17 00:00:00 2001 From: Daniel Loos Date: Wed, 11 Jun 2025 10:24:22 +0200 Subject: [PATCH 1/8] Remove timestats.jl --- src/timestats.jl | 37 ------------------------------------- 1 file changed, 37 deletions(-) delete mode 100644 src/timestats.jl diff --git a/src/timestats.jl b/src/timestats.jl deleted file mode 100644 index 5591845..0000000 --- a/src/timestats.jl +++ /dev/null @@ -1,37 +0,0 @@ -using Statistics -using StatsBase - -function timestats(cube; path=tempname()) - - indims = InDims("Time") - funcs = ["Mean", "5th Quantile", "25th Quantile", "Median", "75th Quantile", "95th Quantile", - "Standard Deviation", - "Minimum", "Maximum", - "Skewness", "Kurtosis", "Median Absolute Deviation"] - - stataxis = CategoricalAxis("Stats", funcs) - od = OutDims(stataxis, path=path) - stats = mapCube(ctimestats!, cube, indims=indims, outdims=od) -end - -function ctimestats!(xout, xin) - x = collect(skipmissing(xin)) - ts = x[.!isnan.(x)] - # m = mean(ts) - # T = eltype(m) - #stats = Vector{T}(undef,12) - if isempty(ts) - xout .= NaN - else - xout[1] = mean(ts) - xout[2:6] .= quantile(ts, [0.05, 0.25, 0.5, 0.75, 0.95]) - xout[7] = std(ts) - xout[2] = minimum(ts) - xout[3] = maximum(ts) - # stats[10] = skewness(ts) - # stats[11] = kurtosis(ts) - # stats[12] = mad(ts, normalize=true) - end - #xout .=stats - nothing -end \ No newline at end of file From 9226867e23462d486a0817ac446470261ff3bc72 Mon Sep 17 00:00:00 2001 From: Daniel Loos Date: Wed, 11 Jun 2025 10:30:19 +0200 Subject: [PATCH 2/8] Remove anti_diagonal_density --- src/analysis.jl | 34 ---------------------------------- 1 file changed, 34 deletions(-) diff --git a/src/analysis.jl b/src/analysis.jl index b1c8131..6df3a8c 100644 --- a/src/analysis.jl +++ b/src/analysis.jl @@ -68,40 +68,6 @@ function rqatrend_matrix(pix_trend, pix, thresh=2) pix_trend .= RA.trend(rm) end -#= -""" - rqatrend_shuffle(cube; thresh=2, path=tempname() * ".zarr", numshuffle=300) -Compute the RQA trend metric for shuffled time series of the data cube `cube` with the epsilon threshold `thresh` for `numshuffle` tries and save it into `path`. -""" -function rqatrend_shuffle(cube; thresh=2, path=tempname() * ".zarr", numshuffle=300) - # This should be made a random shuffle - # TODO this looks completely broken - sg = surrogenerator(collect(eachindex(water[overlap])), BlockShuffle(7, shift=true)) -end -=# - - -""" - anti_diagonal_density(ts, thresh, metric) -Compute the average density of the diagonals perpendicular to the main diagonal for data series `ts`. -Uses the threshold `thresh` and `metric` for the computation of the similarities. -""" -function anti_diagonal_density(ts::AbstractVector, thresh, metric=Euclidean()) - n = length(ts) - ad_densities = zeros(2 * n - 3) - for col in 1:n - for row in 1:(col-1) - d = evaluate(metric, ts[col], ts[row]) - #@show row, col, d - ad_densities[col+row-2] += d <= thresh - end - end - half = div(n, 2) - maxdensities = collect(Iterators.flatten([(n, n) for n in 1:half-1])) - diagonallengths = [maxdensities..., half, reverse(maxdensities)...] - ad_densities ./ diagonallengths -end - """ Compute the forest masking thresholding and clustering of the rqadata in one step """ From 034ed9e3dc4ed72e8f2037249bed7a77849f98f6 Mon Sep 17 00:00:00 2001 From: Daniel Loos Date: Wed, 11 Jun 2025 10:31:44 +0200 Subject: [PATCH 3/8] Remove inner_postprocessing --- src/analysis.jl | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/src/analysis.jl b/src/analysis.jl index 6df3a8c..2cb9f8e 100644 --- a/src/analysis.jl +++ b/src/analysis.jl @@ -66,18 +66,4 @@ function rqatrend_matrix(pix_trend, pix, thresh=2) ts = collect(skipmissing(pix)) rm = RecurrenceMatrix(ts, thresh) pix_trend .= RA.trend(rm) -end - -""" -Compute the forest masking thresholding and clustering of the rqadata in one step -""" -function inner_postprocessing(rqadata, forestmask; threshold=-1.28, clustersize=30) - @time rqamasked = rqadata .* forestmask - @time rqathresh = map(rqamasked) do x - if !ismissing(x) - x > threshold ? zero(Float32) : one(Float32) - else - x - end - end end \ No newline at end of file From 7f55d65e259d33c2e38f4e10cb8f65340a8db35d Mon Sep 17 00:00:00 2001 From: Daniel Loos Date: Wed, 11 Jun 2025 10:33:02 +0200 Subject: [PATCH 4/8] Remove rqatrend_matrix --- src/analysis.jl | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/analysis.jl b/src/analysis.jl index 2cb9f8e..bafc7e8 100644 --- a/src/analysis.jl +++ b/src/analysis.jl @@ -59,11 +59,4 @@ function rqatrend_recurrenceanalysis(pix_trend, pix, thresh=2) ts = collect(skipmissing(pix)) tau_pix = tau_recurrence(ts, thresh) pix_trend .= RA._trend(tau_pix) -end - -function rqatrend_matrix(pix_trend, pix, thresh=2) - #replace!(pix, -9999 => missing) - ts = collect(skipmissing(pix)) - rm = RecurrenceMatrix(ts, thresh) - pix_trend .= RA.trend(rm) end \ No newline at end of file From b4d7b7ff4ce42b4d3be0d0384c3a4e7c0a6f74d2 Mon Sep 17 00:00:00 2001 From: Daniel Loos Date: Wed, 11 Jun 2025 10:34:16 +0200 Subject: [PATCH 5/8] Remove rqatrend_recurrenceanalysis --- src/analysis.jl | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/src/analysis.jl b/src/analysis.jl index bafc7e8..aa0aacb 100644 --- a/src/analysis.jl +++ b/src/analysis.jl @@ -43,20 +43,8 @@ countvalid(cube; path=tempname() * ".zarr") = mapCube(countvalid, cube; indims=I mock_count = RQADeforestation.countvalid(mock_cube) @test mock_count.axes == (mock_cube.X, mock_cube.Y) - @test mock_count[1,1] == 20 - @test mock_count[1,2] == 30 - @test mock_count[2,2] == 27 - @test mock_count[2,1] == 0 -end - -""" -rqatrend(xout, xin, thresh) - -Compute the RQA trend metric for the non-missing time steps of xin, and save it to xout. -`thresh` specifies the epsilon threshold of the Recurrence Plot computation -""" -function rqatrend_recurrenceanalysis(pix_trend, pix, thresh=2) - ts = collect(skipmissing(pix)) - tau_pix = tau_recurrence(ts, thresh) - pix_trend .= RA._trend(tau_pix) + @test mock_count[1, 1] == 20 + @test mock_count[1, 2] == 30 + @test mock_count[2, 2] == 27 + @test mock_count[2, 1] == 0 end \ No newline at end of file From 27781fe108e52af1ef8e647039da3396bb2c5c9d Mon Sep 17 00:00:00 2001 From: Daniel Loos Date: Wed, 11 Jun 2025 10:37:19 +0200 Subject: [PATCH 6/8] Fix include of removed file --- src/RQADeforestation.jl | 1 - 1 file changed, 1 deletion(-) diff --git a/src/RQADeforestation.jl b/src/RQADeforestation.jl index c409457..9587b48 100644 --- a/src/RQADeforestation.jl +++ b/src/RQADeforestation.jl @@ -15,7 +15,6 @@ include("metrics.jl") include("auxil.jl") include("rqatrend.jl") include("analysis.jl") # TODO what is still needed from analysis now that rqatrend is in its own file? -include("timestats.jl") include("main.jl") end \ No newline at end of file From 5a7176f1d21f67f317760d58a2181a8ac5cc1970 Mon Sep 17 00:00:00 2001 From: Daniel Loos Date: Wed, 11 Jun 2025 10:37:43 +0200 Subject: [PATCH 7/8] Format analysis.jl --- src/analysis.jl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/analysis.jl b/src/analysis.jl index aa0aacb..da2853d 100644 --- a/src/analysis.jl +++ b/src/analysis.jl @@ -35,9 +35,9 @@ countvalid(cube; path=tempname() * ".zarr") = mapCube(countvalid, cube; indims=I Y(range(1, 5, length=15)), ) mock_data = allowmissing(rand(30, 10, 15)) - mock_data[1:10,1,1] .= missing - mock_data[:, 2,1] .= missing - mock_data[[1,5,9], 2,2] .= missing + mock_data[1:10, 1, 1] .= missing + mock_data[:, 2, 1] .= missing + mock_data[[1, 5, 9], 2, 2] .= missing mock_props = Dict() mock_cube = YAXArray(mock_axes, mock_data, mock_props) From 8bd0ab9f56ca4fdd29968efb82b0cab4220bc804 Mon Sep 17 00:00:00 2001 From: Daniel Loos Date: Wed, 11 Jun 2025 10:42:44 +0200 Subject: [PATCH 8/8] Fix Arifact path --- test/Artifacts.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Artifacts.toml b/test/Artifacts.toml index 9ba9b91..db39948 100644 --- a/test/Artifacts.toml +++ b/test/Artifacts.toml @@ -2,5 +2,5 @@ git-tree-sha1 = "1dc9d7aa975de4f5ecc652f34d6bbee706fcb7bd" [[rqatestdata.download]] - url = "https://github.com/meggart/RQADeforestationTestData/archive/refs/tags/v2.0.tar.gz" + url = "https://github.com/EarthyScience/RQADeforestationTestData/archive/refs/tags/v2.0.tar.gz" sha256 = "38a3e66a0505ed9d22c6e065627039089a421b0b143ac4c8d78aac45dd3dd497"