-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
db29073
commit c6c779b
Showing
5 changed files
with
185 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
.idea |
Submodule esa-snap-docker
added at
467030
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
# docker build -t openeo_insar . | ||
# skopeo --insecure-policy copy --dest-tls-verify=false --multi-arch=all --format=oci docker-daemon:openeo_insar:latest docker://registry.stag.warsaw.openeo.dataspace.copernicus.eu/rand/openeo_insar:latest | ||
# docker run -it openeo_insar | ||
FROM ghcr.io/osgeo/gdal:ubuntu-small-3.10.0 | ||
|
||
# Install necessary packages | ||
RUN apt-get update && \ | ||
apt-get install -y \ | ||
jq \ | ||
xmlstarlet \ | ||
zip \ | ||
default-jre \ | ||
bc \ | ||
nano \ | ||
wget \ | ||
python3-pip \ | ||
curl \ | ||
parallel \ | ||
dpkg && \ | ||
rm -rf /var/lib/apt/lists/* | ||
|
||
# Download and install jacksum and s5cmd | ||
RUN curl -L -O 'https://s3.waw3-2.cloudferro.com/swift/v1/jacksum/jacksum_1.7.0-4.1_all.deb' && \ | ||
dpkg -i jacksum_1.7.0-4.1_all.deb && rm jacksum_1.7.0-4.1_all.deb && \ | ||
curl -L -O 'https://github.com/peak/s5cmd/releases/download/v2.2.2/s5cmd_2.2.2_linux_amd64.deb' && \ | ||
dpkg -i s5cmd_2.2.2_linux_amd64.deb && rm s5cmd_2.2.2_linux_amd64.deb | ||
|
||
#COPY ./utilities /src/utilities # Copy at the end of faile to avoid slow rebuilds | ||
ENV PATH="${PATH}:/src/utilities/" | ||
|
||
# Set environment variables | ||
ENV AWS_S3_ENDPOINT=eodata.dataspace.copernicus.eu \ | ||
# AWS_ACCESS_KEY_ID=ACCESS \ | ||
# AWS_SECRET_ACCESS_KEY=DATA \ | ||
AWS_HTTPS=YES \ | ||
AWS_VIRTUAL_HOSTING=FALSE | ||
|
||
|
||
|
||
### Install esa-snap ### | ||
ENV DEBIAN_FRONTEND=noninteractive \ | ||
LC_ALL=C.UTF-8 \ | ||
LANG=C.UTF-8 | ||
|
||
RUN apt-get update && \ | ||
apt-get install -y \ | ||
build-essential \ | ||
git \ | ||
wget \ | ||
python3 \ | ||
libgfortran5 | ||
|
||
LABEL authors="Michele Claus, Emile Sonneveld" | ||
LABEL maintainer="[email protected], [email protected]" | ||
|
||
ENV SNAPVER=11 | ||
|
||
RUN mkdir -p /src/snap | ||
COPY esa-snap-docker/response.varfile /src/snap/response.varfile | ||
|
||
# install and update snap | ||
RUN wget -q -O /src/snap/esa-snap_all_unix_${SNAPVER}_0_0.sh "https://step.esa.int/downloads/${SNAPVER}.0/installers/esa-snap_all_linux-${SNAPVER}.0.0.sh" && \ | ||
sh /src/snap/esa-snap_all_unix_${SNAPVER}_0_0.sh -q -varfile /src/snap/response.varfile && \ | ||
rm -f /src/snap/esa-snap_all_unix_${SNAPVER}_0_0.sh | ||
|
||
# update SNAP | ||
COPY esa-snap-docker/update_snap.sh /src/snap/update_snap.sh | ||
RUN sh /src/snap/update_snap.sh | ||
|
||
# add gpt to PATH | ||
ENV PATH="${PATH}:/usr/local/esa-snap/bin" | ||
|
||
|
||
ENV PATH="${PATH}:/src/" | ||
COPY . /src | ||
|
||
WORKDIR /src |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
#!/usr/bin/env python3 | ||
import base64 | ||
import glob | ||
import json | ||
import subprocess | ||
import sys | ||
import os | ||
import datetime | ||
from pathlib import Path | ||
|
||
start_time = datetime.datetime.now() | ||
|
||
argument_list = sys.argv[1:] | ||
|
||
if len(argument_list) > 0: | ||
input_dict = json.loads(base64.b64decode(argument_list[0].encode("utf8")).decode("utf8")) | ||
else: | ||
input_dict = { | ||
"message": "These are example arguments", | ||
"spatial_extent": { | ||
"west": 10.751, | ||
"south": 46.741, | ||
"east": 10.759, | ||
"north": 46.749 | ||
}, | ||
"temporal_extent": [ | ||
"2024-08-14", | ||
"2024-08-26" | ||
] | ||
} | ||
print(input_dict) | ||
print("AWS_ACCESS_KEY_ID= " + str(os.environ.get("AWS_ACCESS_KEY_ID", None))) # Don't print AWS_SECRET_ACCESS_KEY | ||
|
||
argument_list = [ | ||
"-s", input_dict["temporal_extent"][0], | ||
"-e", input_dict["temporal_extent"][1], | ||
# TODO: Specify spatial extent instead of point | ||
"-x", str((input_dict["spatial_extent"]["west"] + input_dict["spatial_extent"]["east"]) / 2), | ||
"-y", str((input_dict["spatial_extent"]["south"] + input_dict["spatial_extent"]["north"]) / 2), | ||
"-p", "vv", | ||
"-S", "IW3" # TODO: Dynamically determine sub-swat | ||
] | ||
containing_folder = Path(os.path.dirname(__file__)) | ||
|
||
# result_folder = containing_folder / "result" | ||
# result_folder.mkdir(parents=True, exist_ok=True) | ||
# result_folder = Path("/home/ubuntu") | ||
result_folder = Path.home() | ||
# tmp_insar = Path("/tmp/insar") | ||
# tmp_insar.mkdir(parents=True, exist_ok=True) | ||
tmp_insar = result_folder | ||
|
||
with open(result_folder / "output.txt", "w") as f: | ||
f.write(json.dumps(input_dict)) | ||
|
||
if "-o" in argument_list: | ||
index_of_o = argument_list.index("-o") | ||
# print("Ignoring -o parameter") | ||
# argument_list = argument_list[:index_of_o] + argument_list[index_of_o + 2:] | ||
if argument_list[index_of_o + 1] != "/home/ubuntu": | ||
raise Exception("Only /home/ubuntu is allowed as output folder") | ||
else: | ||
argument_list = ["-o", str(tmp_insar)] + argument_list | ||
|
||
# assert not any(tmp_insar.iterdir()) | ||
# cmd = [str(containing_folder /"utilities/sentinel1_burst_extractor_spatiotemporal.sh")] + argument_list | ||
os.environ["PATH"] = os.environ["PATH"] + ":" + str(containing_folder / "utilities") | ||
cmd = ["sentinel1_burst_extractor_spatiotemporal.sh"] + argument_list | ||
print(cmd) | ||
# subprocess.run(cmd, check=True, cwd=containing_folder / "utilities", stderr=subprocess.STDOUT) | ||
|
||
print("seconds since start insar.py: " + str((datetime.datetime.now() - start_time).seconds)) | ||
|
||
# GPT means "Graph Processing Toolkit" in this context | ||
glob_str = str(tmp_insar / "*/manifest.safe") | ||
bursts = glob.glob(glob_str) | ||
if len(bursts) == 0: | ||
raise Exception("No files found with glob: " + glob_str) | ||
|
||
input1 = bursts[0] | ||
input2 = bursts[1] | ||
# bursts_relative = [str(Path(burst).relative_to(tmp_insar)) for burst in bursts] | ||
# iw_component = bursts_relative[0].split("_")[4] | ||
# input1 = tmp_insar / "S1A_SLC_20240814T171550_030345_IW3_VV_441043.SAFE/manifest.safe" | ||
# input2 = tmp_insar / "S1A_SLC_20240826T171550_030345_IW3_VV_442708.SAFE/manifest.safe" | ||
# input1 = tmp_insar / "S1A_SLC_20240814T171550_030345_IW3_VV_042880.SAFE/manifest.safe" | ||
# input2 = tmp_insar / "S1A_SLC_20240826T171550_030345_IW3_VV_043168.SAFE/manifest.safe" | ||
# ('-Pinput1=/home/ubuntu/S1A_SLC_20240814T171550_030345_IW3_VV_441043.SAFE/manifest.safe', | ||
# '-Pinput2=/home/ubuntu/S1A_SLC_20240825T052728_359500_IW2_VV_442501.SAFE/manifest.safe',) | ||
|
||
gpt_cmd = [ | ||
"gpt", | ||
"/src/s1-workflows/graphs/pre-processing_stackOverview_2images_GeoTiff.xml", | ||
f"-Pinput1={input1}", f"-Pinput2={input2}", | ||
f"-PstackOverview_filename={result_folder}/stackOverview_2images.json", | ||
f"-PcoregisteredStack_filename={result_folder}/Orb_Stack_2images" | ||
] | ||
print(gpt_cmd) | ||
subprocess.run(gpt_cmd, check=True, stderr=subprocess.STDOUT) | ||
print("seconds since start insar.py: " + str((datetime.datetime.now() - start_time).seconds)) | ||
|
||
# CWL Will find the result files in HOME or CD | ||
|
||
files = glob.glob(str(result_folder / "*.*")) | ||
print("Files in target dir: " + str(files)) |
Submodule utilities
added at
6b0492