Skip to content

Commit 65d5309

Browse files
author
Fadda
committed
more elegant version of disconnect, new version
1 parent aa5a8b9 commit 65d5309

File tree

3 files changed

+8
-56
lines changed

3 files changed

+8
-56
lines changed

fifimon/mainwindow.py

Lines changed: 5 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,7 @@ def onWheel(self, event):
7878
new_height= (curr_ylim[1]-curr_ylim[0])*factor*0.5
7979
self.axes.set_xlim([curr_x0-new_width,curr_x0+new_width])
8080
self.axes.set_ylim([curr_y0-new_height,curr_y0+new_height])
81-
# Adjust size of array
82-
#self.update()
8381
self.draw_idle()
84-
#self.fig.canvas.flush_events()
85-
#plt.show(block=False)
8682

8783
def compute_initial_figure(self,ra=None,dec=None):
8884
from astropy.wcs import WCS
@@ -144,9 +140,6 @@ def updateFigure(self, nod, ra, dec, dx, dy, angle, infile):
144140
self.axes.set_xlim([xlim[1],xlim[0]])
145141
# Update figure
146142
self.draw_idle()
147-
#self.update()
148-
#self.fig.canvas.flush_events()
149-
#plt.show(block=False)
150143

151144
class FluxCanvas(MplCanvas):
152145
"""A canvas that show spectra and some housekeeping"""
@@ -268,10 +261,6 @@ def onMotion(self, event):
268261
self.axes1.set_xlim(curr_xlim-deltax)
269262
self.axes1.set_ylim(curr_ylim-deltay)
270263
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()
275264
# Draw only when idle
276265
self.draw_idle()
277266
return True
@@ -287,8 +276,6 @@ def onRelease(self, event):
287276
def compute_initial_figure(self,fileGroupId=None):
288277
# Clear figure
289278
self.fig.clear()
290-
#plt.ion()
291-
#plt.show(False)
292279
# Initialize display
293280
self.displayZA = True
294281
self.displayAlt = True
@@ -357,8 +344,8 @@ def updateFigure(self,nod,spec,infile,za,alti,wv):
357344
self.labpos.append(sum(self.coverage)-0.5*self.coverage[i-1])
358345
self.axes2.set_xticks(self.labpos)
359346
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)])
362349
self.axes2.autoscale(enable=True,axis='y')
363350

364351
# Shade background of last position
@@ -404,7 +391,6 @@ def updateFigure(self,nod,spec,infile,za,alti,wv):
404391
self.wvLayer.set_visible(self.displayWV)
405392

406393
self.draw_idle()
407-
# self.fig.canvas.flush_events()
408394

409395

410396
class myListWidget(QListWidget):
@@ -437,7 +423,6 @@ def __init__(self, selFileNames, fileNames, parent=None):
437423
def run(self):
438424
from fifitools import readData, multiSlopes, Obs
439425
from timeit import default_timer as timer
440-
#print self.selFileNames
441426
for infile in self.selFileNames:
442427
if infile not in self.fileNames:
443428
try:
@@ -447,22 +432,20 @@ def run(self):
447432
spectrum = np.nanmedian(spectra,axis=2)
448433
detchan, order, dichroic, ncycles, nodbeam, filegpid, filenum = aor
449434
obsdate, coords, offset, angle, za, altitude, wv = hk
450-
#print "filenum is: ", filenum
451435
obj = Obs(spectrum,coords,offset,angle,altitude,za,wv,nodbeam,filegpid,filenum,gratpos,detchan)
452436
t2=timer()
453437
print "Fitted: ", infile, " ",np.shape(spectrum), " in: ", t2-t1," s"
454438
# Call this with a signal from thread
455-
#print 'update objects with file ', filenum
456439
self.updateObjects.newObj.emit(obj)
457-
#print 'update filename with file ', filenum
458440
self.updateFilenames.emit(infile)
459-
#print 'update figures with file ', filenum
460441
self.updateFigures.emit(infile)
461442
except:
462443
print "Problems with file: ", infile
463444
else:
464445
self.updateFigures.emit(infile)
465446
print "Done adding observations thread"
447+
# Disconnect signal at the end of the thread
448+
self.updateObjects.newObj.disconnect()
466449

467450

468451
class ApplicationWindow(QMainWindow):
@@ -556,14 +539,6 @@ def __init__(self):
556539
# Compile the list of unique File group IDs
557540
self.fgidList = list(set(self.fgid))
558541

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-
567542
# Start list of observations
568543
self.fileGroupId = None
569544

@@ -623,7 +598,6 @@ def __init__(self):
623598
self.lf.addItem(item);
624599
self.lf.setWindowTitle('File Group ID')
625600
self.lf.itemClicked.connect(self.lf.Clicked)
626-
627601
# Status Bar
628602
self.sb = QStatusBar()
629603
self.sb.showMessage("Welcome to FIFI Monitor!", 10000)
@@ -751,7 +725,6 @@ def addObs(self, fileGroupId = None, newfiles=False):
751725
if self.fileGroupId == None:
752726
return
753727

754-
#mask = (self.fgid == self.fileGroupId) & (self.ch == self.channel)
755728
mask = self.fgid == self.fileGroupId
756729
# Select the channel
757730
channels = list(set(self.ch[mask]))
@@ -780,16 +753,6 @@ def addObs(self, fileGroupId = None, newfiles=False):
780753
except:
781754
print "Failed to read file ",selFileNames[0]
782755
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
793756

794757
self.addObsThread = AddObsThread(selFileNames,self.fileNames)
795758
self.addObsThread.updateObjects.newObj.connect(self.update_objects)
@@ -804,23 +767,12 @@ def addObs(self, fileGroupId = None, newfiles=False):
804767
#print('memory use:', memoryUse)
805768

806769
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
818770
self.obs.append(obj)
819771

820772
def update_filenames(self, infile):
821773
#print "updating filenames with file ", infile
822774
self.fileNames.append(infile)
823-
775+
824776
def update_figures(self, infile):
825777
from timeit import default_timer as timer
826778

meta.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
package:
22
name: fifimon
3-
version: 0.19.alpha
3+
version: 0.20.alpha
44

55
source:
6-
git_rev: v0.19-alpha
6+
git_rev: v0.20-alpha
77
git_url: https://github.com/darioflute/fifimon.git
88

99
build:

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import setuptools
55

66
setup(name='fifimon',
7-
version='0.19.alpha',
7+
version='0.20.alpha',
88
description='FIFI-LS Monitor',
99
long_description='The package monitors FIFI-LS data',
1010
author='Dario Fadda',

0 commit comments

Comments
 (0)