예제 #1
0
파일: __init__.py 프로젝트: anetasie/sherpa
        def _sherpa_plot(self, *args, **kwargs):
            """Call Sherpa plot ``func`` for each dataset.

            :param func: Sherpa plot function
            :param args: plot function list arguments
            :param kwargs: plot function named (keyword) arguments
            :rtype: None
            """
            # FIXME We need to make sure ChIPS is initialized.
            # As a hack, we just call begin() and end() on the chips backend
            # To make sure the backend is initialized before we start creating windows.
            if _plot_pkg == 'chips':
                try:
                    chips_backend.begin()
                finally:
                    chips_backend.end()
            for dataset in self.filter_datasets():
                if _plot_pkg == 'chips':
                    try:
                        pychips.add_window(['id', dataset['id']])
                    except RuntimeError:
                        pass  # already exists
                    # window_id = pychips.ChipsId()
                    # window_id.window = dataset['id']
                    pychips.current_window(str(dataset['id']))
                elif _plot_pkg == 'pylab':
                    plt.figure(self.ids.index(dataset['id']) + 1)
                else:
                    raise ValueError('Unknown plot package')

                func(dataset['id'], *args, **kwargs)
예제 #2
0
        def _sherpa_plot(self, *args, **kwargs):
            """Call Sherpa plot ``func`` for each dataset.

            :param func: Sherpa plot function
            :param args: plot function list arguments
            :param kwargs: plot function named (keyword) arguments
            :rtype: None
            """
            # FIXME We need to make sure ChIPS is initialized.
            # As a hack, we just call begin() and end() on the chips backend
            # To make sure the backend is initialized before we start creating windows.
            if _plot_pkg == 'chips':
                try:
                    chips_backend.begin()
                finally:
                    chips_backend.end()
            for dataset in self.filter_datasets():
                if _plot_pkg == 'chips':
                    try:
                        pychips.add_window(['id', dataset['id']])
                    except RuntimeError:
                        pass  # already exists
                    # window_id = pychips.ChipsId()
                    # window_id.window = dataset['id']
                    pychips.current_window(str(dataset['id']))
                elif _plot_pkg == 'pylab':
                    plt.figure(self.ids.index(dataset['id']) + 1)
                else:
                    raise ValueError('Unknown plot package')

                func(dataset['id'], *args, **kwargs)
예제 #3
0
def initialize_plot(dataset, ids):
    """Create the plot window or figure for the given dataset.

    Parameters
    ----------
    dataset : str or int
       The dataset.
    ids : array_like
       The identifier array from the DataStack object.

    See Also
    --------
    select_plot

    """
    try:
        pychips.add_window(['id', dataset['id']])
    except RuntimeError:
        pass
    pychips.current_window(str(dataset['id']))
예제 #4
0
        def _sherpa_plot(self, *args, **kwargs):
            """Call Sherpa plot ``func`` for each dataset.

            :param func: Sherpa plot function
            :param args: plot function list arguments
            :param kwargs: plot function named (keyword) arguments
            :rtype: None
            """
            for dataset in self.filter_datasets():
                if _plot_pkg == 'chips':
                    try:
                        pychips.add_window(['id', dataset['id']])
                    except RuntimeError:
                        pass  # already exists
                    # window_id = pychips.ChipsId()
                    # window_id.window = dataset['id']
                    pychips.current_window(str(dataset['id']))
                elif _plot_pkg == 'pylab':
                    plt.figure(self.ids.index(dataset['id']) + 1)
                else:
                    raise ValueError('Unknown plot package')

                func(dataset['id'], *args, **kwargs)