Example #1
0
    def update_max_min(self):
        """
        Updates the max and min boxes in colorbar dialog.

        There should be code in here which stops this process on large cubes...
        The time taken in this case is too large for the small reward.

        """
        QApplication.setOverrideCursor(QtCore.Qt.WaitCursor)
        scheme = self.colorbar_dialog.get_colorbar_scheme()

        if scheme is "auto":
            colorbar_max, colorbar_min = cl.find_max_min(self.plotted_cube)
            self.colorbar_dialog.set_max_min(colorbar_max, colorbar_min)

        elif scheme is "fixed":
            # want to fix the colorbar across all of the slices.
            cube = self.cube
            dim_1_index = self.select_dimension_1.currentIndex()
            dim_2_index = self.select_dimension_2.currentIndex()
            sliced_dim_index = self.select_sliced_dim.currentIndex()
            dim_indices = {'dim 1 index': dim_1_index,
                           'dim 2 index': dim_2_index,
                           'sliced dim index': sliced_dim_index}
            collapsed_indices = []
            for i in xrange(self.ndim - 3):
                box_name = "select_slice_index_" + str(i+1)
                box = self.findChild(QtGui.QComboBox, box_name)
                collapsed_indices.append(box.currentIndex())

            colorbar_max, colorbar_min = cl.set_fixed_colorbar(
                cube, dim_indices, collapsed_indices)
            self.colorbar_dialog.set_max_min(colorbar_max, colorbar_min)

        QApplication.restoreOverrideCursor()
Example #2
0
    def update_max_min(self):
        """
        Updates the max and min boxes in colorbar dialog.

        There should be code in here which stops this process on large cubes...
        The time taken in this case is too large for the small reward.

        """
        QApplication.setOverrideCursor(QtCore.Qt.WaitCursor)
        scheme = self.colorbar_dialog.get_colorbar_scheme()

        if scheme is "auto":
            colorbar_max, colorbar_min = cl.find_max_min(self.plotted_cube)
            self.colorbar_dialog.set_max_min(colorbar_max, colorbar_min)

        elif scheme is "fixed":
            # want to fix the colorbar across all of the slices.
            cube = self.cube
            dim_1_index = self.select_dimension_1.currentIndex()
            dim_2_index = self.select_dimension_2.currentIndex()
            sliced_dim_index = self.select_sliced_dim.currentIndex()
            dim_indices = {'dim 1 index': dim_1_index,
                           'dim 2 index': dim_2_index,
                           'sliced dim index': sliced_dim_index}
            collapsed_indices = []
            for i in xrange(self.ndim - 3):
                box_name = "select_slice_index_" + str(i+1)
                box = self.findChild(QtGui.QComboBox, box_name)
                collapsed_indices.append(box.currentIndex())

            colorbar_max, colorbar_min = cl.set_fixed_colorbar(
                cube, dim_indices, collapsed_indices)
            self.colorbar_dialog.set_max_min(colorbar_max, colorbar_min)

        QApplication.restoreOverrideCursor()
Example #3
0
 def test_fixed_colormap(self):
     cube = setup_7d_anonymous_cube()
     dim_indices = {'dim 1 index': 1,
                    'dim 2 index': 4,
                    'sliced dim index': 0}
     collapsed_indices = [2, 3, 4, 0]
     maximum, minimum = cl.set_fixed_colorbar(
         cube, dim_indices, collapsed_indices)
     max_min = (maximum, minimum)
     expected = (76745, 1645)
     self.assertEqual(max_min, expected)
