Skip to content
Merged
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: 4 additions & 4 deletions src/main.jl
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ ArgParse.parse_item(::Type{Date}, x::AbstractString) = Date(x)

"--orbit", "-o"
help = "One of: Orbit number, 'A' for ascending, 'D' for descending, '*' for all orbits"
default = "A"
default = "D"

"--out-dir", "-d"
help = "Path to output zarr dataset"
Expand All @@ -53,7 +53,7 @@ ArgParse.parse_item(::Type{Date}, x::AbstractString) = Date(x)

"--folders", "--folder"
help = "subfolders taken into account"
default = ["V01R01", "V0M2R4", "V1M0R1", "V1M1R1", "V1M1R2"]
default = ["V1M0R1", "V1M1R1", "V1M1R2"]
arg_type = String
nargs = '*'
end
Expand Down Expand Up @@ -98,17 +98,17 @@ function main(;
corruptedfiles = "corrupted_tiles.txt"
# TODO save the corrupt files to a txt for investigation
for tilefolder in tiles

filenamelist = [glob("$(sub)/*$(continent)*20M/$(tilefolder)/*$(polarisation)_$(orbit)*.tif", indir) for sub in folders]
allfilenames = collect(Iterators.flatten(filenamelist))

relorbits = unique([split(basename(x), "_")[5][2:end] for x in allfilenames])
@show relorbits

for relorbit in relorbits
filenames = allfilenames[findall(contains("$(relorbit)_E"), allfilenames)]
@time cube = gdalcube(filenames, stack)

path = joinpath(YAXDefaults.workdir[], "$(tilefolder)_rqatrend_$(polarisation)_$(orbit)$(relorbit)_thresh_$(threshold)_year_$(y)")
path = joinpath(YAXDefaults.workdir[], "$(tilefolder)_rqatrend_$(polarisation)_$(orbit)$(relorbit)_thresh_$(threshold)")
@show path
ispath(path * ".done") && continue
ispath(path * "_zerotimesteps.done") && continue
Expand Down
37 changes: 35 additions & 2 deletions test/testdata.jl
Original file line number Diff line number Diff line change
@@ -1,11 +1,42 @@

@testitem "testdata main" begin
import Pkg: Artifacts.@artifact_str, ensure_artifact_installed

ensure_artifact_installed("rqatestdata", "Artifacts.toml")
testdatapath = joinpath(artifact"rqatestdata", "RQADeforestationTestData-2.0")

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

using Zarr
using YAXArrays
using Dates
RQADeforestation.main(;
tiles=["E051N018T3"],
continent="EU",
indir=indir,
start_date=Date("2021-01-01"),
end_date=Date("2022-01-01"),
outdir=outdir
)
a = open_dataset(outdir * "/E051N018T3_rqatrend_VH_D022_thresh_3.0.zarr").layer

@test size(a) == (50, 74)
@test minimum(a) < 0
@test maximum(a) > 0
end

@testitem "testdata julia_main" begin
import Pkg: Artifacts.@artifact_str, ensure_artifact_installed

ensure_artifact_installed("rqatestdata", "Artifacts.toml")
testdatapath = joinpath(artifact"rqatestdata", "RQADeforestationTestData-2.0")

testdir = "tmp/testdata"
testdir = tempname()
rm(testdir, recursive=true, force=true)
mkpath(testdir)
outdir = "$testdir/out.zarr"
Expand All @@ -17,7 +48,7 @@
"--tile", "E051N018T3",
"--continent", "EU",
"--start-date", "2021-01-01",
"--end-date", "2021-12-31",
"--end-date", "2022-01-01",
"--in-dir", indir,
"--out-dir", outdir,
])
Expand All @@ -26,4 +57,6 @@
# test short cut implementation using cache files
RQADeforestation.julia_main()
copy!(ARGS, OLD_ARGS)

@test outdir |> readdir |> length > 1
end
Loading