Skip to content

Commit 51f3318

Browse files
committed
Revert "Skip nan time steps and classify the rqa trend results into UInt8 (#101)"
This reverts commit 042d19e.
1 parent f66e269 commit 51f3318

File tree

4 files changed

+11
-27
lines changed

4 files changed

+11
-27
lines changed

Project.toml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ GeoFormatTypes = "68eda718-8dee-11e9-39e7-89f7f65f511f"
2525
Glob = "c27321d9-0574-5035-807b-f59d2c89b15c"
2626
ImageMorphology = "787d08f9-d448-5407-9aad-5290dd7ab264"
2727
KML = "1284bf3a-1e3d-4f4e-a7a9-b9d235a28f35"
28-
LazyArtifacts = "4af54fe1-eca0-43a8-85a7-787d91b784e3"
2928
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
3029
LoggingExtras = "e6f89c97-d47a-5376-807f-9c37f3926c36"
3130
Minio = "4281f0d9-7ae0-406e-9172-b7277c1efa20"
@@ -72,7 +71,6 @@ GeoFormatTypes = "0.4"
7271
Glob = "1"
7372
ImageMorphology = "0.4.5"
7473
KML = "0.2"
75-
LazyArtifacts = "1.11.0"
7674
Libdl = "1.10"
7775
LinearAlgebra = "1.10"
7876
LoggingExtras = "1"
@@ -95,7 +93,7 @@ TestItems = "1.0"
9593
TimeseriesSurrogates = "2"
9694
UnicodePlots = "3"
9795
YAXArrayBase = "0.6, 0.7"
98-
YAXArrays = "0.5, 0.6, 0.7"
96+
YAXArrays = "0.5, 0.6"
9997
Zarr = "0.9"
10098
julia = "1.11"
10199

@@ -104,13 +102,13 @@ AllocCheck = "9b6a8646-10ed-4001-bbdc-1d2f46dfbb1a"
104102
Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595"
105103
BenchmarkTools = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf"
106104
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
107-
Libdl = "8f399da3-3557-5675-b5ff-fb832c97cbdb"
108105
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
109106
PythonCall = "6099a3de-0909-46bc-b1f4-468b9a2dfc0d"
110107
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
111108
StaticTools = "86c06d3c-3f03-46de-9781-57580aa96d0a"
112109
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
113110
TestItemRunner = "f8b46487-2199-4994-9208-9a1283c18c0a"
111+
Libdl = "8f399da3-3557-5675-b5ff-fb832c97cbdb"
114112

115113
[targets]
116114
test = ["Test", "TestItemRunner", "Pkg", "Random", "AllocCheck", "BenchmarkTools", "Aqua", "Documenter", "StaticTools", "PythonCall", "Libdl"]

README.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88

99
This is the Julia package developed within the [FAIRSenDD project](https://github.com/EarthyScience/FAIRSenDD).
1010

11-
The aim of this project is to provide a forest change detection algorithm in Julia.
12-
1311
## Citation
1412

1513
F. Cremer, M. Urbazaev, J. Cortés, J. Truckenbrodt, C. Schmullius and C. Thiel, "Potential of Recurrence Metrics from Sentinel-1 Time Series for Deforestation Mapping," in IEEE Journal of Selected Topics in Applied Earth Observations and Remote Sensing, vol. 13, pp. 5233-5240, 2020, doi: [10.1109/JSTARS.2020.3019333](https://dx.doi.org/10.1109/JSTARS.2020.3019333).

src/rqatrend.jl

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ using Distances
88
Compute the RQA trend metric for the datacube `cube` with the epsilon threshold `thresh`.
99
"""
1010
function rqatrend(cube; thresh=2, outpath=tempname() * ".zarr", overwrite=false, kwargs...)
11-
mapCube(rqatrend, cube, thresh; indims=InDims("Time"), outdims=OutDims(; outtype=UInt8, path=outpath, overwrite, kwargs...))
11+
@show outpath
12+
mapCube(rqatrend, cube, thresh; indims=InDims("Time"), outdims=OutDims(; outtype=Float32, path=outpath, overwrite, kwargs...))
1213
end
1314

1415
@testitem "rqatrend cube" begin
@@ -30,8 +31,8 @@ end
3031

3132
mock_trend = rqatrend(mock_cube; thresh=0.5)
3233
@test mock_trend.axes == (mock_cube.X, mock_cube.Y)
33-
@test eltype(mock_trend) == Union{Missing, UInt8}
34-
34+
diff = abs(mean(mock_trend))
35+
@test diff < 0.5
3536
end
3637

3738
"""rqatrend(path::AbstractString; thresh=2, outpath=tempname()*".zarr")
@@ -48,24 +49,10 @@ rqatrend(xout, xin, thresh)
4849
Compute the RQA trend metric for the non-missing time steps of xin, and save it to xout.
4950
`thresh` specifies the epsilon threshold of the Recurrence Plot computation
5051
"""
51-
function rqatrend(pix_trend, pix, thresh=2, lowerbound=-5., upperbound=-0.5)
52-
pix_trend .= classify_rqatrend(rqatrend_impl(pix; thresh); lowerbound, upperbound)
53-
end
54-
55-
function classify_rqatrend(trend; lowerbound=Float32(-5.0), upperbound=Float32(-0.5))
56-
ctrend = clamp(trend, lowerbound, upperbound)
57-
rlength = upperbound - lowerbound
58-
return round(UInt8, 255-((ctrend - lowerbound) / rlength) * 255)
52+
function rqatrend(pix_trend, pix, thresh=2)
53+
pix_trend .= rqatrend_impl(pix; thresh)
5954
end
6055

61-
@testitem "classify_rqatrend" begin
62-
import AllocCheck
63-
@test RQADeforestation.classify_rqatrend(-4.999) === UInt8(255)
64-
@test RQADeforestation.classify_rqatrend(1) === UInt8(0)
65-
@test RQADeforestation.classify_rqatrend(-0.52) === UInt8(1)
66-
@test RQADeforestation.classify_rqatrend(-6) === UInt8(255)
67-
@test isempty( AllocCheck.check_allocs(RQADeforestation.classify_rqatrend, (Float32,)))
68-
end
6956

7057
function rqatrend_impl(data; thresh=2, border=10, theiler=1, metric=CheckedEuclidean())
7158
# simplified implementation of https://stats.stackexchange.com/a/370175 and https://github.com/joshday/OnlineStats.jl/blob/b89a99679b13e3047ff9c93a03c303c357931832/src/stats/linreg.jl
@@ -131,7 +118,7 @@ function tau_rr(y, d; thresh=2, metric=CheckedEuclidean())
131118
nominator = 0
132119
denominator = 0
133120
@inbounds for i in 1:length(y)-d
134-
if y[i] === missing || y[i+d] === missing|| isnan(y[i]) || isnan(y[i+d])
121+
if y[i] === missing || y[i+d] === missing
135122
continue
136123
end
137124
nominator += evaluate(metric, y[i], y[i+d]) <= _thresh

test/testdata.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11

22
@testitem "testdata main" begin
33
import Pkg: Artifacts.@artifact_str
4-
using LazyArtifacts
54
testdatapath = artifact"rqatestdata/RQADeforestationTestData-2.0"
65

76
testdir = tempname()
@@ -25,6 +24,8 @@
2524
a = open_dataset(outdir * "/E051N018T3_rqatrend_VH_D022_thresh_3.0.zarr").layer
2625

2726
@test size(a) == (50, 74)
27+
@test minimum(a) < 0
28+
@test maximum(a) > 0
2829
end
2930

3031
@testitem "testdata julia_main" begin

0 commit comments

Comments
 (0)