/
detrend_window.py
679 lines (479 loc) · 23.2 KB
/
detrend_window.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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
# -*- coding: utf-8 -*-
import pyqtgraph as pg
from PyQt5 import QtCore, QtGui, QtWidgets, uic
import numpy as np
import os
from print_info_window import print_info
from worker import Worker
from multiprocessing import cpu_count
import gls as gls
import dill
from wotan import flatten
qtCreatorFile = "./lib/UI/tdt.ui"
Ui_DetrendWindow, QtBaseClass = uic.loadUiType(qtCreatorFile)
try:
import sklearn
sklearn_found = True
except (ImportError, KeyError) as e:
sklearn_found = False
pass
try:
import statsmodels
statsmodels_found = True
except (ImportError, KeyError) as e:
statsmodels_found = False
pass
try:
import pygam
pygam_found = True
except (ImportError, KeyError) as e:
pygam_found = False
pass
try:
import supersmoother
supersmoother_found = True
except (ImportError, KeyError) as e:
supersmoother_found = False
pass
class DetrendWindow(QtWidgets.QWidget, Ui_DetrendWindow):
def __init__(self,parent):
super(DetrendWindow, self).__init__()
QtWidgets.QWidget.__init__(self)
Ui_DetrendWindow.__init__(self)
# self.setWindowTitle('Transit detrending options')
self.font = QtGui.QFont()
self.font.setPointSize(9)
self.font.setBold(False)
self.threadpool_DT = QtCore.QThreadPool()
self.threadpool_DT.setMaxThreadCount(cpu_count())
self.parent=parent
# Create the main window
self.ui = Ui_DetrendWindow()
self.ui.setupUi(self)
self.setWindowIcon(QtGui.QIcon('./lib/UI/33_striker.png'))
self.sklearn_found = sklearn_found
self.statsmodels_found = statsmodels_found
self.pygam_found = pygam_found
self.supersmoother_found = supersmoother_found
self.ui.radio_GPs.setEnabled(sklearn_found)
self.ui.comboBox_GP.setEnabled(sklearn_found)
self.ui.kernel_size.setEnabled(sklearn_found)
self.t_store = {k: [] for k in range(10)}
self.flux_store = {k: [] for k in range(10)}
self.flux_err_store = {k: [] for k in range(10)}
self.flux_o_c_store = {k: [] for k in range(10)}
self.flux_err_o_c_store = {k: [] for k in range(10)}
self.trend_store = {k: [] for k in range(10)}
self.t = []
self.old_t = []
self.flux_o_c = []
self.initialize_plots()
self.init_comboBox_regres()
self.init_comboBox_sliders()
self.init_comboBox_poly()
self.init_comboBox_splines()
self.init_comboBox_GP()
self.ui.try_button.clicked.connect(self.worker_detrend)
self.ui.saveProduct.clicked.connect(self.save_data_product)
self.ui.readme_button.clicked.connect(self.info)
self.ui.print_stat.clicked.connect(self.print_stat_window)
self.info_dialog = print_info(self)
self.stat_dialog = print_info(self)
self.ui.buttonGroup_plot2.buttonClicked.connect(self.replot)
self.ui.buttonGroup_trendOptions.buttonClicked.connect(self.update_labels)
self.ui.click_to_reject.clicked.connect(self.top_plot)
self.ui.reset_data.clicked.connect(self.reset_data)
self.ui.add_epoch.clicked.connect(self.add_bjd)
self.ui.apply_dilution.clicked.connect(self.add_dilution)
def replot(self):
if self.ui.GLS_of_data.isChecked():
self.make_GLS()
self.plot_GLS()
elif self.ui.GLS_of_model.isChecked():
self.make_GLS(model=True)
self.plot_GLS()
elif self.ui.GLS_of_detr_data.isChecked():
self.make_GLS(model=False,o_c=True)
self.plot_GLS()
elif self.ui.flatten_data.isChecked():
self.bottom_plot_lc()
def init_data(self):
self.t = self.parent.tra_data[0]
self.flux = self.parent.tra_data[4]
self.flux_err = self.parent.tra_data[2]
self.data_file_name = self.parent.tra_data[-1]
self.old_t = dill.copy(self.t)
return
def add_dilution(self):
D_flux = self.flux/(self.ui.Dilution_fact.value())
self.flux = D_flux - np.median(D_flux) * (1.0 - self.ui.Dilution_fact.value())
D_flux_err = self.flux_err/(self.ui.Dilution_fact.value())
self.flux_err = D_flux_err
self.ui.radio_remove_median.setChecked(True)
#self.plot()
self.worker_detrend()
return
def add_bjd(self):
self.t = self.t + self.ui.extra_BJD.value()
self.ui.radio_remove_median.setChecked(True)
#self.plot()
self.worker_detrend()
return
def reset_data(self):
self.ui.radio_remove_median.setChecked(True)
self.t = []
self.worker_detrend()
def calculate(self):
if self.ui.radio_remove_median.isChecked():
flatten_lc1 = self.flux/np.median(self.flux)
trend_lc1 = np.ones(len(self.flux))*np.median(self.flux)
elif self.ui.radio_remove_mean.isChecked():
flatten_lc1 = self.flux/np.mean(self.flux)
trend_lc1 = np.ones(len(self.flux))*np.mean(self.flux)
elif self.ui.radio_timeW.isChecked():
flatten_lc1, trend_lc1 = flatten(
self.t, # Array of time values
self.flux , # Array of flux values
method=str(self.ui.comboBox_sliders.currentText()),
window_length=self.ui.sliders_wl.value(), # The length of the filter window in units of ``time``
# break_tolerance=self.ui.spline_bt.value(), # Split into segments at breaks longer than that
return_trend=True, # Return trend and flattened light curve
)
elif self.ui.radio_Splines.isChecked():
flatten_lc1, trend_lc1 = flatten(
self.t, # Array of time values
self.flux , # Array of flux values
method=str(self.ui.comboBox_splines.currentText()),
window_length=self.ui.spline_wl.value(), # The length of the filter window in units of ``time``
break_tolerance=self.ui.spline_bt.value(), # Split into segments at breaks longer than that
return_trend=True, # Return trend and flattened light curve
)
elif self.ui.radio_Polynomials.isChecked():
flatten_lc1, trend_lc1 = flatten(
self.t, # Array of time values
self.flux , # Array of flux values
method=str(self.ui.comboBox_poly.currentText()),
window_length=self.ui.poly_wl.value(), # The length of the filter window in units of ``time``
break_tolerance=self.ui.poly_bt.value(), # Split into segments at breaks longer than that
return_trend=True, # Return trend and flattened light curve
)
elif self.ui.radio_Regressions.isChecked():
flatten_lc1, trend_lc1 = flatten(
self.t, # Array of time values
self.flux , # Array of flux values
method=str(self.ui.comboBox_regs.currentText()),
window_length=self.ui.regres_wl.value(), # The length of the filter window in units of ``time``
break_tolerance=self.ui.regres_bt.value(), # Split into segments at breaks longer than that
return_trend=True, # Return trend and flattened light curve
)
elif self.ui.radio_GPs.isChecked():
flatten_lc1, trend_lc1 = flatten(
self.t, # Array of time values
self.flux , # Array of flux values
method='gp',
kernel = str(self.ui.comboBox_GP.currentText()),
kernel_size=self.ui.kernel_size.value(),
break_tolerance=self.ui.regres_bt.value(), # Split into segments at breaks longer than that
kernel_period = self.ui.GP_period.value(),
robust = self.ui.checkBox_GP_robust.isChecked(),
return_trend=True # Return trend and flattened light curve
)
else:
flatten_lc1 = self.flux
trend_lc1 = np.ones(len(self.flux))*np.median(self.flux)
self.flux_o_c = flatten_lc1
self.trend = trend_lc1
self.flux_err_o_c = self.flux_err/trend_lc1
def worker_detrend_complete(self):
#self.ui.label_working.setText("")
self.ui.try_button.setText("Try !")
self.ui.try_button.setEnabled(True)
self.ui.flatten_data.setChecked(True)
self.old_t = dill.copy(self.t)
self.plot()
self.show()
return
def worker_detrend(self):
if len(self.t) == 0:
self.init_data()
self.ui.try_button.setEnabled(False)
#self.ui.label_working.setText("Working!!!")
self.ui.try_button.setText("Working!!!")
worker_detrend_wk = Worker(self.calculate)# Any other args, kwargs are passed to the run
worker_detrend_wk.signals.finished.connect(self.worker_detrend_complete)
# worker.signals.result.connect(self.print_output)
#worker.signals.finished.connect(self.thread_complete)
# worker.signals.progress.connect(self.progress_fn)
self.threadpool_DT.start(worker_detrend_wk)
def plot(self):
self.top_plot()
self.bottom_plot_lc()
def top_plot(self):
global p_1
if self.ui.click_to_reject.isChecked():
symbolSize=6
else:
symbolSize=2
self.ui.plot.plot(clear=True,)
######## Top plot ############
self.ui.plot.plot(self.t,self.flux, pen=None,
symbol='o', symbolPen={'color': '#0066ff', 'width': 1.1},
symbolSize=symbolSize,enableAutoRange=True,viewRect=True,
symbolBrush='#0066ff')
err_ = pg.ErrorBarItem(x=self.t, y=self.flux, symbol = 'o',
top=self.flux_err,
bottom=self.flux_err,
beam=0.0, pen='#0066ff')
self.ui.plot.addItem(err_)
model_curve = self.ui.plot.plot(self.t, self.trend , pen={'color': '#000000', 'width': 3}, enableAutoRange=True,viewRect=True )
model_curve.setZValue(1)
self.ui.plot.plotItem.items[1].sigPointsClicked.connect(self.plotClicked)
def bottom_plot_lc(self):
#global p_2
self.ui.plot_2.plot(clear=True,)
######## Bottom plot ############
self.ui.plot_2.setLogMode(False,False)
self.ui.plot_2.plot(self.t,self.flux_o_c, pen=None,
symbol='o', symbolPen={'color': '#0066ff', 'width': 1.1},
symbolSize=2,enableAutoRange=True,viewRect=True,
symbolBrush='#0066ff')
self.ui.plot_2.setLabel('left', 'Flux', units='', **{'font-size':'9pt'})
err_ = pg.ErrorBarItem(x=self.t, y=self.flux_o_c, symbol = 'o',
top=self.flux_err_o_c,
bottom=self.flux_err_o_c,
beam=0.0, pen='#0066ff')
self.ui.plot_2.addItem(err_)
def plotClicked(self,curve,datas):
if self.ui.click_to_reject.isChecked() == False:
return
rem_x,rem_y = datas[0].pos()
print("Removed x,y: ",rem_x,rem_y)
self.old_t = dill.copy(self.t)
self.t = dill.copy(self.t[self.old_t != rem_x])
self.flux = dill.copy(self.flux[self.old_t != rem_x])
self.flux_err = dill.copy(self.flux_err[self.old_t != rem_x])
self.flux_o_c = dill.copy(self.flux_o_c[self.old_t != rem_x])
self.flux_err_o_c = dill.copy(self.flux_err_o_c[self.old_t != rem_x])
self.trend = dill.copy(self.trend[self.old_t != rem_x])
self.ui.plot.plotItem.items[1].setData(x=self.t,y=self.flux)
self.ui.plot.plotItem.items[2].setData(x=self.t, y=self.flux,
top=self.flux_err,
bottom=self.flux_err)
self.ui.plot_2.plotItem.items[1].setData(x=self.t,y=self.flux_o_c)
self.ui.plot_2.plotItem.items[2].setData(x=self.t, y=self.flux_o_c,
top=self.flux_err_o_c,
bottom=self.flux_err_o_c)
#self.plot()
def make_GLS(self, model=False, o_c=False):
#omega = 1/ np.logspace(np.log10(self.parent.gls_min_period.value()), np.log10(self.parent.gls_max_period.value()), num=int(self.parent.gls_n_omega.value()))
omega = 1/ np.logspace(np.log10(0.9), np.log10((max(self.t)-min(self.t))*2.0), num=int(self.parent.gls_n_omega.value()))
if model == False and o_c == False:
data_for_GLS = self.flux
e_data_for_GLS = self.flux_err
elif model == False and o_c == True:
data_for_GLS = self.flux_o_c
e_data_for_GLS = self.flux_err_o_c
else:
data_for_GLS = self.trend
e_data_for_GLS = self.flux_err
self.trend_per = gls.Gls((self.t, data_for_GLS, e_data_for_GLS),
fast=True, verbose=False, norm= "ZK",ofac=self.parent.gls_ofac.value(), fbeg=omega[-1], fend=omega[ 0],)
def plot_GLS(self):
#global p_2
self.ui.plot_2.plot(clear=True,)
power_levels = np.array([self.parent.gls_fap1.value(),self.parent.gls_fap2.value(),self.parent.gls_fap3.value()])
######################## GLS ##############################
if self.parent.radioButton_act_GLS_period.isChecked():
self.ui.plot_2.setLogMode(True,False)
self.ui.plot_2.plot(1.0/self.trend_per.freq, self.trend_per.power,pen='r',symbol=None )
self.ui.plot_2.setLabel('bottom', 'period [d]', units='', **{'font-size':'9pt'})
self.ui.plot_2.setLabel('left', 'Power', units='', **{'font-size':'9pt'})
else:
self.ui.plot_2.setLogMode(False,False)
self.ui.plot_2.plot(self.trend_per.freq, self.trend_per.power,pen='r',symbol=None )
self.ui.plot_2.setLabel('bottom', 'frequency [1/d]', units='', **{'font-size':'9pt'})
[self.ui.plot_2.addLine(x=None, y=fap, pen=pg.mkPen('k', width=0.8, style=QtCore.Qt.DotLine)) for ii,fap in enumerate(self.trend_per.powerLevel(np.array(power_levels)))]
def closeEvent(self, event):
if len(self.old_t) != len(self.t):
choice = QtGui.QMessageBox.information(self, 'Warning!',
"It seems that you removed data, but you did not refit! This is not allowed. Please press the 'Try!' button and then close", QtGui.QMessageBox.Ok)
event.ignore()
else:
ret = QtGui.QMessageBox.question(None, 'Close request', 'Are you sure you want to quit?',
QtGui.QMessageBox.Yes | QtGui.QMessageBox.No,
QtGui.QMessageBox.Yes)
if ret == QtGui.QMessageBox.Yes:
self.t_store[self.parent.tra_data_index] = self.t
self.flux_store[self.parent.tra_data_index] = self.flux
self.flux_err_store[self.parent.tra_data_index] = self.flux_err
self.flux_o_c_store[self.parent.tra_data_index] = self.flux_o_c
self.flux_err_o_c_store[self.parent.tra_data_index] = self.flux_err_o_c
self.trend_store[self.parent.tra_data_index] = self.trend
self.ui.radio_remove_median.setChecked(True)
QtGui.QMainWindow.closeEvent(self, event)
else:
event.ignore()
def save_data_product(self):
output_file = QtGui.QFileDialog.getSaveFileName(self, 'Save detrended data file', 'detrended_%s'%self.data_file_name, 'All (*.*);;Data (*.tran)', options=QtGui.QFileDialog.DontUseNativeDialog)
if str(output_file[0]) != '':
f = open(output_file[0], 'w')
f.write("# BJD Detrended data Detrended data errors, Original data Original data errors Model applied \n")
for i in range(len(self.t)):
f.write('{0:{width}.{precision}f} {1:{width}.{precision}f} {2:{width}.{precision}f} {3:{width}.{precision}f} {4:{width}.{precision}f} {5:{width}.{precision}f}\n'.format(
float(self.t[i]),
float(self.flux_o_c[i]),
float(self.flux_err_o_c[i]),
float(self.flux[i]),
float(self.flux_err[i]),
float(self.trend[i]),
width = 14, precision = 7 ))
f.close()
def print_stat_window(self):
self.stat_dialog.setFixedSize(550, 600)
self.stat_dialog.setWindowTitle('Detrending stat. info')
text_info = """
"""
self.stat_dialog.text.setText(text_info)
################## text generator #################
text_info = """
-----------------------------------
N data : %s
first epoch : %.3f
last epoch : %.3f
time span : %.3f
min. value : %.4f
max. value : %.4f
end-to-end : %.4f
mean : %.4f
median : %.4f
rms : %.4f
min error : %.4f
max error : %.4f
mean error : %.4f
median error : %.4f
"""%(len(self.t),
self.t[0],
self.t[-1],
self.t[-1]-self.t[0],
np.min(self.flux_o_c),
np.max(self.flux_o_c),
np.max(self.flux_o_c)-np.min(self.flux_o_c),
np.mean(self.flux_o_c),
np.median(self.flux_o_c),
np.sqrt(np.mean(np.square(self.flux_o_c))),
np.min(self.flux_err_o_c),
np.max(self.flux_err_o_c),
np.mean(self.flux_err_o_c),
np.median(self.flux_err_o_c))
self.stat_dialog.text.append(text_info)
self.stat_dialog.text.setReadOnly(True)
#self.dialog.setWindowIcon (QtGui.QIcon('logo.png'))
self.stat_dialog.show()
def info(self):
#self.info_dialog.setGeometry(300, 200, 150, 150)
self.info_dialog.setFixedSize(550, 600)
self.info_dialog.setWindowTitle('Detrending options info')
text = ''
self.info_dialog.text.setText(text)
text = "For more info on the detrending algorithms see <a href='https://github.com/hippke/wotan'>wotan</a>"
self.info_dialog.text.append(text)
text = """
<br>
<br>
As explained in "wotan", some algorithms request
additional dependencies, which are not included in "wotan", and thus, not included in the Exo-Striker
dependencies list. For example:
<br>
<br> "huber", "ramsay", and "hampel" depend on "statsmodels"
<br> "Gaussian processes", "hspline", "ridge", and "lasso" depend on "sklearn"
<br> "pspline" depends on "pygam"
<br> "supersmoother" depends on "supersmoother"
<br>
<br> To install all additional dependencies, try to install these python packages:
<br>
<br> * pip install statsmodels
<br> * pip install sklearn
<br> * pip install supersmoother
<br> * pip install pygam
<br>
<br> Also, "wotan" depends on "numba" and "llvmlite" so it might be a good idea to update those two if you already have older versions.
<br>
<br>
<br> If you made the use of the detrending options for your paper, please also cite: <a href='https://ui.adsabs.harvard.edu/abs/2019AJ....158..143H/abstract'> Hippke et al. (2019)</a>
"""
self.info_dialog.text.append(text)
self.info_dialog.text.setReadOnly(True)
#self.dialog.setWindowIcon (QtGui.QIcon('logo.png'))
self.info_dialog.show()
def update_labels(self):
if self.ui.radio_GPs.isChecked():
self.ui.label_method.setText("Kernel")
self.ui.label_wl.setText("Kernel size")
self.ui.label_tolerance.setText("Kernel period")
else:
self.ui.label_method.setText("Method")
self.ui.label_wl.setText("Window length")
self.ui.label_tolerance.setText("break tolerance")
def init_comboBox_sliders(self):
sliders = ["biweight","huber","huber_psi","hampel","andrewsinewave","welsch","ramsay","tau","hodges","median",
"medfilt","mean","trim_mean","winsorize","hampelfilt"]
sliders_use = [True, self.statsmodels_found, True, self.statsmodels_found,True, True, self.statsmodels_found,True,True,True,True,True,True,True,True]
for i in range(len(sliders)):
if sliders_use[i] == True:
self.ui.comboBox_sliders.addItem(sliders[i],i)
def init_comboBox_poly(self):
poly = ["cofiam","cosine","savgol"]
for i in range(len(poly)):
self.ui.comboBox_poly.addItem(poly[i],i)
def init_comboBox_splines(self):
splines = ["rspline","hspline","pspline"]
splines_use = [True,self.sklearn_found,self.pygam_found]
for i in range(len(splines)):
if splines_use[i] == True:
self.ui.comboBox_splines.addItem(splines[i],i)
def init_comboBox_regres(self):
regres = ["lowess","supersmoother","ridge","lasso"]
regres_use = [True,self.supersmoother_found,self.sklearn_found,self.sklearn_found]
for i in range(len(regres)):
if regres_use[i] == True:
self.ui.comboBox_regs.addItem(regres[i],i)
def init_comboBox_GP(self):
gps = ["squared_exp","matern","periodic","periodic_auto"]
for i in range(len(gps)):
self.ui.comboBox_GP.addItem(gps[i],i)
def initialize_plots(self):
#global p_1,p_2
xaxis = ['BJD [days]','BJD [days]']
yaxis = ['Flux','Flux']
xunit = ['' ,'']
yunit = ['' ,'' ]
#p_1 = self.ui.plot
#p_2 = self.ui.plot_2
zzz = [self.ui.plot,self.ui.plot_2]
for i in range(len(zzz)):
zzz[i].getAxis("bottom").tickFont = self.font
zzz[i].getAxis("bottom").setStyle(tickTextOffset = 12)
zzz[i].getAxis("top").tickFont = self.font
zzz[i].getAxis("top").setStyle(tickTextOffset = 12)
zzz[i].getAxis("left").tickFont = self.font
zzz[i].getAxis("left").setStyle(tickTextOffset = 12)
zzz[i].getAxis("right").tickFont = self.font
zzz[i].getAxis("right").setStyle(tickTextOffset = 12)
zzz[i].getAxis('left').setWidth(50)
zzz[i].getAxis('right').setWidth(10)
zzz[i].getAxis('top').setHeight(10)
zzz[i].getAxis('bottom').setHeight(50)
zzz[i].setLabel('bottom', '%s'%xaxis[i], units='%s'%xunit[i], **{'font-size':'9pt'})
zzz[i].setLabel('left', '%s'%yaxis[i], units='%s'%yunit[i], **{'font-size':'9pt'})
zzz[i].showAxis('top')
zzz[i].showAxis('right')
zzz[i].getAxis('bottom').enableAutoSIPrefix(enable=False)
#zzz[i].getViewBox().setAspectLocked(True)
return
def main():
app = QtWidgets.QApplication(sys.argv)
# main = DetrendWindow()
# main.show()
sys.exit(app.exec_())
if __name__ == '__main__':
main()