This repository has been archived by the owner on Mar 19, 2021. It is now read-only.
forked from TimHessels/SEBAL
-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathpySEBAL_GUI.py
148 lines (116 loc) · 5.51 KB
/
pySEBAL_GUI.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
# -*- coding: utf-8 -*-
"""
Created on Thu Jan 04 15:04:39 2018
@author: tih
"""
from PyQt5 import QtCore, QtWidgets
import SEBAL.GUI.pySEBAL_pyGUI as pySEBAL_pyGUI
import SEBAL
import time
import os
import glob
import re
import datetime as dt
from osgeo import gdal, gdal_array
import osr
import numpy as np
import pandas as pd
class Interface_pySEBAL (QtWidgets.QTabWidget, pySEBAL_pyGUI.Ui_pySEBALGUI):
def __init__(self):
super(self.__class__,self).__init__()
self.setupUi(self)
# Fixed Size of Application
self.setFixedSize(self.width(),self.height())
# =============================================================================
# #Signals and Slots
# =============================================================================
'''
# Actual Date
now_time=time.strftime("%Y%m%d")
# SEBAL
self.dateEdit_from.setDate(QtCore.QDate(int(now_time[0:4]),int(now_time[4:6]),int(now_time[6:8])))
self.dateEdit_to.setDate(QtCore.QDate(int(now_time[0:4]),int(now_time[4:6]),int(now_time[6:8])))
# =============================================================================
# SEBAL
# =============================================================================
self.dateEdit_from.dateChanged.connect(self.setdate_sebal)
self.dateEdit_to.dateChanged.connect(self.setdate_sebal)
self.checkBox_SebalLot.stateChanged.connect(self.verify)
self.radioButton_Landsat.clicked.connect(self.Hot_Cold_pixels)
self.radioButton_VIIRS_PROBAV_100.clicked.connect(self.Hot_Cold_pixels)
self.radioButton_VIIRS_375.clicked.connect(self.Hot_Cold_pixels)
self.BrowseButton_DEMSebal.clicked.connect(self.Set_folders)
self.BrowseButton_InSebal.clicked.connect(self.Set_folders)
self.BrowseButton_OutSebal.clicked.connect(self.Set_folders)
self.BrowseButton_MeteoSebal.clicked.connect(self.Set_folders)
self.BrowseButton_SoilSebal.clicked.connect(self.Set_folders)
self.buttonBox_OKCancel.accepted.connect(self.ApplySEBAL)
self.ButtonBox.accepted.connect(self.Apply_Test)
'''
self.pushButton.clicked.connect(self.browse_folder)
# =============================================================================
# #Functions or Methodes call
# =============================================================================
def reject(self):
self.pySEBAL_pyGUI.close
def browse_folder(self):
sender = self.sender()
objectName = sender.objectName()
if objectName == 'pushButton':
a=self.lineEdit.text()
filename = QtWidgets.QFileDialog.getOpenFileName(self, 'Select Excel File', 'C:\\', 'Excel Files (*.xlsx)')
if filename=='':
self.lineEdit.setText(a)
else:
self.lineEdit.setText(filename[0])
def accept(self):
self.ExcelFile_sebal=str(self.lineEdit.text())
self.Startvalue=int(self.spinBox.value())
self.Endvalue=int(self.spinBox_2.value())
if (self.ExcelFile_sebal==''):
QtWidgets.QMessageBox.warning(self, "Warning",
"Select the SEBAL excel file",
QtWidgets.QMessageBox.Ok)
else:
self.progdialog = QtWidgets.QProgressDialog( "SEBAL in Progress. Please Wait...", "Cancel", 0 , 100, self)
self.progdialog.setWindowTitle("SEBAL Progression")
self.progdialog.setWindowModality(QtCore.Qt.ApplicationModal)
self.progdialog.setFixedSize(self.progdialog.size())
self.progdialog.show()
self.TT_sebal = Sebal_Thread(self)
self.TT_sebal.updateProgress.connect(self.Sebal_Progressed)
self.TT_sebal.exception.connect(self.Sebal_exception)
self.TT_sebal.start()
def Sebal_Progressed(self,value_pg):
self.progdialog.setLabelText("SEBAL Accomplishment Percentage")
self.progdialog.setValue(value_pg)
def Sebal_exception(self, message):
QtWidgets.QMessageBox.critical(self, "Error", message, QtWidgets.QMessageBox.Ok)
# =============================================================================
# #Threads and Dialog Class
# =============================================================================
class Sebal_Thread(QtCore.QThread):
updateProgress = QtCore.pyqtSignal(int)
exception = QtCore.pyqtSignal(str)
def __init__(self,Interface_pySEBAL):
QtCore.QThread.__init__(self)
self.Interface=Interface_pySEBAL
def run(self):
ExcelFile_sebal=self.Interface.ExcelFile_sebal
Startvalue=int(self.Interface.Startvalue)
Endvalue=int(self.Interface.Endvalue)
i = 0
for number in range(Startvalue,Endvalue+1):
try:
SEBAL.pySEBAL.pySEBAL_code.main(number,ExcelFile_sebal)
except:
message="SEBAL Model Processing on Landsat Images are not well executed"
self.exception.emit(message)
self.updateProgress.emit(int(round((i+1)*(100./len(range(Startvalue,Endvalue+1))))))
i+=1
if __name__== '__main__':
import sys
app=QtWidgets.QApplication(sys.argv)
form=Interface_pySEBAL()
form.show()
app.exec_()