Commit 599a3b41 authored by luroth's avatar luroth
Browse files

dd.

parent bb81d8fa
......@@ -394,10 +394,11 @@ def process_NadirCC_LCCC_LA_BBCH30(path_campaign, GSD):
X = sc_x.transform(X)
# Log delta to weight close-to-zero values higher
y = np.log(np.abs(df_training['delta_to_BBCH']) + 1) * np.sign(df_training['delta_to_BBCH'])
y = np.log1p(np.abs(df_training['delta_to_BBCH'])) * np.sign(df_training['delta_to_BBCH'])
svm_predictor = svm.SVR(C=32, kernel='rbf', gamma = 0.125, epsilon = 0.1)
svm_predictor.fit(X, y)
print("SVM initialized, support vectors:", len(svm_predictor.support_vectors_))
print("Process campaign ", path_campaign)
......@@ -480,20 +481,26 @@ def process_NadirCC_LCCC_LA_BBCH30(path_campaign, GSD):
# Square
LA_img_powered = np.power(LA_img, 2)
'''
gt_bins = {}
for gt_bin in np.arange(start=0, stop=100, step=1):
gt_bins[gt_bin] = np.sum(LA_img > gt_bin/100) / (LA_img.shape[0] * LA_img.shape[1])
'''
gt_bins = {gt_bin : np.sum(LA_img > gt_bin/100) / (LA_img.shape[0] * LA_img.shape[1]) for gt_bin in np.arange(start=0, stop=100, step=1)}
gt_bins_10 = {gt_bin: np.sum(LA_img > gt_bin / 100) / (LA_img.shape[0] * LA_img.shape[1]) for gt_bin in
np.arange(start=0, stop=100, step=10)}
# normalize
gt_bins_norm = {}
for gt_bin in np.arange(start=0, stop=100, step=10):
sum_a = np.sum([val for val in gt_bins.values()])
sum_a = np.sum([val for val in gt_bins_10.values()])
if sum_a != 0:
gt_bins_norm[gt_bin] = gt_bins[gt_bin] / sum_a
gt_bins_norm[gt_bin] = gt_bins_10[gt_bin] / sum_a
else:
gt_bins_norm[gt_bin] = 0
# check normalization:
#np.sum([val for val in gt_bins_norm.values()])
#print("GT bins normalized to sum: ", np.sum([val for val in gt_bins_norm.values()]))
# Calc LA and aerial index
LA = np.sum(LA_img_powered)
......@@ -536,14 +543,17 @@ def process_NadirCC_LCCC_LA_BBCH30(path_campaign, GSD):
X = [list(d.values()) for d in df_LA['gt_bins_norm']]
value = -svm_predictor.predict(sc_x.transform(X))
value = (np.exp(value) + 1) * np.sign(value)
X = sc_x.transform(X)
value = svm_predictor.predict(X)
value = -(np.expm1(np.abs(value))) * np.sign(value)
print("Mean BBCH30 delta:", np.mean(value))
df_LA['value'] = value
df_LA['timestamp'] = datetime.strptime(campaign_date, "%Y%m%d")
df_LA.to_csv(path_trait_csvs / (design_label + "_AI.csv"), index=False)
df_LA.to_csv(path_trait_csvs / (design_label + "_BBCH30.csv"), index=False)
......
......@@ -2,7 +2,7 @@ from GroundAerialCoverage import CanopyAnalysis
from pathlib import Path
path_p = Path("P:")
path_p = Path("/home/luroth/public")
#path_p = Path("/home/luroth/public")
if __name__ == "__main__":
......@@ -16,7 +16,9 @@ if __name__ == "__main__":
path_campaign = base_path_campaign / campaign_date / '28m_M600P'
if int(campaign_date) <= 20180509:
CanopyAnalysis.clean_trait_folder(path_campaign, ["*_AI.csv"])
if int(campaign_date) <= 20180509 and int(campaign_date) > 20180301:
print("Processing", campaign_date)
CanopyAnalysis.process_NadirCC_LCCC_LA_BBCH30(path_campaign, GSD)
\ No newline at end of file
......@@ -2,7 +2,7 @@ from GroundAerialCoverage import CanopyAnalysis
from pathlib import Path
path_p = Path("P:")
path_p = Path("/home/luroth/public")
#path_p = Path("/home/luroth/public")
if __name__ == "__main__":
......@@ -16,7 +16,9 @@ if __name__ == "__main__":
path_campaign = base_path_campaign / campaign_date / '28m_M600P'
if int(campaign_date) <= 20180509:
CanopyAnalysis.clean_trait_folder(path_campaign, ["*_AI.csv"])
if int(campaign_date) <= 20180509 and int(campaign_date) > 20180301:
print("Processing", campaign_date)
CanopyAnalysis.process_NadirCC_LCCC_LA_BBCH30(path_campaign, GSD)
\ No newline at end of file
......@@ -2,7 +2,7 @@ from GroundAerialCoverage import CanopyAnalysis
from pathlib import Path
path_p = Path("P:")
path_p = Path("/home/luroth/public")
#path_p = Path("/home/luroth/public")
if __name__ == "__main__":
......@@ -14,10 +14,13 @@ if __name__ == "__main__":
for date_folder in date_folders:
campaign_date = date_folder.name
if int(campaign_date) <= 20190411:
path_campaign = base_path_campaign / campaign_date / '28m_M600P'
CanopyAnalysis.clean_trait_folder(path_campaign, ["*_AI.csv"])
if int(campaign_date) <= 20190411 and int(campaign_date) > 20190301:
print("Processing", campaign_date)
path_campaign = base_path_campaign / campaign_date / '28m_M600P'
CanopyAnalysis.process_NadirCC_LCCC_LA_BBCH30(path_campaign, campaign_date, GSD)
\ No newline at end of file
CanopyAnalysis.process_NadirCC_LCCC_LA_BBCH30(path_campaign, GSD)
\ No newline at end of file
......@@ -2,7 +2,7 @@ from GroundAerialCoverage import CanopyAnalysis
from pathlib import Path
path_p = Path("P:")
path_p = Path("/home/luroth/public")
#path_p = Path("/home/luroth/public")
if __name__ == "__main__":
......@@ -14,10 +14,13 @@ if __name__ == "__main__":
for date_folder in date_folders:
campaign_date = date_folder.name
if int(campaign_date) <= 20190501:
path_campaign = base_path_campaign / campaign_date / '28m_M600P'
CanopyAnalysis.clean_trait_folder(path_campaign, ["*_AI.csv"])
if int(campaign_date) <= 20190501 and int(campaign_date) > 20190301:
print("Processing", campaign_date)
path_campaign = base_path_campaign / campaign_date / '28m_M600P'
CanopyAnalysis.process_NadirCC_LCCC_LA_BBCH30(path_campaign, GSD)
\ No newline at end of file
......@@ -65,10 +65,35 @@ if __name__ == "__main__":
r'O:\UAV\_Processed_\ETHZ_eschikon_FPWW024_lot2\20190415\28m_M600P',
r'O:\UAV\_Processed_\ETHZ_eschikon_FPWW024_lot2\20190418\28m_M600P']
paths = [
paths_done = [
r'O:\UAV\_Processed_\ETHZ_eschikon_FPWW024_lot2\20190422\28m_M600P',
r'O:\UAV\_Processed_\ETHZ_eschikon_FPWW024_lot2\20190501\28m_M600P']
paths = [
r'O:\UAV\_Processed_\ETHZ_eschikon_FPWW024_lot2\20190507\28m_M600P',
r'O:\UAV\_Processed_\ETHZ_eschikon_FPWW024_lot2\20190515\28m_M600P',
r'O:\UAV\_Processed_\ETHZ_eschikon_FPWW024_lot2\20190517\28m_M600P',
r'O:\UAV\_Processed_\ETHZ_eschikon_FPWW024_lot2\20190523\28m_M600P',
r'O:\UAV\_Processed_\ETHZ_eschikon_FPWW024_lot2\20190526\28m_M600P',
r'O:\UAV\_Processed_\ETHZ_eschikon_FPWW024_lot2\20190527\28m_M600P',
r'O:\UAV\_Processed_\ETHZ_eschikon_FPWW024_lot2\20190529\28m_M600P',
r'O:\UAV\_Processed_\ETHZ_eschikon_FPWW024_lot2\20190530\28m_M600P',
r'O:\UAV\_Processed_\ETHZ_eschikon_FPWW024_lot2\20190601\28m_M600P',
r'O:\UAV\_Processed_\ETHZ_eschikon_FPWW024_lot2\20190603\28m_M600P',
r'O:\UAV\_Processed_\ETHZ_eschikon_FPWW024_lot2\20190605\28m_M600P',
r'O:\UAV\_Processed_\ETHZ_eschikon_FPWW024_lot2\20190607\28m_M600P',
r'O:\UAV\_Processed_\ETHZ_eschikon_FPWW024_lot2\20190609\28m_M600P',
r'O:\UAV\_Processed_\ETHZ_eschikon_FPWW024_lot2\20190612\28m_M600P',
r'O:\UAV\_Processed_\ETHZ_eschikon_FPWW024_lot2\20190614\28m_M600P',
r'O:\UAV\_Processed_\ETHZ_eschikon_FPWW024_lot2\20190617\28m_M600P',
r'O:\UAV\_Processed_\ETHZ_eschikon_FPWW024_lot2\20190620\28m_M600P',
r'O:\UAV\_Processed_\ETHZ_eschikon_FPWW024_lot2\20190624\28m_M600P',
r'O:\UAV\_Processed_\ETHZ_eschikon_FPWW024_lot2\20190628\28m_M600P',
r'O:\UAV\_Processed_\ETHZ_eschikon_FPWW024_lot2\20190703\28m_M600P',
r'O:\UAV\_Processed_\ETHZ_eschikon_FPWW024_lot2\20190705\28m_M600P',
r'O:\UAV\_Processed_\ETHZ_eschikon_FPWW024_lot2\20190708\28m_M600P'
]
for path in paths:
print("Process", path)
......
......@@ -77,7 +77,9 @@ if __name__ == '__main__':
'20190319',
'20190322',
'20190324',
'20190327',
'20190327']
dates = [
'20190329',
'20190402',
'20190405',
......
......@@ -2,7 +2,7 @@ from GroundAerialCoverage import CanopyAnalysis
from pathlib import Path
path_p = Path("P:")
path_p = Path("/home/luroth/public")
#path_p = Path("/home/luroth/public")
if __name__ == "__main__":
......@@ -14,10 +14,12 @@ if __name__ == "__main__":
for date_folder in date_folders:
campaign_date = date_folder.name
if int(campaign_date) <= 20190501:
path_campaign = base_path_campaign / campaign_date / '28m_M600P'
print("Processing", campaign_date)
CanopyAnalysis.clean_trait_folder(path_campaign, ["*_AI.csv"])
if int(campaign_date) <= 20190501 and int(campaign_date) > 20190301:
path_campaign = base_path_campaign / campaign_date / '28m_M600P'
print("Processing", campaign_date)
CanopyAnalysis.process_NadirCC_LCCC_LA_BBCH30(path_campaign, GSD)
\ No newline at end of file
......@@ -65,13 +65,41 @@ if __name__ == "__main__":
r'O:\UAV\_Processed_\ETHZ_eschikon_FPWW024_lot4\20190415\28m_M600P',
r'O:\UAV\_Processed_\ETHZ_eschikon_FPWW024_lot4\20190418\28m_M600P']
paths = [
paths_done = [
r'O:\UAV\_Processed_\ETHZ_eschikon_FPWW024_lot4\20181105\28m_M600P']
paths = [
paths_done = [
r'O:\UAV\_Processed_\ETHZ_eschikon_FPWW024_lot4\20190422\28m_M600P',
r'O:\UAV\_Processed_\ETHZ_eschikon_FPWW024_lot4\20190501\28m_M600P']
paths_done = [
r'O:\UAV\_Processed_\ETHZ_eschikon_FPWW024_lot4\20190507\28m_M600P',
r'O:\UAV\_Processed_\ETHZ_eschikon_FPWW024_lot4\20190515\28m_M600P',
r'O:\UAV\_Processed_\ETHZ_eschikon_FPWW024_lot4\20190517\28m_M600P',
r'O:\UAV\_Processed_\ETHZ_eschikon_FPWW024_lot4\20190523\28m_M600P',
r'O:\UAV\_Processed_\ETHZ_eschikon_FPWW024_lot4\20190526\28m_M600P',
r'O:\UAV\_Processed_\ETHZ_eschikon_FPWW024_lot4\20190527\28m_M600P',
r'O:\UAV\_Processed_\ETHZ_eschikon_FPWW024_lot4\20190529\28m_M600P',
r'O:\UAV\_Processed_\ETHZ_eschikon_FPWW024_lot4\20190530\28m_M600P',
r'O:\UAV\_Processed_\ETHZ_eschikon_FPWW024_lot4\20190601\28m_M600P',
r'O:\UAV\_Processed_\ETHZ_eschikon_FPWW024_lot4\20190603\28m_M600P',
r'O:\UAV\_Processed_\ETHZ_eschikon_FPWW024_lot4\20190605\28m_M600P',
r'O:\UAV\_Processed_\ETHZ_eschikon_FPWW024_lot4\20190607\28m_M600P',
r'O:\UAV\_Processed_\ETHZ_eschikon_FPWW024_lot4\20190609\28m_M600P',
r'O:\UAV\_Processed_\ETHZ_eschikon_FPWW024_lot4\20190612\28m_M600P',
r'O:\UAV\_Processed_\ETHZ_eschikon_FPWW024_lot4\20190614\28m_M600P',
r'O:\UAV\_Processed_\ETHZ_eschikon_FPWW024_lot4\20190617\28m_M600P'
]
paths = [
r'O:\UAV\_Processed_\ETHZ_eschikon_FPWW024_lot4\20190620\28m_M600P',
r'O:\UAV\_Processed_\ETHZ_eschikon_FPWW024_lot4\20190621\28m_M600P',
r'O:\UAV\_Processed_\ETHZ_eschikon_FPWW024_lot4\20190624\28m_M600P',
r'O:\UAV\_Processed_\ETHZ_eschikon_FPWW024_lot4\20190628\28m_M600P',
r'O:\UAV\_Processed_\ETHZ_eschikon_FPWW024_lot4\20190703\28m_M600P',
r'O:\UAV\_Processed_\ETHZ_eschikon_FPWW024_lot4\20190708\28m_M600P',
]
for path in paths:
print("Process", path)
......
......@@ -77,7 +77,9 @@ if __name__ == '__main__':
'20190402',
'20190405',
'20190409',
'20190412',
'20190412']
dates = [
'20190415',
'20190418',
'20181105',
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment