get_clouds.py
1 #!/usr/bin/env python3 2 # -*- coding: utf-8 -*- 3 """ 4 Created on Fri Mar 11 11:39:01 2022 5 6 @author: aleoikon 7 """ 8 9 import pandas as pd 10 import numpy as np 11 12 #s2mtcp_target = '/home/aleoikon/Documents/data/ssl/s2mtcp/patches/task11238/' 13 14 s2mtcp_target = '/home/aleoikon/Documents/data/ssl/s2mtcp/patches_colorshifted/task1/' 15 16 df = pd.read_csv(s2mtcp_target+'dataset.csv', dtype=str) 17 18 count_left = 0 19 count_right = 0 20 index_left =[] 21 index_right=[] 22 clouded_index =[] 23 for index in range(len(df)): 24 img1 = np.load(s2mtcp_target+df['pair1'][index]) 25 img2 = np.load(s2mtcp_target+df['pair2'][index]) 26 if np.max(img1[:,:,13]) != 0: 27 index_left.append(index) 28 count_left+=1 29 30 if np.max(img2[:,:,13]) != 0: 31 index_right.append(index) 32 count_right+=1 33 34 if np.max(img1[:,:,13]) != 0 or np.max(img2[:,:,13]) != 0: 35 clouded_index.append(index) 36 37 38 to_Drop = np.array(clouded_index) 39 40 uncloud_df = df.drop(to_Drop) 41 uncloud_df.to_csv(s2mtcp_target+'dataset_unclouded.csv') 42 43 44 img = np.load(s2mtcp_target+df['pair2'][14004]) 45 import matplotlib.pyplot as plt 46 plt.imshow(img[:,:,13]) 47 np.max(img[:,:,13])!=0