-
Notifications
You must be signed in to change notification settings - Fork 1
/
EcoFOCI_Processing_main.py
executable file
·144 lines (107 loc) · 5.36 KB
/
EcoFOCI_Processing_main.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
#!/usr/bin/env python
"""
### WARNING: CODE IS BROKEN ###
## QT4 EOL ##
Tasks where simple:
to process raw cnv to epic flavored netcdf
import OnCruiseRoutines.CTD2NC as CTD2NC
from OnCruiseRoutines.CTD_Vis import ctd
from OnCruiseRoutines.CTD_Vis import ncprocessing
CTD2NC.data_processing('/Users/bell/ecoraid/2020/CTDcasts/dy2012/rawconverted/','/Users/bell/ecoraid/2020/CTDcasts/dy2012/working/')
get_btl.report('/Users/bell/ecoraid/2020/CTDcasts/dy2012/rawconverted/','/Users/bell/ecoraid/2020/CTDcasts/dy2012/working/')
## OLD HEADER ##
Background:
--------
EcoFOCI_Processing_main.py
GUI wrapper (using tKinter) for various cruise related processing programs
Purpose:
--------
Usage:
------
All available routines have command line capability as well
Contains:
---------
CTD2NC.py
Original code reference:
------------------------
Built using Anaconda packaged Python:
"""
# System Packages
import datetime, os, sys
import socket
# GUI Packages
from PyQt4 import QtGui
import gui_ui.ecofoci_processing_design as design
# This file holds our MainWindow and all design related things
# it also keeps events etc that we defined in Qt Designer
__author__ = 'Shaun Bell'
__email__ = 'shaun.bell@noaa.gov'
__created__ = datetime.datetime(2014, 01, 29)
__modified__ = datetime.datetime(2014, 10, 13)
__version__ = "0.2.0"
__status__ = "Development"
class ExampleApp(QtGui.QMainWindow, design.Ui_MainWindow):
def __init__(self):
# Explaining super is out of the scope of this article
# So please google it if you're not familar with it
# Simple reason why we use it here is that it allows us to
# access variables, methods etc in the design.py file
super(self.__class__, self).__init__()
self.setupUi(self) # This is defined in design.py file automatically
# It sets up layout and widgets that are defined
self.inputButton.clicked.connect(self.input_files)
self.processButton.clicked.connect(self.Process_Files)
self.addMetaButton.clicked.connect(self.AddCruiseMetaData)
self.btlSummaryButton.clicked.connect(self.BtlSummary)
self.exitButton.clicked.connect(self.exit_main)
def input_files(self):
directory = QtGui.QFileDialog.getExistingDirectory(self,
"Pick a folder")
self.inputList.clear()
self.outputList.clear()
if directory: # if user didn't pick a directory don't continue
self.directory = str(directory)
for file_name in os.listdir(directory): # for all files, if any, in the directory
self.inputList.addItem(file_name) # add file to the listWidget
self.outputList.addItem(file_name) # add file to the listWidget
self.inputButton.setStyleSheet("background-color: green")
def Process_Files(self):
''' run data processing routine in file CTD2nc.py'''
# User Packages
import OnCruiseRoutines.CTD2NC as CTD2NC
from OnCruiseRoutines.CTD_Vis import ctd
from OnCruiseRoutines.CTD_Vis import ncprocessing
if self.IPHCcheckBox.isChecked():
rflag = CTD2NC.IPHC_data_processing(os.path.join(self.directory, str(self.inputList.currentItem().text()) + '/'),
os.path.join(self.directory, str(self.outputList.currentItem().text()) + '/'),
pressure_varname=str(self.presscomboBox.currentText()))
else: #get header info for IPHC style files
rflag = CTD2NC.data_processing(os.path.join(self.directory, str(self.inputList.currentItem().text()) + '/'),
os.path.join(self.directory, str(self.outputList.currentItem().text()) + '/'),
pressure_varname=str(self.presscomboBox.currentText()))
if rflag == True:
self.processButton.setStyleSheet("background-color: green")
def AddCruiseMetaData(self):
#import PostCruiseRoutines.PostCruiseMetaDBadd as PostCruiseMetaDBadd
#socket.gethostname().split('.')[0]
#rflag = PostCruiseMetaDBadd.AddMeta_fromDB(os.path.join(self.directory, str(self.inputList.currentItem().text()) + '/'),
# os.path.join(self.directory, str(self.outputList.currentItem().text()) + '/'),
# server=socket)
#if rflag == True:
# self.addMetaButton.setStyleSheet("background-color: green")
pass
def BtlSummary(self):
import OnCruiseRoutines.utilities.get_btl as get_btl
rflag = get_btl.report(os.path.join(self.directory, str(self.inputList.currentItem().text()) + '/'),
os.path.join(self.directory, str(self.outputList.currentItem().text()) + '/'))
if rflag == True:
self.btlSummaryButton.setStyleSheet("background-color: green")
def exit_main(self):
self.close()
def main():
app = QtGui.QApplication(sys.argv) # A new instance of QApplication
form = ExampleApp() # We set the form to be our ExampleApp (design)
form.show() # Show the form
app.exec_() # and execute the app
if __name__ == '__main__': # if we're running file directly and not importing it
main() # run the main function