-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmainwindow.cpp
More file actions
144 lines (118 loc) · 3.99 KB
/
mainwindow.cpp
File metadata and controls
144 lines (118 loc) · 3.99 KB
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
// TopLevel Window for QHdfView
#include "mainwindow.h"
#include "ui_mainwindow.h"
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
mod11_hdf = new MOD11_hdf () ;
mod13_hdf = new MOD13_hdf () ;
nl = 700 ;
ns = 1320 ;
nyears = 20 ;
xloc = ns / 2 ;
yloc = nl / 2 ;
LSTFlag = true ;
m11dir = new QString ("/Users/hg1/data/MOD11") ;
m13dir = new QString ("/Users/hg1/data/MOD13") ;
ui->image_widget->setXY (xloc, yloc) ;
gc = new GlobalCoords () ;
gc->xy2latlon(xloc, yloc, &curlon, &curlat) ;
QString s = QString::number(curlon, 'f', 3) ;
ui->lonLE->setText (s) ;
s = QString::number(curlat, 'f', 3) ;
ui->latLE->setText (s) ;
connect (ui->image_widget, SIGNAL(clickedXY(int *)), this, SLOT(newXY (int *))) ;
}
MainWindow::~MainWindow()
{
delete ui;
delete mod11_hdf ;
delete mod13_hdf ;
}
void MainWindow::on_actionOpen_triggered()
{
if (LSTFlag){
this->infile = QFileDialog::getOpenFileName (this, "Open HDF4 File", *m11dir) ;
QFile *qf = new QFile (this->infile) ;
if (!qf->exists()){
qDebug() << ("Uhoh") ;
return ;
}
// if MOD11 is selected
mod11_hdf->openHDF(this->infile.toLatin1().data()) ;
nyears = mod11_hdf->getStack(this->infile.toLatin1().data()) ;
ui->image_widget->loadQImage (mod11_hdf->nightdata, ns, nl) ;
//ui->image_widget->loadQImage (mod11_hdf->stack, ns, nl) ;
ui->image_widget->loadQImage_alt (mod11_hdf->daydata, ns, nl) ;
ui->fnameLabel->setText (mod11_hdf->curfile.c_str()) ;
ui->month_CB->setCurrentIndex(mod11_hdf->month) ;
ui->yearLE->setText (QString::number(mod11_hdf->year)) ;
} else {
this->infile = QFileDialog::getOpenFileName (this, "Open HDF4 File", *m13dir) ;
QFile *qf = new QFile (this->infile) ;
if (!qf->exists()){
qDebug() << ("Uhoh") ;
return ;
}
// if MOD11 is selected
mod13_hdf->openHDF(this->infile.toLatin1().data()) ;
nyears = mod13_hdf->getStack(this->infile.toLatin1().data()) ;
ui->image_widget->loadQImage (mod13_hdf->ndvidata, ns, nl) ;
//ui->image_widget->loadQImage (mod11_hdf->stack, ns, nl) ;
//ui->image_widget->loadQImage_alt (mod11_hdf->daydata, ns, nl) ;
ui->fnameLabel->setText (mod13_hdf->curfile.c_str()) ;
ui->month_CB->setCurrentIndex(mod13_hdf->month) ;
ui->yearLE->setText (QString::number(mod13_hdf->year)) ;
}
ui->image_widget->update() ;
this->getProfile (ns/2, nl/2) ;
}
void MainWindow::on_actionExit_triggered()
{
QApplication::quit() ;
}
void MainWindow::on_nightButton_toggled(bool checked)
{
// check if night or day has been selected
ui->image_widget->setNightFlag (checked) ;
}
void MainWindow::getProfile (int x, int y) {
int npix = ns * nl ;
float *ydata = new float [nyears] ;
float *ydata_day = new float [nyears];
if (LSTFlag){
for (int i=0; i<nyears; i++){
ydata[i] = mod11_hdf->stackf[i * npix + ns * y + x] ;
ydata_day[i] = mod11_hdf->daystackf[i * npix + ns * y + x] ;
qDebug() << ydata[i] << " " << ydata_day[i];
}
} else {
for (int i=0; i<nyears; i++){
ydata[i] = mod13_hdf->stackf[i * npix + ns * y + x] ;
//ydata_day[i] = mod13_hdf->daystackf[i * npix + ns * y + x] ;
qDebug() << ydata[i] ;
}
}
ui->plot_widget->setYData(0, ydata, nyears);
if (LSTFlag)
ui->plot_widget->setYData(1, ydata_day, nyears);
delete [] ydata ;
delete [] ydata_day ;
}
void MainWindow::newXY (int *xy){
int x, y ;
x = xy[0];
y = xy[1];
gc->xy2latlon(x, y, &curlon, &curlat) ;
QString s = QString::number(curlon, 'f', 3) ;
ui->lonLE->setText (s) ;
s = QString::number(curlat, 'f', 3) ;
ui->latLE->setText (s) ;
this->getProfile(x,y);
}
void MainWindow::on_landtempRB_toggled(bool checked)
{
this->LSTFlag = checked ;
}