-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathredshift_checker.py
39 lines (35 loc) · 1.25 KB
/
redshift_checker.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
'''Build like you want to distribute on GitHub'''
import numpy as np
import matplotlib.pyplot as plt
class DragSpectra:
def __init__(self,spectra,ydata,ax5):
self.ax5 = ax5
print 'begin shift'
self.spectra = spectra
self.ydata = ydata
self.pressed = False
self.dx_tot = 0.0
#figure.canvas.mpl_connect('motion_notify_event',self.on_motion)
#figure.canvas.mpl_connect('button_press_event',self.on_press)
#figure.canvas.mpl_connect('button_release_event',self.on_release)
def on_motion(self,evt):
if self.pressed:
dx = evt.xdata - self.mouse_x
#self.dx_tot += dx
self.spectra.set_data(self.spectra_x + dx,self.ydata)
plt.draw()
def on_press(self,evt):
if evt.inaxes == self.ax5:
self.mouse_x = evt.xdata
self.spectra_x = self.spectra.get_xdata()
self.pressed = True
#print 'mouse press'
else: return
def on_release(self,evt):
if evt.inaxes == self.ax5:
self.pressed = False
#print evt.xdata - self.mouse_x
self.dx_tot += evt.xdata - self.mouse_x
print self.dx_tot
#print 'release event'
else: return