Skip to content

Commit

Permalink
Merge pull request #85 from kleok/dev
Browse files Browse the repository at this point in the history
Jupyter notebook improvements & ReadMe updates
  • Loading branch information
kleok committed Sep 3, 2024
2 parents b363e1b + 3c131ad commit e8de3ae
Show file tree
Hide file tree
Showing 9 changed files with 146 additions and 625 deletions.
34 changes: 0 additions & 34 deletions FLOODPY_env.yml

This file was deleted.

582 changes: 109 additions & 473 deletions Floodpyapp_Vit.ipynb

Large diffs are not rendered by default.

File renamed without changes.
16 changes: 9 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ Recommended setup: Python 3.9+, SNAP 9.0+

### 1.1 Install snap gpt including Sentinel-1 toolbox

You can download SNAP manually from [here](https://step.esa.int/main/download/snap-download/) and install it using the following commands:
Please download ESA-SNAP (All Toolboxes) from [here](https://step.esa.int/main/download/snap-download/) and install it using the following commands:

```bash
chmod +x install_snap.sh
./install_snap.sh
chmod +x esa-snap_all_linux-10.0.0.sh
./esa-snap_all_linux-10.0.0.sh
```

### 1.2 Account setup for downloading Sentinel-1 acquisitions
Expand Down Expand Up @@ -63,10 +63,10 @@ You can download FLOODPY toolbox using the following command:
FLOODPY is written in Python3 and relies on several Python modules. We suggest to install them by using conda.
- Using **conda**
Create a new conda environement with required packages using the the file [FLOODPY_env.yml](https://github.com/kleok/FLOODPY/blob/main/FLOODPY_env.yml).
Create a new conda environement with required packages using the the file [FLOODPY_gpu_env.yml](https://github.com/kleok/FLOODPY/blob/main/FLOODPY_gpu_env.yml).
```
conda env create -f path_to_FLOODPY/FLOODPY_env.yml
conda env create -f path_to_FLOODPY/FLOODPY_gpu_env.yml
```
### 1.6 Set environmental variables (Optional)
Expand All @@ -84,13 +84,15 @@ FLOODPY generates a map with flooded regions based on Sentinel-1 GRD products an
Sentinel-1 orbits are downloaded using the [sentineleof](https://github.com/scottstanie/sentineleof)
You can run FLOODPY using the following jupyter notebooks as templates.
- [Floodpy statistical approach](https://nbviewer.org/github/kleok/FLOODPY/blob/main/Floodpyapp_notebook.ipynb)
- [Floodpy Deep learning approach](https://nbviewer.org/github/kleok/FLOODPY/blob/main/Floodpyapp_Vit.ipynb)
- [Floodpy statistical approach](https://nbviewer.org/github/kleok/FLOODPY/blob/main/Floodpyapp_stat.ipynb)
- [Floodpy deep learning approach](https://nbviewer.org/github/kleok/FLOODPY/blob/main/Floodpyapp_Vit.ipynb)
## 3. Documentation and citation
Algorithms implemented in the software are described in detail at our publications. If FLOODPY was useful for you, we encourage you to cite the following work:
- Karamvasis K, Karathanassi V. FLOMPY: An Open-Source Toolbox for Floodwater Mapping Using Sentinel-1 Intensity Time Series. Water. 2021; 13(21):2943. https://doi.org/10.3390/w13212943
- Kuro Siwo: 33 billion m2 under the water. A global multi-temporal satellite dataset for rapid flood mapping. https://paperswithcode.com/paper/kuro-siwo-12-1-billion-m-2-under-the-water-a
You can also have a look at other works that are using FLOODPY:
- Gounari 0., Falagas A., Karamvasis K., Tsironis V., Karathanassi V.,
Expand Down
46 changes: 0 additions & 46 deletions aux/install_snap.sh

This file was deleted.

23 changes: 22 additions & 1 deletion floodpy/Preprocessing_S1_data/snap_preprocessing_funcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ def perform_pair_preprocessing_2GRD_1GRD(gptcommand, primary1, primary2, seconda
subprocess.check_call(argvs, stdout=subprocess.DEVNULL, stderr=subprocess.STDOUT)
return 0

def perform_pair_preprocessing_2GRD_2GRD(gptcommand, primary1, primary2, secondary1, secondary2, outfile, Subset_AOI, xml_file, overwrite):
def perform_pair_preprocessing_2GRD_2GRD(gptcommand, primary1, primary2, secondary1, secondary2, outfile, Subset_AOI, xml_file, overwrite, print_esa_snap_logs = False):

"""
This function performs the preprocessing of the given pair from the
Expand All @@ -146,4 +146,25 @@ def perform_pair_preprocessing_2GRD_2GRD(gptcommand, primary1, primary2, seconda
'-Pfileout='+outfile]

subprocess.check_call(argvs, stdout=subprocess.DEVNULL, stderr=subprocess.STDOUT)

if print_esa_snap_logs:
print (argvs)
# Append argument for logging from ESA SNAP
argvs.append('-J-Dsnap.log.level=FINE')

# Print the command for manual execution
print("Running command:")
print(" ".join(argvs))

# Run the command while printing ESA SNAP logs to stdout in real-time
with subprocess.Popen(argvs, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, universal_newlines=True) as process:
for stdout_line in iter(process.stdout.readline, ""):
print(stdout_line, end="")
process.stdout.close()
return_code = process.wait()
if return_code:
raise subprocess.CalledProcessError(return_code, argvs)
else:
subprocess.check_call(argvs, stdout=subprocess.DEVNULL, stderr=subprocess.STDOUT)

return 0
19 changes: 6 additions & 13 deletions floodpy/utils/folium_categorical_legend.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
def get_folium_categorical_template():
def get_folium_categorical_template(categories):
template = """
{% macro html(this, kwargs) %}
Expand Down Expand Up @@ -36,20 +36,13 @@ def get_folium_categorical_template():
<div class='legend-title'>ESA WorldCover 2021 Categories</div>
<div class='legend-scale'>
<ul class='legend-labels'>
"""

<li><span style='background:rgb(0, 0, 0); opacity:1;'></span><b>No data</b></li>
<li><span style='background:rgb(0, 100, 0); opacity:1;'></span><b>Tree cover</b></li>
<li><span style='background:rgb(255, 187, 34); opacity:1;'></span><b>Shrubland</b></li>
<li><span style='background:rgb(255, 255, 76); opacity:1;'></span><b>Grassland</b></li>
<li><span style='background:rgb(240, 150, 255); opacity:1;'></span><b>Cropland</b></li>
<li><span style='background:rgb(250, 0, 0); opacity:1;'></span><b>Built-up</b></li>
<li><span style='background:rgb(180, 180, 180); opacity:1;'></span><b>Bare/sparse vegetation</b></li>
<li><span style='background:rgb(240, 240, 240); opacity:1;'></span><b>Snow and Ice</b></li>
<li><span style='background:rgb(0, 100, 200); opacity:1;'></span><b>Permanent water bodies</b></li>
<li><span style='background:rgb(0, 150, 160); opacity:1;'></span><b>Herbaceous wetland</b></li>
<li><span style='background:rgb(0, 207, 117); opacity:1;'></span><b>Mangroves</b></li>
<li><span style='background:rgb(250, 230, 160); opacity:1;'></span><b>Moss and lichen</b></li>
for category, color in categories.items():
template += f"<li><span style='background:rgb{color}; opacity:1;'></span><b>{category}</b></li>\n"


template += """
</ul>
</div>
</div>
Expand Down
24 changes: 0 additions & 24 deletions requirements.txt

This file was deleted.

27 changes: 0 additions & 27 deletions setup.py

This file was deleted.

0 comments on commit e8de3ae

Please sign in to comment.