Exemple #1
0
    def __call__(self, *args, **kargs):
        # Call handler functions
        to_be_removed = []
        for func in self._functions.copy():
            try:
                func(*args, **kargs)
            except RuntimeError:
                Warning.warn(
                    'Signals func->RuntimeError: func "{}" will be removed.'.
                    format(func))
                to_be_removed.append(func)

        for remove in to_be_removed:
            self._functions.discard(remove)

        # Call handler methods
        to_be_removed = []
        emitters = self._methods.copy()
        for obj, funcs in emitters.items():
            msg_debug('obj is type "{}"'.format(type(obj)))
            for func in funcs.copy():
                try:
                    func(obj, *args, **kargs)
                except RuntimeError:
                    warnings.warn(
                        'Signals methods->RuntimeError, obj.func "{}.{}" will be removed'
                        .format(obj, func))
                    to_be_removed.append((obj, func))

        for obj, func in to_be_removed:
            self._methods[obj].discard(func)
Exemple #2
0
    def __call__(self, *args, **kargs):
        # Call handler functions
        to_be_removed = []
        for func in self._functions.copy():
            try:
                func(*args, **kargs)
            except RuntimeError:
                Warning.warn('Signals func->RuntimeError: func "{}" will be removed.'.format(func))
                to_be_removed.append(func)

        for remove in to_be_removed:
            self._functions.discard(remove)

        # Call handler methods
        to_be_removed = []
        emitters = self._methods.copy()
        for obj, funcs in emitters.items():
            msg_debug('obj is type "{}"'.format(type(obj)))
            for func in funcs.copy():
                try:
                    func(obj, *args, **kargs)
                except RuntimeError:
                    warnings.warn('Signals methods->RuntimeError, obj.func "{}.{}" will be removed'.format(obj, func))
                    to_be_removed.append((obj, func))

        for obj, func in to_be_removed:
            self._methods[obj].discard(func)
Exemple #3
0
    def _draw(self, *args):
        msg_debug('entered')

        for spectrum in self.spectra:
            flux = np.asarray(spectrum.data)
            self.axes.plot(flux)
        self.ui.plotView.canvas.draw()
Exemple #4
0
    def _draw(self, *args):
        msg_debug('entered')

        for spectrum in self.spectra:
            flux = np.asarray(spectrum.data)
            self.axes.plot(flux)
        self.ui.plotView.canvas.draw()
Exemple #5
0
 def _change_data_range(self, axes):
     msg_debug('entered')
     msg_debug('Axes: {}'.format(id(axes)))
     xlim_low, xlim_high = axes.get_xlim()
     ylim_low, ylim_high = axes.get_ylim()
     self.signals.enotify_all('samp.app.viewport_change',
                              xlim_low=str(xlim_low), xlim_high=str(xlim_high),
                              ylim_low=str(ylim_low), ylim_high=str(ylim_high))
Exemple #6
0
 def _change_data_range(self, axes):
     msg_debug('entered')
     msg_debug('Axes: {}'.format(id(axes)))
     xlim_low, xlim_high = axes.get_xlim()
     ylim_low, ylim_high = axes.get_ylim()
     self.signals.enotify_all('samp.app.viewport_change',
                              xlim_low=str(xlim_low),
                              xlim_high=str(xlim_high),
                              ylim_low=str(ylim_low),
                              ylim_high=str(ylim_high))
Exemple #7
0
    def _viewport_change(self, viewer, axes):
        msg_debug('entered.')
        msg_debug('viewer is "{}"'.format(viewer))
        msg_debug('Sent from myself is "{}"'.format(viewer == self))
        msg_debug('Axes is "{}"'.format(axes))

        if viewer != self:
            msg_debug('resetting limits.')
            limits_new = viewer.axes.get_xlim()
            if limits_new != self.axes.get_xlim():
                self.axes.set_xlim(limits_new)
            limits_new = viewer.axes.get_ylim()
            if limits_new != self.axes.get_ylim():
                self.axes.set_ylim(limits_new)
            self.ui.plotView.canvas.draw()
