Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions src/main.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -84,24 +84,20 @@ 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

filenames = allfilenames[findall(contains("$(relorbit)_E"), allfilenames)]
@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
Expand Down
2 changes: 1 addition & 1 deletion src/rqatrend.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
8 changes: 7 additions & 1 deletion test/testdata.jl
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@

@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")

testdir = "tmp/testdata"
rm(testdir, recursive=true, force=true)
mkpath(testdir)
outdir = "$testdir/out.zarr"
outdir = "$testdir/out"
indir = "$testdir/in"
cp(testdatapath, indir)

Expand All @@ -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
Loading