@@ -78,11 +78,7 @@ def onWheel(self, event):
78
78
new_height = (curr_ylim [1 ]- curr_ylim [0 ])* factor * 0.5
79
79
self .axes .set_xlim ([curr_x0 - new_width ,curr_x0 + new_width ])
80
80
self .axes .set_ylim ([curr_y0 - new_height ,curr_y0 + new_height ])
81
- # Adjust size of array
82
- #self.update()
83
81
self .draw_idle ()
84
- #self.fig.canvas.flush_events()
85
- #plt.show(block=False)
86
82
87
83
def compute_initial_figure (self ,ra = None ,dec = None ):
88
84
from astropy .wcs import WCS
@@ -144,9 +140,6 @@ def updateFigure(self, nod, ra, dec, dx, dy, angle, infile):
144
140
self .axes .set_xlim ([xlim [1 ],xlim [0 ]])
145
141
# Update figure
146
142
self .draw_idle ()
147
- #self.update()
148
- #self.fig.canvas.flush_events()
149
- #plt.show(block=False)
150
143
151
144
class FluxCanvas (MplCanvas ):
152
145
"""A canvas that show spectra and some housekeeping"""
@@ -268,10 +261,6 @@ def onMotion(self, event):
268
261
self .axes1 .set_xlim (curr_xlim - deltax )
269
262
self .axes1 .set_ylim (curr_ylim - deltay )
270
263
self .pick_pos = new_pos
271
- # Not clear how to use blit
272
- # self.draw()
273
- #self.fig.canvas.blit(self.axes.bbox)
274
- #self.update()
275
264
# Draw only when idle
276
265
self .draw_idle ()
277
266
return True
@@ -287,8 +276,6 @@ def onRelease(self, event):
287
276
def compute_initial_figure (self ,fileGroupId = None ):
288
277
# Clear figure
289
278
self .fig .clear ()
290
- #plt.ion()
291
- #plt.show(False)
292
279
# Initialize display
293
280
self .displayZA = True
294
281
self .displayAlt = True
@@ -357,8 +344,8 @@ def updateFigure(self,nod,spec,infile,za,alti,wv):
357
344
self .labpos .append (sum (self .coverage )- 0.5 * self .coverage [i - 1 ])
358
345
self .axes2 .set_xticks (self .labpos )
359
346
self .axes2 .set_xticklabels (labels ,rotation = 90 ,ha = 'center' ,fontsize = 10 )
360
- # Set limits around last observation
361
- self .axes2 .set_xlim ([self .coverage [i - 1 ]* (i - 1.5 * self .w ),self .coverage [i - 1 ]* (i + 0.5 * self .w )]) # Set at least 20 observations
347
+ # Set limits around last observation (at least 20 observations)
348
+ self .axes2 .set_xlim ([self .coverage [i - 1 ]* (i - 1.5 * self .w ),self .coverage [i - 1 ]* (i + 0.5 * self .w )])
362
349
self .axes2 .autoscale (enable = True ,axis = 'y' )
363
350
364
351
# Shade background of last position
@@ -404,7 +391,6 @@ def updateFigure(self,nod,spec,infile,za,alti,wv):
404
391
self .wvLayer .set_visible (self .displayWV )
405
392
406
393
self .draw_idle ()
407
- # self.fig.canvas.flush_events()
408
394
409
395
410
396
class myListWidget (QListWidget ):
@@ -437,7 +423,6 @@ def __init__(self, selFileNames, fileNames, parent=None):
437
423
def run (self ):
438
424
from fifitools import readData , multiSlopes , Obs
439
425
from timeit import default_timer as timer
440
- #print self.selFileNames
441
426
for infile in self .selFileNames :
442
427
if infile not in self .fileNames :
443
428
try :
@@ -447,22 +432,20 @@ def run(self):
447
432
spectrum = np .nanmedian (spectra ,axis = 2 )
448
433
detchan , order , dichroic , ncycles , nodbeam , filegpid , filenum = aor
449
434
obsdate , coords , offset , angle , za , altitude , wv = hk
450
- #print "filenum is: ", filenum
451
435
obj = Obs (spectrum ,coords ,offset ,angle ,altitude ,za ,wv ,nodbeam ,filegpid ,filenum ,gratpos ,detchan )
452
436
t2 = timer ()
453
437
print "Fitted: " , infile , " " ,np .shape (spectrum ), " in: " , t2 - t1 ," s"
454
438
# Call this with a signal from thread
455
- #print 'update objects with file ', filenum
456
439
self .updateObjects .newObj .emit (obj )
457
- #print 'update filename with file ', filenum
458
440
self .updateFilenames .emit (infile )
459
- #print 'update figures with file ', filenum
460
441
self .updateFigures .emit (infile )
461
442
except :
462
443
print "Problems with file: " , infile
463
444
else :
464
445
self .updateFigures .emit (infile )
465
446
print "Done adding observations thread"
447
+ # Disconnect signal at the end of the thread
448
+ self .updateObjects .newObj .disconnect ()
466
449
467
450
468
451
class ApplicationWindow (QMainWindow ):
@@ -556,14 +539,6 @@ def __init__(self):
556
539
# Compile the list of unique File group IDs
557
540
self .fgidList = list (set (self .fgid ))
558
541
559
- # Set channel to display
560
- #channels = list(set(self.ch))
561
- #if 'BLUE' in channels:
562
- # self.channel = 'BLUE'
563
- #else:
564
- # self.channel = 'RED'
565
- #print "Channel is: ", self.channel
566
-
567
542
# Start list of observations
568
543
self .fileGroupId = None
569
544
@@ -623,7 +598,6 @@ def __init__(self):
623
598
self .lf .addItem (item );
624
599
self .lf .setWindowTitle ('File Group ID' )
625
600
self .lf .itemClicked .connect (self .lf .Clicked )
626
-
627
601
# Status Bar
628
602
self .sb = QStatusBar ()
629
603
self .sb .showMessage ("Welcome to FIFI Monitor!" , 10000 )
@@ -751,7 +725,6 @@ def addObs(self, fileGroupId = None, newfiles=False):
751
725
if self .fileGroupId == None :
752
726
return
753
727
754
- #mask = (self.fgid == self.fileGroupId) & (self.ch == self.channel)
755
728
mask = self .fgid == self .fileGroupId
756
729
# Select the channel
757
730
channels = list (set (self .ch [mask ]))
@@ -780,16 +753,6 @@ def addObs(self, fileGroupId = None, newfiles=False):
780
753
except :
781
754
print "Failed to read file " ,selFileNames [0 ]
782
755
return
783
-
784
- # number of file added
785
- #self.n = None
786
-
787
- # Start a thread to fit ramps and plot data
788
- # First disconnect previous thread, otherwise is called again
789
- try :
790
- self .addObsThread .updateObjects .newObj .disconnect ()
791
- except :
792
- pass
793
756
794
757
self .addObsThread = AddObsThread (selFileNames ,self .fileNames )
795
758
self .addObsThread .updateObjects .newObj .connect (self .update_objects )
@@ -804,23 +767,12 @@ def addObs(self, fileGroupId = None, newfiles=False):
804
767
#print('memory use:', memoryUse)
805
768
806
769
def update_objects (self , obj ):
807
- #print "updating objects with object ", obj.n
808
- # Check if already there ... until I discover how to treat the bug
809
- #if self.n == None:
810
- # self.n = obj.n
811
- # self.obs.append(obj)
812
- #else:
813
- # if obj.n == self.n:
814
- # pass
815
- # else:
816
- # self.obs.append(obj)
817
- # self.n = obj.n
818
770
self .obs .append (obj )
819
771
820
772
def update_filenames (self , infile ):
821
773
#print "updating filenames with file ", infile
822
774
self .fileNames .append (infile )
823
-
775
+
824
776
def update_figures (self , infile ):
825
777
from timeit import default_timer as timer
826
778
0 commit comments