Exemple #8
0
    def _draw(self):
        msg_debug('entered')

        for name, spectrum in six.iteritems(self.spectra):
            nddata = spectrum['spectrum']
            flux = np.asarray(nddata.data)
            wcs_array = getattr(nddata, 'wcs', None)
            if wcs_array is None:
                wcs_array = range(len(flux))
            try:
                plot_state = spectrum['plot_state']
            except KeyError:
                spectrum['plot_state'] = PlotState()
                plot_state = spectrum['plot_state']
            if not plot_state.isvalid:
                if plot_state.line:
                    self.axes.lines.remove(plot_state.line)
                plot_state.line = self.axes.plot(wcs_array, flux)[0]
                plot_state.validate()
        self.ui.plotView.canvas.draw()
Exemple #9
0
 def __init__(self, spectrum=None):
     msg_debug('entered.')
     super(SpectrumItem, self).__init__()
     if spectrum is not None:
         self.setData(spectrum)
Exemple #10
0
 def __init__(self, spectrum=None):
     msg_debug('entered.')
     super(SpectrumItem, self).__init__()
     if spectrum is not None:
         self.setData(spectrum)
Exemple #11
0
    def _viewport_change(self, private_key, sender_id, msg_id, mtype, params,
                         extra):
        msg_debug('entered.')
        msg_debug('msg info: {} {} {} {} {} {}'.format(private_key, sender_id,
                                                       msg_id, mtype, params,
                                                       extra))
        msg_debug('my id is "{}"'.format(self.signals.get_public_id()))

        xlim_new = (float(params['xlim_low']), float(params['xlim_high']))
        ylim_new = (float(params['ylim_low']), float(params['ylim_high']))
        if sender_id != self.signals.get_public_id():
            try:
                msg_debug('resetting limits.')
                changed = False
                xlim_old = self.axes.get_xlim()
                ylim_old = self.axes.get_ylim()
                msg_debug('xlim_old = "{}", xlim_new = "{}"'.format(
                    xlim_old, xlim_new))
                msg_debug('ylim_old = "{}", ylim_new = "{}"'.format(
                    ylim_old, ylim_new))
                if xlim_new != xlim_old:
                    changed = True
                    self.axes.set_xlim(xlim_new)
                if ylim_new != ylim_old:
                    changed = True
                    self.axes.set_ylim(ylim_new)
                if changed:
                    self.ui.plotView.canvas.draw()
            except Exception as e:
                msg_debug('Exception: {}'.format(sys.exec_info()))
            finally:
                msg_debug('finally.')
                return
        msg_debug('exiting.')
Exemple #12
0
 def _mpl_event(self, event):
     msg_debug('entered.')
     msg_debug('Event name = "{}"'.format(event.name))
Exemple #13
0
 def _change_data_range(self, axes):
     msg_debug('entered')
     msg_debug('Axes: {}'.format(id(axes)))
     self.signals.ViewportChange(self, axes)
Exemple #14
0
    def _viewport_change(self, private_key, sender_id, msg_id, mtype, params, extra):
        msg_debug('entered.')
        msg_debug('msg info: {} {} {} {} {} {}'.format(private_key,
                                                       sender_id,
                                                       msg_id,
                                                       mtype,
                                                       params,
                                                       extra))
        msg_debug('my id is "{}"'.format(self.signals.get_public_id()))

        xlim_new = (float(params['xlim_low']), float(params['xlim_high']))
        ylim_new = (float(params['ylim_low']), float(params['ylim_high']))
        if sender_id != self.signals.get_public_id():
            try:
                msg_debug('resetting limits.')
                changed = False
                xlim_old = self.axes.get_xlim()
                ylim_old = self.axes.get_ylim()
                msg_debug('xlim_old = "{}", xlim_new = "{}"'.format(xlim_old, xlim_new))
                msg_debug('ylim_old = "{}", ylim_new = "{}"'.format(ylim_old, ylim_new))
                if xlim_new != xlim_old:
                    changed = True
                    self.axes.set_xlim(xlim_new)
                if ylim_new != ylim_old:
                    changed = True
                    self.axes.set_ylim(ylim_new)
                if changed:
                    self.ui.plotView.canvas.draw()
            except Exception as e:
                msg_debug('Exception: {}'.format(sys.exec_info()))
            finally:
                msg_debug('finally.')
                return
        msg_debug('exiting.')
Exemple #15
0
 def _mpl_event(self, event):
     msg_debug('entered.')
     msg_debug('Event name = "{}"'.format(event.name))