-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathworsica_sentinel_script_v5_waterleak_generating_average.py
66 lines (52 loc) · 1.84 KB
/
worsica_sentinel_script_v5_waterleak_generating_average.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/usr/bin/python3
# -*- coding: utf-8 -*-
"""
worsica script for edge detection using opencv
Author: rjmartins
Script to run all the image processing,
This does not include running the topo-bath image generation
since it is only once made and should be manually done.
Args:
>1) ZIPFILE is the imagesets name to merge separated by comma
>2) MERGEDNAME is a name for output merged file
Usage: ./worsica_sentinel_script_v5_merging.py [ZIPFILE] [MERGEDNAME]
e.g: ./worsica_sentinel_script_v5_merging.py S2A_MSIL2A_20181229T113501_N0211_R080_T29SMC_20181229T124502,S2A_MSIL2A_20181229T113501_N0211_R080_T29SMD_20181229T124502 merged_resampled_imagesets_2018_12_29
"""
import sys
import worsica_leakdetection
import traceback
WORKSPACE_PATH = '.'
SCRIPT_PATH = '/usr/local/worsica_web_products'
def run_script(args):
'''
run all the image processing
'''
# resample
try:
print(WORKSPACE_PATH)
print('---------------------------------------------')
print('-- 1) Do climatology ' + args[1] + ' with ' + args[2] + ' (' + args[3] + ') --')
print('---------------------------------------------')
imagesetNames = [WORKSPACE_PATH + '/' + iN + '/' + iN + '.tif' for iN in args[2].split(',')]
waterIndexes = args[3].split(',')
worsica_leakdetection.generate_average(
WORKSPACE_PATH +
'/' +
args[1] +
'/' +
args[1] +
'.tif',
imagesetNames,
waterIndexes)
except BaseException:
traceback.print_exc()
exit(1)
if __name__ == '__main__':
print(sys.argv)
if len(sys.argv) != 4:
print(
"Usage: ./worsica_sentinel_script_v5_generating_average.py [AVG_IMAGE_NAME] [MERGED_IMAGESETS_NAME] [WATER_INDEX]")
exit(1)
else:
run_script(sys.argv)
exit(0)