Exemple #1
0
    def load_data(self):
        """Highest level method to interactively load a data set.

        :rtype: A list of constructed data objects
        """
        from glue.core.data_factories import data_label, load_data
        paths, fac = self._get_paths_and_factory()
        result = []

        # Check that the user didn't select a .glu file by mistake
        for path in paths:
            if path.endswith('.glu'):
                mb = QtWidgets.QMessageBox(QtWidgets.QMessageBox.Critical,
                                           "Error loading data",
                                           "It looks like you have selected "
                                           "a .glu session file. You should open "
                                           "this using 'Open Session' under the "
                                           "'File' menu instead")
                mb.exec_()
                return []

        with set_cursor_cm(Qt.WaitCursor):
            for path in paths:
                self._curfile = path
                d = load_data(path, factory=fac.function)
                if not isinstance(d, list):
                    if not d.label:
                        d.label = data_label(path)
                    d = [d]
                result.extend(d)

        return result
    def load_data(self):
        """Highest level method to interactively load a data set.

        :rtype: A list of constructed data objects
        """
        from glue.core.data_factories import data_label, load_data
        paths, fac = self._get_paths_and_factory()
        result = []

        # Check that the user didn't select a .glu file by mistake
        for path in paths:
            if path.endswith('.glu'):
                mb = QtWidgets.QMessageBox(
                    QtWidgets.QMessageBox.Critical, "Error loading data",
                    "It looks like you have selected "
                    "a .glu session file. You should open "
                    "this using 'Open Session' under the "
                    "'File' menu instead")
                mb.exec_()
                return []

        with set_cursor_cm(Qt.WaitCursor):
            for path in paths:
                self._curfile = path
                d = load_data(path, factory=fac.function)
                if not isinstance(d, list):
                    if not d.label:
                        d.label = data_label(path)
                    d = [d]
                result.extend(d)

        return result
Exemple #3
0
    def load_data(self):
        """Highest level method to interactively load a data set.

        :rtype: A constructed data object, or None
        """
        from glue.core.data_factories import data_label
        path, fac = self._get_path_and_factory()
        if path is not None:
            result = fac.function(path)
            result.label = data_label(path)
            return result
Exemple #4
0
    def load_data(self):
        """Highest level method to interactively load a data set.

        :rtype: A list of constructed data objects
        """
        from glue.core.data_factories import data_label
        path, fac = self._get_path_and_factory()
        if path is not None:
            result = fac.function(path)
            if isinstance(result, list):
                return result
            #single data object
            result.label = data_label(path)
            return [result]
        return []
Exemple #5
0
    def load_data(self):
        """Highest level method to interactively load a data set.

        :rtype: A list of constructed data objects
        """
        from glue.core.data_factories import data_label
        path, fac = self._get_path_and_factory()
        if path is not None:
            result = fac.function(path)
            if isinstance(result, list):
                return result
            #single data object
            result.label = data_label(path)
            return [result]
        return []
Exemple #6
0
    def load_data(self):
        """Highest level method to interactively load a data set.

        :rtype: A list of constructed data objects
        """
        from glue.core.data_factories import data_label, load_data
        paths, fac = self._get_paths_and_factory()
        result = []

        for path in paths:
            d = load_data(path, factory=fac.function)
            if not isinstance(d, list):
                d.label = data_label(path)
                d = [d]
            result.extend(d)

        return result
Exemple #7
0
    def load_data(self):
        """Highest level method to interactively load a data set.

        :rtype: A list of constructed data objects
        """
        from glue.core.data_factories import data_label, load_data
        paths, fac = self._get_paths_and_factory()
        result = []

        for path in paths:
            d = load_data(path, factory=fac.function)
            if not isinstance(d, list):
                d.label = data_label(path)
                d = [d]
            result.extend(d)

        return result
Exemple #8
0
def yt_data(path):
    """Use yt to load a gridded dataset

    This function will extract all particle and field datasets
    (excluding derived datasets) from a file. Currently,
    you cannot make images from this data.

    The resulting Field dataset refers to the highest-resolution
    subgrids

    Paramters
    ---------
    path : str
           Path to file to load. This is what get's passed to yt.mods.load()

    Returns
    -------
    One or two Glue data objects
    """
    ds = load(path)
    dd = ds.h.all_data()

    particles = [f for f in ds.h.field_list if ds.field_info[f].particle_type]
    fields = [f for f in ds.h.field_list if not ds.field_info[f].particle_type]

    lbl = data_label(path)

    result = []
    if len(particles) > 0:
        d1 = Data(label=lbl + "_particle")
        shp = dd[particles[0]].shape
        for p in particles:
            d1.add_component(YtComponent(ds, p, shp), p)
        result.append(d1)

    if len(fields) > 0:
        d2 = Data(label=lbl + "_field")
        shp = dd[fields[0]].shape
        for f in fields:
            d2.add_component(YtComponent(ds, f, shp), f)
        result.append(d2)

    return result
def test_data_label():
    assert df.data_label('test.fits') == 'test'
    assert df.data_label('/Leading/Path/test.fits') == 'test'
    assert df.data_label('') == ''
    assert df.data_label('/Leading/Path/no_extension') == 'no_extension'
    assert df.data_label('no_extension') == 'no_extension'
Exemple #10
0
def test_data_label():
    assert df.data_label('test.fits') == 'test'
    assert df.data_label('/Leading/Path/test.fits') == 'test'
    assert df.data_label('') == ''
    assert df.data_label('/Leading/Path/no_extension') == 'no_extension'
    assert df.data_label('no_extension') == 'no_extension'