Exemplo n.º 1
0
    def commit(self):
        # Test if Glueviz is running or closed already
        if self.gluvizapp is not None:
            import sip
            app = self.gluvizapp
            if sip.isdeleted(app):
                # Clear last instance closed
                self.gluvizapp = None
                self.infob.setText(
                    "Please click the button below to run Glueviz.")
                return
            # Glueviz is running
            else:
                return

        from glue.core import DataCollection
        from glue.qglue import parse_data

        dc = DataCollection()
        for table in self.tables.values():
            gd = parse_data(table, table.name)
            dc.append(gd[0])

        # start Glue
        from glue.app.qt.application import GlueApplication
        self.gluvizapp = GlueApplication(dc)
        # ------------------------------------------------------------------
        # Very important!!! Can't open another QMainWindow without this line
        self.windowList.append(self.gluvizapp)
        self.close()
        self.gluvizapp.start()
        self.infob.setText("Glueviz is running.")
Exemplo n.º 2
0
    def add_data(self, *args, **kwargs):
        """
        Add data to the session.

        Positional arguments are interpreted using the data factories, while
        keyword arguments are interpreted using the same infrastructure as the
        `qglue` command.
        """

        datasets = []

        for path in args:
            datasets.append(load_data(path))

        links = kwargs.pop('links', None)

        from glue.qglue import parse_data, parse_links

        for label, data in kwargs.items():
            datasets.extend(parse_data(data, label))

        self.add_datasets(self.data_collection, datasets)

        if links is not None:
            self.data_collection.add_link(parse_links(self.data_collection, links))
Exemplo n.º 3
0
def jglue(*args, settings=None, show=False, links=None, **kwargs):
    """
    Create a new Jupyter-based glue application.

    It is typically easiest to call this function without arguments and load
    data and add links separately in subsequent calls. However, this function
    can also take the same inputs as the `~glue.qglue` function.

    Once this function is called, it will return a
    `~glue_jupyter.JupyterApplication` object, which can then be used to
    load data, set up links, and create visualizations. See the documentation
    for that class for more details.
    """

    from glue.qglue import parse_data, parse_links
    from glue.core.data_factories import load_data

    japp = JupyterApplication(settings=settings)

    dc = japp.data_collection
    for label, data in kwargs.items():
        if isinstance(data, str):
            data = load_data(data)
        dc.extend(parse_data(data, label))
    for data in args:
        dc.append(data)

    if links is not None:
        dc.add_link(parse_links(dc, links))

    if show:
        display(japp)
    return japp
Exemplo n.º 4
0
def test_qglue():
    from spectral_cube import SpectralCube
    cube = SpectralCube.read(os.path.join(DATA, 'cube_3d.fits'))
    data = parse_data(cube, 'x')[0]
    assert data.label == 'x'
    data['flux']
    assert data.shape == (2, 3, 4)
Exemplo n.º 5
0
    def add_data(self, *args, **kwargs):
        """
        Add data to the session.

        Positional arguments are interpreted using the data factories, while
        keyword arguments are interpreted using the same infrastructure as the
        `qglue` command.

        This returns a list of added `Data` objects.
        """

        datasets = []

        for path in args:
            datasets.append(load_data(path))

        links = kwargs.pop('links', None)

        from glue.qglue import parse_data, parse_links

        for label, data in kwargs.items():
            datasets.extend(parse_data(data, label))

        self.add_datasets(self.data_collection, datasets)

        if links is not None:
            self.data_collection.add_link(
                parse_links(self.data_collection, links))

        return datasets
Exemplo n.º 6
0
def test_qglue():
    from spectral_cube import SpectralCube
    cube = SpectralCube.read(os.path.join(DATA, 'cube_3d.fits'))
    data = parse_data(cube, 'x')[0]
    assert data.label == 'x'
    data['STOKES I']
    assert data.shape == (2, 3, 4)
Exemplo n.º 7
0
 def as_data_objects(ds, lbl):
     # pack other container types like astropy tables
     # into glue data objects
     for d in ds:
         if isinstance(d, BaseData):
             yield d
             continue
         for item in parse_data(d, lbl):
             yield item
Exemplo n.º 8
0
 def as_data_objects(ds, lbl):
     # pack other container types like astropy tables
     # into glue data objects
     for d in ds:
         if isinstance(d, Data):
             yield d
             continue
         for item in parse_data(d, lbl):
             yield item
Exemplo n.º 9
0
def test_glue(db, RE):
    from databroker.glue import read_header
    from glue.qglue import parse_data
    import bluesky.plans as bp
    from ophyd.sim import SynAxis, SynGauss
    motor = SynAxis(name='motor')
    det = SynGauss('det',
                   motor,
                   'motor',
                   center=0,
                   Imax=1,
                   noise='uniform',
                   sigma=1,
                   noise_multiplier=0.1)
    RE.subscribe(db.insert)
    RE(bp.scan([det], motor, -5, 5, 10))

    d = read_header(db[-1])
    g = parse_data(d[0], 'test')[0].to_dataframe()
Exemplo n.º 10
0
def jglue(*args, **kwargs):
    from glue.core import DataCollection
    from glue.app.qt import GlueApplication
    from glue.qglue import parse_data, parse_links
    from glue.core.data_factories import load_data

    links = kwargs.pop('links', None)

    dc = DataCollection()
    for label, data in kwargs.items():
        if isinstance(data, six.string_types):
            data = load_data(data)
        dc.extend(parse_data(data, label))
    for data in args:
        dc.append(data)

    if links is not None:
        dc.add_link(parse_links(dc, links))

    japp = JupyterApplication(dc)
    return japp
Exemplo n.º 11
0
    def add_data(self, *args, **kwargs):

        datasets = []

        for path in args:
            datasets.append(load_data(path))

        links = kwargs.pop('links', None)

        from glue.qglue import parse_data, parse_links

        for label, data in kwargs.items():
            datasets.extend(parse_data(data, label))

        self.add_datasets(self.data_collection, datasets)

        if links is not None:
            self.data_collection.add_link(
                parse_links(self.data_collection, links))

        return datasets
Exemplo n.º 12
0
def test_qglue():
    cube = SpectralCube.read(get_pkg_data_filename('data/cube_3d.fits'))
    data = parse_data(cube, 'x')[0]
    assert data.label == 'x'
    assert isinstance(data['flux'], np.ndarray)
    assert data.shape == (2, 3, 4)