Example #4
0
    def get_status(self):
        """
        This method gathers information from around the interface, and then
        packages it up into a dictionary which can be neatly passed around.

        """
        cube_loaded = self.cube_loaded
        if cube_loaded:
            filename = self.filename
            cube_index = self.select_cube.currentIndex()
            set_global = self.set_global
            cube = self.get_current_cube()
            dim_1_index = self.select_dimension_1.currentIndex()
            dim_2_index = self.select_dimension_2.currentIndex()
            sliced_dim_index = self.select_sliced_dim.currentIndex()
            central_longitude = self.select_central_longitude.value()
            dim_indices = {'dim 1 index': dim_1_index,
                           'dim 2 index': dim_2_index,
                           'sliced dim index': sliced_dim_index}
            collapsed_indices = []
            for dim in xrange(cube.ndim - 3):
                box_name = "select_slice_index_" + str(dim+1)
                box = self.findChild(QtGui.QComboBox, box_name)
                collapsed_indices.append(box.currentIndex())
            can_draw_map = self.can_draw_map
            dim_1_name = self.select_dimension_1.currentText()
            dim_2_name = self.select_dimension_2.currentText()
            scheme = self.colorbar_dialog.get_colorbar_scheme()
            if scheme == "auto":
                self.colorbar_max = None
                self.colorbar_min = None
            elif scheme == "fixed":
                if not self.fixed_colorbar:
                    self.colorbar_max, self.colorbar_min = \
                        cl.set_fixed_colorbar(cube, dim_indices,
                                              collapsed_indices)
                    self.fixed_colorbar = True
            else:
                self.colorbar_max = self.colorbar_dialog.max_contour.value()
                self.colorbar_min = self.colorbar_dialog.min_contour.value()
            colorbar_range = {'max': self.colorbar_max,
                              'min': self.colorbar_min}
            slice_index = self.select_slice_scroll.value()
        else:
            filename = cube_index = set_global = cube = None
            dim_indices = collapsed_indices = can_draw_map = None
            dim_1_name = dim_2_name = colorbar_range = None
            slice_index = None
            central_longitude = None

        plot_method = self.select_plot_method.currentText()
        plot_type = self.select_plot_type.currentText()
        projection = self.select_projection.currentText()
        cmap = self.select_colormap.currentText()
        num_contours = self.contour_slider.value()
        coastlines = self.action_coastlines.isChecked()
        gridlines = self.action_gridlines.isChecked()
        contour_labels = self.action_contour_labels.isChecked()
        countries = self.action_country_boundaries.isChecked()
        rivers = self.action_rivers_and_lakes.isChecked()
        cartographic = {'coastlines': coastlines,
                        'countries': countries,
                        'rivers': rivers}

        interface_status = {'cube loaded': cube_loaded,
                            'cube': cube,
                            'plot method': plot_method,
                            'plot type': plot_type,
                            'projection': projection,
                            'central longitude': central_longitude,
                            'cmap': cmap,
                            'num contours': num_contours,
                            'cartographic': cartographic,
                            'gridlines': gridlines,
                            'contour labels': contour_labels,
                            'colorbar range': colorbar_range,
                            'dim indices': dim_indices,
                            'slice index': slice_index,
                            'collapsed indices': collapsed_indices,
                            'can draw map': can_draw_map,
                            'set global': set_global,
                            'filename': filename,
                            'cube index': cube_index,
                            'dim 1 name': dim_1_name,
                            'dim 2 name': dim_2_name}

        return interface_status
Example #5
0
    def get_status(self):
        """
        This method gathers information from around the interface, and then
        packages it up into a dictionary which can be neatly passed around.

        """
        cube_loaded = self.cube_loaded
        if cube_loaded:
            filename = self.filename
            cube_index = self.select_cube.currentIndex()
            set_global = self.set_global
            cube = self.get_current_cube()
            dim_1_index = self.select_dimension_1.currentIndex()
            dim_2_index = self.select_dimension_2.currentIndex()
            sliced_dim_index = self.select_sliced_dim.currentIndex()
            central_longitude = self.select_central_longitude.value()
            dim_indices = {'dim 1 index': dim_1_index,
                           'dim 2 index': dim_2_index,
                           'sliced dim index': sliced_dim_index}
            collapsed_indices = []
            for dim in xrange(cube.ndim - 3):
                box_name = "select_slice_index_" + str(dim+1)
                box = self.findChild(QtGui.QComboBox, box_name)
                collapsed_indices.append(box.currentIndex())
            can_draw_map = self.can_draw_map
            dim_1_name = self.select_dimension_1.currentText()
            dim_2_name = self.select_dimension_2.currentText()
            scheme = self.colorbar_dialog.get_colorbar_scheme()
            if scheme == "auto":
                self.colorbar_max = None
                self.colorbar_min = None
            elif scheme == "fixed":
                if not self.fixed_colorbar:
                    self.colorbar_max, self.colorbar_min = \
                        cl.set_fixed_colorbar(cube, dim_indices,
                                              collapsed_indices)
                    self.fixed_colorbar = True
            else:
                self.colorbar_max = self.colorbar_dialog.max_contour.value()
                self.colorbar_min = self.colorbar_dialog.min_contour.value()
            colorbar_range = {'max': self.colorbar_max,
                              'min': self.colorbar_min}
            slice_index = self.select_slice_scroll.value()
        else:
            filename = cube_index = set_global = cube = None
            dim_indices = collapsed_indices = can_draw_map = None
            dim_1_name = dim_2_name = colorbar_range = None
            slice_index = None
            central_longitude = None

        plot_method = self.select_plot_method.currentText()
        plot_type = self.select_plot_type.currentText()
        projection = self.select_projection.currentText()
        cmap = self.select_colormap.currentText()
        num_contours = self.contour_slider.value()
        coastlines = self.action_coastlines.isChecked()
        gridlines = self.action_gridlines.isChecked()
        contour_labels = self.action_contour_labels.isChecked()
        countries = self.action_country_boundaries.isChecked()
        rivers = self.action_rivers_and_lakes.isChecked()
        cartographic = {'coastlines': coastlines,
                        'countries': countries,
                        'rivers': rivers}

        interface_status = {'cube loaded': cube_loaded,
                            'cube': cube,
                            'plot method': plot_method,
                            'plot type': plot_type,
                            'projection': projection,
                            'central longitude': central_longitude,
                            'cmap': cmap,
                            'num contours': num_contours,
                            'cartographic': cartographic,
                            'gridlines': gridlines,
                            'contour labels': contour_labels,
                            'colorbar range': colorbar_range,
                            'dim indices': dim_indices,
                            'slice index': slice_index,
                            'collapsed indices': collapsed_indices,
                            'can draw map': can_draw_map,
                            'set global': set_global,
                            'filename': filename,
                            'cube index': cube_index,
                            'dim 1 name': dim_1_name,
                            'dim 2 name': dim_2_name}

        return interface_status