Skip to content

Commit c709cee

Browse files
committed
Remove timestats
1 parent 52498c1 commit c709cee

File tree

3 files changed

+24
-85
lines changed

3 files changed

+24
-85
lines changed

Project.toml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ authors = ["Felix Cremer <[email protected]>, Daniel Loos <dloos@bgc-
44
version = "1.0.0-DEV"
55

66
[deps]
7-
AWSS3 = "1c724243-ef5b-51ab-93f4-b0a88ac62a95"
87
ArchGDAL = "c9ce4bd3-c3d5-55b8-8973-c0e20141b8c3"
98
ArgParse = "c7e460c6-2fb9-53a9-8c5b-16f535851c63"
109
ConstructionBase = "187b0558-2788-49d3-abe0-74a17ed4e7c9"
@@ -25,9 +24,9 @@ GeoFormatTypes = "68eda718-8dee-11e9-39e7-89f7f65f511f"
2524
Glob = "c27321d9-0574-5035-807b-f59d2c89b15c"
2625
ImageMorphology = "787d08f9-d448-5407-9aad-5290dd7ab264"
2726
KML = "1284bf3a-1e3d-4f4e-a7a9-b9d235a28f35"
27+
LazyArtifacts = "4af54fe1-eca0-43a8-85a7-787d91b784e3"
2828
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
2929
LoggingExtras = "e6f89c97-d47a-5376-807f-9c37f3926c36"
30-
Minio = "4281f0d9-7ae0-406e-9172-b7277c1efa20"
3130
Missings = "e1d29d7a-bbdc-5cf2-9ac0-f12de2c33e28"
3231
NetCDF = "30363a11-5582-574a-97bb-aa9a979735b9"
3332
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
@@ -46,7 +45,6 @@ YAXArrays = "c21b50f5-aa40-41ea-b809-c0f5e47bfa5c"
4645
Zarr = "0a941bbe-ad1d-11e8-39d9-ab76183a1d99"
4746

4847
[compat]
49-
AWSS3 = "0.10.4"
5048
AllocCheck = "0.2.2"
5149
Aqua = "0.8.13"
5250
ArchGDAL = "0.10"
@@ -71,10 +69,10 @@ GeoFormatTypes = "0.4"
7169
Glob = "1"
7270
ImageMorphology = "0.4.5"
7371
KML = "0.2"
72+
LazyArtifacts = "1.11.0"
7473
Libdl = "1.10"
7574
LinearAlgebra = "1.10"
7675
LoggingExtras = "1"
77-
Minio = "0.2.2"
7876
Missings = "1"
7977
NetCDF = "0.12"
8078
Pkg = "1.10"
@@ -93,7 +91,7 @@ TestItems = "1.0"
9391
TimeseriesSurrogates = "2"
9492
UnicodePlots = "3"
9593
YAXArrayBase = "0.6, 0.7"
96-
YAXArrays = "0.5, 0.6"
94+
YAXArrays = "0.5, 0.6, 0.7"
9795
Zarr = "0.9"
9896
julia = "1.11"
9997

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

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

src/RQADeforestation.jl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ include("auxil.jl")
1818
include("rqatrend.jl")
1919
include("analysis.jl") # TODO what is still needed from analysis now that rqatrend is in its own file?
2020
include("cluster.jl")
21-
include("timestats.jl")
2221
include("main.jl")
2322

2423
end

src/main.jl

Lines changed: 20 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,7 @@
11
using ArgParse
22
using YAXArrays: YAXDefaults
3-
using ArchGDAL: ArchGDAL
4-
using PyramidScheme
5-
using AWSS3: global_aws_config, S3Path
6-
using FilePathsBase: exists
73

84

9-
#using YAXArrays, Zarr
10-
using Minio: MinioConfig
11-
12-
global_aws_config(MinioConfig("http://s3.fairsendd.eodchosting.eu",region="us-east-1"))
13-
145
const argparsesettings = ArgParseSettings()
156

167
ArgParse.parse_item(::Type{Date}, x::AbstractString) = Date(x)
@@ -78,121 +69,72 @@ function main(;
7869
tiles::Vector{String},
7970
continent::String,
8071
indir::String,
81-
outstore=Zarr.S3Store("europe-forest-change"),
82-
outdir="results",
83-
tempfolder = S3Path(outstore.bucket, "intermediates/"),
72+
outdir="out.zarr",
8473
start_date::Date,
8574
end_date::Date,
8675
polarisation="VH",
8776
orbit="D",
8877
threshold=3.0,
8978
folders=["V1M0R1", "V1M1R1", "V1M1R2"],
90-
stack=:dae,
91-
postprocess=true,
92-
forestdir="data/forest20m_new",
93-
delete_intermediate=false
79+
stack=:dae
9480
)
95-
#global_aws_config(MinioConfig("http://s3.fairsendd.eodchosting.eu",region="us-east-1",username="ufew8gJku5hRY7VD6jbEjRi8VnvDfeEv",password="dqZdzWCLB7a9gTshL29AnQWGqL3krwnS"))
9681
in(orbit, ["A", "D"]) || error("Orbit needs to be either A or D")
9782
if isdir(indir) && isempty(indir)
9883
error("Input directory $indir must not be empty")
9984
end
100-
101-
if isdir(tempfolder)
85+
if isdir(outdir)
10286
@warn "Resume from existing output directory"
10387
else
104-
mkdir(tempfolder, recursive=true)
88+
mkdir(outdir)
10589
@info "Write output to $outdir"
10690
end
91+
10792
if monthday(start_date) != monthday(end_date)
10893
@warn "Selected time series does not include a multiple of whole years. This might introduce seasonal bias."
10994
end
11095

111-
YAXDefaults.workdir[] = tempfolder
112-
@show typeof(tempfolder)
96+
YAXDefaults.workdir[] = outdir
11397

114-
corruptedfiles = open("corrupted_tiles.txt", "w")
98+
corruptedfiles = "corrupted_tiles.txt"
11599
# TODO save the corrupt files to a txt for investigation
116100
for tilefolder in tiles
117-
@show tilefolder
118-
outpath = joinpath(outdir, "postprocess_$tilefolder.zarr/")
119-
@show outpath
120-
if outpath in Zarr.subdirs(outstore, outdir)
121-
println("Skip already processed tile $tilefolder")
122-
continue
123-
end
124-
sub = first(folders)
125-
#@show glob("$(sub)/*$(continent)*20M/$(tilefolder)*/*$(polarisation)_$(orbit)*.tif", indir)
126-
filenamelist = [glob("$(sub)/*$(continent)*20M/$(tilefolder)*/*$(polarisation)_$(orbit)*.tif", indir) for sub in folders]
101+
filenamelist = [glob("$(sub)/*$(continent)*20M/$(tilefolder)/*$(polarisation)_$(orbit)*.tif", indir) for sub in folders]
127102
allfilenames = collect(Iterators.flatten(filenamelist))
128-
#@show allfilenames
103+
129104
relorbits = unique([split(basename(x), "_")[5][2:end] for x in allfilenames])
130105
@show relorbits
131106

132107
for relorbit in relorbits
133-
path = S3Path(joinpath(YAXDefaults.workdir[], "$(tilefolder)_rqatrend_$(polarisation)_$(orbit)$(relorbit)_thresh_$(threshold)"))
134-
#s3path = "s3://"*joinpath(outstore.bucket, path)
135-
@show path
136-
exists(path * ".done") && continue
137-
exists(path * "_zerotimesteps.done") && continue
138108
filenames = allfilenames[findall(contains("$(relorbit)_E"), allfilenames)]
139109
@time cube = gdalcube(filenames, stack)
140-
141110

111+
path = joinpath(YAXDefaults.workdir[], "$(tilefolder)_rqatrend_$(polarisation)_$(orbit)$(relorbit)_thresh_$(threshold)")
112+
@show path
113+
ispath(path * ".done") && continue
114+
ispath(path * "_zerotimesteps.done") && continue
142115

143116
tcube = cube[Time=start_date .. end_date]
144117
@show size(cube)
145118
@show size(tcube)
146119
if size(tcube, 3) == 0
147-
touch(S3Path(path * "_zerotimesteps.done"))
120+
touch(path * "_zerotimesteps.done")
148121
continue
149122
end
150123
try
151-
orbitoutpath = string(path * ".zarr/")
152-
# This is only necessary because overwrite=true doesn't work on S3 based Zarr files in YAXArrays
153-
# See https://github.com/JuliaDataCubes/YAXArrays.jl/issues/511
154-
if exists(S3Path(orbitoutpath))
155-
println("Deleting path $orbitoutpath")
156-
rm(S3Path(orbitoutpath), recursive=true)
157-
end
158-
@show orbitoutpath
159-
# This seems to ignore the overwrite keyword when the outpath point to S3.
160-
@time rqatrend(tcube; thresh=threshold, outpath=orbitoutpath, overwrite=true)
161-
if delete_intermediate == false
162-
PyramidScheme.buildpyramids(orbitoutpath)
163-
Zarr.consolidate_metadata(orbitoutpath)
164-
end
124+
outpath = path * ".zarr"
125+
@time rqatrend(tcube; thresh=threshold, outpath=outpath, overwrite=true)
126+
Zarr.consolidate_metadata(outpath)
165127
catch e
166128

167129
if hasproperty(e, :captured) && e.captured.ex isa ArchGDAL.GDAL.GDALError
168-
println(corruptedfiles, "Found GDALError:")
169-
println(corruptedfiles, e.captured.ex.msg)
130+
println("Found GDALError:")
131+
println(e.captured.ex.msg)
170132
continue
171133
else
172134
rethrow(e)
173135
end
174136
end
175-
donepath = path * ".done"
176-
@show donepath
177-
touch(S3Path(path * ".done"))
178-
end
179-
if postprocess
180-
@show outpath
181-
DD.STRICT_BROADCAST_CHECKS[] = false
182-
183-
RQADeforestation.postprocess(tilefolder, tempfolder, outpath, forestdir)
184-
Zarr.consolidate_metadata(outpath)
185-
DD.STRICT_BROADCAST_CHECKS[] = true
186-
#base = basename(outpath)
187-
#@show base
188-
#command = `aws --endpoint-url http://s3.fairsendd.eodchosting.eu s3 cp --recursive $outpath s3://europe-forest-change/$base`
189-
190-
#run(command)
137+
touch(path * ".done")
191138
end
192-
if delete_intermediate
193-
rm(tempfolder, force=true, recursive=true)
194-
end
195-
196-
197139
end
198140
end

0 commit comments

Comments
 (0)