Commit 0245d4681dbc5c3f3ec6aa0910b936d26cb50c7a

Authored by Louis Baetens
1 parent ef4b6504
Exists in master

ENH added the needed imports

ALCD/L1C_band_composition.py
... ... @@ -9,6 +9,7 @@ import json
9 9 import shutil
10 10 import subprocess
11 11 import tempfile
  12 +import argparse
12 13  
13 14  
14 15  
... ...
ALCD/all_run_alcd.py
... ... @@ -6,7 +6,6 @@ import os
6 6 import os.path as op
7 7 import json
8 8 import shutil
9   -import json
10 9 import argparse
11 10 import tempfile
12 11 import glob
... ...
ALCD/confidence_map_exploitation.py
... ... @@ -7,10 +7,6 @@ import os.path as op
7 7 import json
8 8 import glob
9 9 import otbApplication
10   -import gdal
11   -from PIL import Image
12   -from scipy import misc
13   -import subprocess
14 10 import numpy as np
15 11 import tempfile
16 12 from collections import defaultdict
... ...
ALCD/contour_from_labeled.py
... ... @@ -9,8 +9,6 @@ import glob
9 9 import otbApplication
10 10 import gdal
11 11 from PIL import Image
12   -from scipy import misc
13   -import glob
14 12 import numpy as np
15 13  
16 14  
... ... @@ -177,7 +175,7 @@ def rgb_contours_stacking(in_tif, contour_label_tif, out_png):
177 175 img = Image.fromarray(rgbArray)
178 176 img.save(op.join(op.dirname(out_png), 'quicklook.png'))
179 177  
180   - # superimpose the labels on the current RGB array
  178 + # superimpose the labels on the current RGB array
181 179 ds = gdal.Open(contour_label_tif)
182 180 label_band = np.array(ds.GetRasterBand(1).ReadAsArray())
183 181 label_band = label_band.astype(int)
... ...
ALCD/merge_shapefiles.py
... ... @@ -57,9 +57,7 @@ def merge_shapefiles(in_shp_list, class_list, out_shp):
57 57 def main():
58 58 mask_dir = '/mnt/data/home/baetensl/classification_clouds/Data/Full_orleans/In_data/Masks/'
59 59  
60   - out_shp = '/mnt/data/home/baetensl/classification_clouds/Data/Full_orleans/In_data/Masks/merged.shp'
61 60  
62   - merge_all_types(mask_dir, out_shp)
63 61  
64 62 if __name__ == '__main__':
65 63 main()
... ...
ALCD/metrics_exploitation.py
... ... @@ -353,7 +353,7 @@ def retrieve_Kfold_data(global_parameters, metrics_plotting = False, location =
353 353 met_nb = 0
354 354  
355 355 for metric in [accuracies, f1scores, recalls, precisions]:
356   - rnd = [(indices[met_nb] - 0.1 + 0.2*(float(k)/len(accuracies))) for k in range(len(accuracies))]
  356 + rnd = [(indices[met_nb] - 0.1 + 0.2*(float(j)/len(accuracies))) for j in range(len(accuracies))]
357 357 plt.scatter(rnd, metric, color='k', marker='.', alpha = 0.2)
358 358 met_nb += 1
359 359  
... ...
ALCD/quicklook_generator.py
... ... @@ -3,9 +3,12 @@
3 3  
4 4 import os
5 5 import os.path as op
  6 +import argparse
  7 +
6 8 import find_directory_names
7 9  
8 10  
  11 +
9 12 def create_jpg(in_jp2s, out_jpg):
10 13 '''
11 14 Create empty shapefiles based on the SRS of the in_tif
... ... @@ -60,10 +63,22 @@ def create_all_quicklook(location, out_dir):
60 63  
61 64  
62 65 def main():
63   - locations = ['Mongu', 'Gobabeb', 'RailroadValley', 'Arles', 'Marrakech']
64   - locations = ['Alta_Floresta_Brazil']
  66 + parser = argparse.ArgumentParser()
  67 +
  68 + parser.add_argument('-l', action='store', default=None, dest='locations', help='Locations, needs to be separated by a comma (e.g. "-l Arles,Gobabeb,Orleans")')
  69 +
  70 + results = parser.parse_args()
  71 + locations_to_parse = results.locations
  72 + if locations_to_parse != None:
  73 + locations = locations_to_parse.split(',')
  74 +
  75 + else:
  76 + locations = ['Mongu', 'Gobabeb', 'RailroadValley', 'Arles', 'Marrakech']
  77 + locations = ['Alta_Floresta_Brazil']
  78 +
65 79 for location in locations:
66   - out_dir = op.join('/mnt/data/home/baetensl/clouds_detection_git/Tools/tmp/Quicks', location)
  80 + #~ out_dir = op.join('/mnt/data/home/baetensl/clouds_detection_git/Tools/tmp/Quicks2', location)
  81 + out_dir = op.join('tmp', location)
67 82 create_all_quicklook(location, out_dir)
68 83  
69 84 return
... ...
ALCD/synthese_alcd_runs.py
... ... @@ -11,6 +11,7 @@ import shutil
11 11 import matplotlib.pyplot as plt
12 12 import glob
13 13 import ogr
  14 +import otbApplication
14 15 from matplotlib.lines import Line2D
15 16  
16 17 def get_main_directories(paths_configuration, locations, excluded):
... ...
PCC/statistics_synthesis.py
1 1 #!/usr/bin/python
2 2 # -*- coding: utf-8 -*-
3 3  
  4 +import os
4 5 import os.path as op
5 6 import glob
6 7 import numpy as np
... ...
Tools/files_gathering.py
... ... @@ -14,8 +14,8 @@ def list_available_dirs(algo):
14 14 if algo == 'alcd':
15 15 all_dirs = glob.glob(op.join('/mnt/data/home/baetensl/clouds_detection_git/Data_ALCD', '*_*'))
16 16 elif algo == 'pcc':
17   - all_dirs = glob.glob(op.join('/mnt/data/home/baetensl/clouds_detection_git/Data_PCC', '*_*'))
18   -
  17 + all_dirs = glob.glob(op.join('/mnt/data/home/baetensl/clouds_detection_git/Data_PCC/HOT016_final', '*_*'))
  18 + print(all_dirs)
19 19 return all_dirs
20 20  
21 21 def copy_quicklooks(out_dir, algo):
... ... @@ -55,15 +55,17 @@ def copy_quicklooks(out_dir, algo):
55 55 except:
56 56 pass
57 57  
58   - k = 0
59   - for f in range(len(src_files)):
60   - try:
61   - shutil.copy(src_files[f], out_files[f])
62   - k += 1
63   - except:
64   - pass
65   - if k < k_lim:
66   - print('Error with {}'.format(prefix))
  58 + k = 0
  59 + for f in range(len(src_files)):
  60 + shutil.copy(src_files[f], out_files[f])
  61 + k += 1
  62 + #~ try:
  63 + #~ shutil.copy(src_files[f], out_files[f])
  64 + #~ k += 1
  65 + #~ except:
  66 + #~ pass
  67 + if k < k_lim:
  68 + print('Error with {}'.format(prefix))
67 69  
68 70 #~ output_dir = op.join(out_dir, base_dir)
69 71 #~ if not op.exists (output_dir):
... ...