Skip to content

Commit

Permalink
Update cwl directory output
Browse files Browse the repository at this point in the history
  • Loading branch information
danlooo committed Dec 11, 2024
1 parent 0ee64c8 commit 970f4bf
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 17 deletions.
18 changes: 14 additions & 4 deletions ogc-app-cwl/fairsendd.cwl
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ $graph:
label: continent
doc: Continent ID within Equi7Grid. One of AF, AN, AS, EU, NA, OC, SA
type: string
in-dir:
label: in-dir
doc: Path to input directory containing Sentinel-1 Sigma0 tile data
type: Directory
tile:
label: tile
doc: tile ID of the area to be analyzed within Equi7Grid, e.g. E036N075T3
Expand All @@ -18,13 +22,14 @@ $graph:
outputs:
out_cube:
doc: Path to output zarr data cube
type: File
type: Directory
outputSource: rqa/out_cube

steps:
rqa:
in:
continent: continent
in-dir: in-dir
tile: tile
run: '#cmd-rqa'
out:
Expand All @@ -35,21 +40,26 @@ $graph:
requirements:
DockerRequirement:
dockerPull: danlooo/fairsendd:latest
InlineJavascriptRequirement: {}

inputs:
continent:
type: string
inputBinding:
position: 2
in-dir:
type: Directory
inputBinding:
position: 1
tile:
type: string
inputBinding:
position: 2
position: 3

outputs:
out_cube:
type: stdout
type: Directory
outputBinding:
glob: out.zarr
id: cmd-rqa
$namespaces:
edam: http://edamontology.org/
Expand Down
36 changes: 28 additions & 8 deletions ogc-app-cwl/run.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ using Glob: glob
using YAXArrays: YAXDefaults
using ArgParse
using RQADeforestation: gdalcube, rqatrend
using DimensionalData: (..)
using DimensionalData
using Dates: Date
using Distributed: addprocs, @everywhere

Expand Down Expand Up @@ -35,6 +35,10 @@ function parse_commandline()
help = "Path to output zarr dataset"
default = "out.zarr"

"in-dir"
help = "Path to input"
required = true

"continent"
help = "continent code for the tile to be processed"
required = true
Expand All @@ -54,18 +58,33 @@ function main()
orbit = parsed_args["orbit"]
thresh = parsed_args["threshold"]

indir = "/eodc/products/eodc.eu/S1_CSAR_IWGRDH/SIG0/"
indir = parsed_args["in-dir"]
readdir(indir) # check if inputdir is available

if isdir(indir) && isempty(indir)
@error "Input directory $indir must not be empty"
end

outdir = parsed_args["out-dir"]

if isdir(outdir)
@warn "Resume from existing output directory"
else
mkdir(outdir)
@info "Write output to $outdir"
end

YAXDefaults.workdir[] = outdir
println(outdir)

continent = parsed_args["continent"]
tilefolder = parsed_args["tile"]
folders = ["V01R01", "V0M2R4", "V1M0R1", "V1M1R1", "V1M1R2"]
tile = parsed_args["tile"]

filenamelist = [glob("$(sub)/*$(continent)*20M/$(tilefolder)/*$(pol)_$(orbit)*.tif", indir) for sub in folders]
allfilenames = collect(Iterators.flatten(filenamelist))
pattern = "V*R*/EQUI7_$continent*20M/$tile/*"
allfilenames = glob(pattern, indir) |> collect

if length(allfilenames) == 0
error("No input files found for given tile $tile")
end

relorbits = unique([split(basename(x), "_")[5][2:end] for x in allfilenames])
y = parsed_args["year"]
Expand All @@ -74,7 +93,8 @@ function main()
filenames = allfilenames[findall(contains("$(relorbit)_E"), allfilenames)]

cube = gdalcube(filenames)
path = joinpath(outdir, "$(tilefolder)_rqatrend_$(pol)_$(relorbit)_thresh_$(thresh)_year_$(y)")
path = joinpath(outdir, "$(tile)_rqatrend_$(pol)_$(relorbit)_thresh_$(thresh)_year_$(y)")

ispath(path * ".done") && continue
tcube = cube[Time=Date(y - 1, 7, 1) .. Date(y + 1, 7, 1)]

Expand Down
7 changes: 2 additions & 5 deletions ogc-app-cwl/run.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
#! /usr/bin/env sh

docker build . -t danlooo/fairsendd
docker push danlooo/fairsendd

cwltool fairsendd.cwl#rqa --continent AF --tile E036N075T3
docker run danlooo/fairsendd AF E036N075T3
docker run --env=HOME=/tmp/YgEokx --user 1234:1234 danlooo/fairsendd AF E036N075T3
# docker push danlooo/fairsendd
cwltool fairsendd.cwl#rqa --continent NA --tile E036N075T3 --in-dir ../etc/data/eodc/products/eodc.eu/S1_CSAR_IWGRDH/SIG0/

0 comments on commit 970f4bf

Please sign in to comment.