def compute(self):
        inputs = {}
        inputs["model_workspace"] = self.force_get_input(
            'model_workspace').name
        inputs["model_dir"] = os.path.split(inputs["model_workspace"])[0]

        inputs["prob_map"] = os.path.join(
            inputs["model_dir"],
            self.find_file(inputs["model_dir"], "_prob_map.tif"))
        inputs["bin_map"] = os.path.join(
            inputs["model_dir"],
            self.find_file(inputs["model_dir"], "_bin_map.tif"))
        inputs["res_map"] = os.path.join(
            inputs["model_dir"],
            self.find_file(inputs["model_dir"], "_resid_map.tif"))
        try:
            inputs["mes_map"] = os.path.join(
                inputs["model_dir"],
                self.find_file(inputs["model_dir"], "_mess_map.tif"))
        except:
            inputs["mes_map"] = ""

        try:
            inputs["mod_map"] = os.path.join(
                inputs["model_dir"],
                self.find_file(inputs["model_dir"], "_MoD_map.tif"))
        except:
            inputs["mod_map"] = ""

        mds = self.find_mds(inputs["model_dir"])
        shaperoot = self.gen_points_shp(mds)
        inputs["pres_points"] = shaperoot + "_pres.shp"
        inputs["abs_points"] = shaperoot + "_abs.shp"
        inputs["backs_points"] = shaperoot + "_backs.shp"

        inputs["model_tag"] = os.path.split(inputs["model_dir"])[1]

        if self.has_input("row"):
            if not self.location:
                self.location = CellLocation()
            self.location.row = self.get_input('row') - 1

        if self.has_input("column"):
            if not self.location:
                self.location = CellLocation()
            self.location.col = self.get_input('column') - 1

        self.displayAndWait(SAHMSpatialOutputViewerCellWidget, inputs)
Ejemplo n.º 2
0
    def compute(self):
        """ compute() -> None
        Dispatch the display event to the spreadsheet with images and labels
        
        """
        if self.hasInputFromPort("ModelWorkspace"):
            window = spreadsheetController.findSpreadsheetWindow()
            model_workspace = self.getInputFromPort("ModelWorkspace").name
            model_dir_full = os.path.normcase(
                os.path.split(model_workspace)[0])
            model_dir = os.path.split(model_dir_full)[1]
            model_name = model_dir[:model_dir.index('output')]

            #            prob_map_path = os.path.join(model_dir_full, model_name + '_prob_map.jpeg')
            #            prob_map = window.file_pool.make_local_copy(prob_map_path)

            auc_graph_path = os.path.join(model_dir_full,
                                          model_name + '_auc_plot.jpg')
            auc_graph = window.file_pool.make_local_copy(auc_graph_path)

            text_output_path = os.path.join(model_dir_full,
                                            model_name + '_output.txt')
            text_output = window.file_pool.make_local_copy(text_output_path)

            response_path = os.path.join(model_dir_full,
                                         model_name + '_response_curves.pdf')
            response_curves = window.file_pool.make_local_copy(response_path)

            model_label = model_dir.capitalize().replace('output', 'Output')

            if self.hasInputFromPort("row"):
                if not self.location:
                    self.location = CellLocation()
                self.location.row = self.getInputFromPort('row') - 1

            if self.hasInputFromPort("column"):
                if not self.location:
                    self.location = CellLocation()
                self.location.col = self.getInputFromPort('column') - 1

        else:
            fileValue = None
        self.cellWidget = self.displayAndWait(
            SAHMOutputViewerCellWidget,
            (auc_graph, text_output, response_curves, model_label))
Ejemplo n.º 3
0
    def compute(self):
        inputs = {}

        inputs = map_ports(self, self.port_map)

        if self.hasInputFromPort("row"):
            if not self.location:
                self.location = CellLocation()
            self.location.row = self.getInputFromPort('row') - 1

        if self.hasInputFromPort("column"):
            if not self.location:
                self.location = CellLocation()
            self.location.col = self.getInputFromPort('column') - 1

        if self.inputPorts.has_key('Location'):
            self.location =  self.inputPorts['Location'][0].obj

        self.local_displayAndWait(inputs)       
Ejemplo n.º 4
0
    def compute(self):
        """ compute() -> None
        Dispatch the vtkRenderer to the actual rendering widget
        """
        # Check required input ports

        if not self.hasInputFromPort('slab1'):
            raise ModuleError(self, "'slab1' is mandatory.")
        if not self.hasInputFromPort('template'):
            raise ModuleError(self, "'template' is mandatory.")
        if not self.hasInputFromPort('plotType'):
            raise ModuleError(self, "'plotType' is mandatory.")

        # Build up the argument list
        args = []
        slab1 = self.getInputFromPort('slab1')
        args.append(self.getInputFromPort('slab1'))
        if self.hasInputFromPort('slab2'):
            args.append(self.getInputFromPort('slab2'))

        args.append(self.getInputFromPort('template'))
        args.append(self.getInputFromPort('plotType'))
        if self.hasInputFromPort('gmName'):
            args.append(self.getInputFromPort('gmName'))

        # Build up plot keyword args ...
        kwargs = {}
        if self.hasInputFromPort('continents'):
            kwargs['continents'] = self.getInputFromPort('continents')

        # Set the cell row / col
        self.location = CellLocation()
        if self.hasInputFromPort('row'):
            self.location.row = self.getInputFromPort('row')
        if self.hasInputFromPort('col'):
            self.location.col = self.getInputFromPort('col')

        canvas = None
        if self.hasInputFromPort('canvas'):
            canvas = self.getInputFromPort('canvas')
        gm = None
        if self.hasInputFromPort('gm'):
            gm = self.getInputFromPort('gm')
        # Plot into the cell
        inputPorts = (canvas, gm, args, kwargs)
        self.cellWidget = self.displayAndWait(QCDATWidget, inputPorts)
        if self.cellWidget is not None:
            self.setResult('canvas', self.cellWidget.canvas)
Ejemplo n.º 5
0
    def compute(self):
        """ compute() -> None
        Dispatch the vtkRenderer to the actual rendering widget
        """
        # Check required input ports
        if self.has_input('canvas'):
            canvas = self.get_input('canvas')
        else:
            self.cellWidget = self.displayAndWait(QCDATWidget, (None, ))
            self.set_output('canvas', self.cellWidget.canvas)
            return
        self.set_output('canvas', canvas)
        if not self.has_input('gmName'):
            return
        if not self.has_input('plotType'):
            return
        if not self.has_input('slab1'):
            return
        if not self.has_input('template'):
            return

        # Build up the argument list
        args = []
        slab1 = self.get_input('slab1')
        args.append(self.get_input('slab1'))
        if self.has_input('slab2'):
            args.append(self.get_input('slab2'))
        args.append(self.get_input('template'))
        args.append(self.get_input('plotType'))
        args.append(self.get_input('gmName'))

        # Build up plot keyword args ...
        kwargs = {}
        if self.has_input('continents'):
            kwargs['continents'] = self.get_input('continents')

        # Set the cell row / col
        self.location = CellLocation()
        if self.has_input('row'):
            self.location.row = self.get_input('row')
        if self.has_input('col'):
            self.location.col = self.get_input('col')

        # Plot into the cell
        inputPorts = (canvas, args, kwargs)
        self.displayAndWait(QCDATWidget, inputPorts)
Ejemplo n.º 6
0
    def compute(self):
        """ compute() -> None
        Dispatch the display event to the spreadsheet with images and labels
        
        """
        if self.hasInputFromPort("ModelWorkspace") and \
            utils.checkIfModelFinished(self.getInputFromPort("ModelWorkspace").name):
            window = spreadsheetController.findSpreadsheetWindow()
            model_workspace = self.getInputFromPort("ModelWorkspace").name

            model_dir_full = os.path.normcase(model_workspace)
            model_dir = os.path.split(model_dir_full)[1]
            model_name = model_dir[:model_dir.index('_')]
            auc_graph_path = self.findFile(model_dir_full, '_modelEvalPlot.jpg')#os.path.join(model_dir_full, model_name + '_modelEvalPlot.jpg')
            if os.path.exists(auc_graph_path):
                auc_graph = window.file_pool.make_local_copy(auc_graph_path)
            
            text_output_path = self.findFile(model_dir_full, '_output.txt')#os.path.join(model_dir_full, model_name + '_output.txt')
            if os.path.exists(text_output_path):
                text_output = window.file_pool.make_local_copy(text_output_path)
            
            response_directory = os.path.join(model_dir_full,'responseCurves')
            if os.path.exists(response_directory):
                responseCurveFiles = os.listdir(response_directory)
                response_curves = []
                for response_curve in responseCurveFiles:
                    if response_curve != "Thumbs.db":  #Windows grief
                        response_curves.append(os.path.join(response_directory, response_curve))
            else:
                response_curves = []
            
            calibration_graph_path = self.findFile(model_dir_full, '_CalibrationPlot.jpg')#os.path.join(model_dir_full, model_name + '_CalibrationPlot.jpg')
            if os.path.exists(calibration_graph_path):
                calibration_graph = window.file_pool.make_local_copy(calibration_graph_path)
            
            confusion_graph_path = self.findFile(model_dir_full, '.confusion.matrix.jpg')#os.path.join(model_dir_full, model_name + '.confusion.matrix.jpg')
            if os.path.exists(confusion_graph_path):
                confusion_graph = window.file_pool.make_local_copy(confusion_graph_path)
            
            residuals_graph_path = self.findFile(model_dir_full, '.resid.plot.jpg')#os.path.join(model_dir_full, model_name + '.resid.plot.jpg')
            if os.path.exists(residuals_graph_path):
                residuals_graph = window.file_pool.make_local_copy(residuals_graph_path)
            
            variable_imp_path = self.findFile(model_dir_full, '_variable.importance.jpg')#os.path.join(model_dir_full, model_name + '_variable.importance.jpg')
            if os.path.exists(variable_imp_path):
                variable_graph = window.file_pool.make_local_copy(variable_imp_path)
                
            model_label = model_dir.capitalize().replace('output', 'Output')
            
            
            if self.hasInputFromPort("row"):
                if not self.location:
                    self.location = CellLocation()
                self.location.row = self.getInputFromPort('row') - 1
            
            if self.hasInputFromPort("column"):
                if not self.location:
                    self.location = CellLocation()
                self.location.col = self.getInputFromPort('column') - 1
                
            if self.hasInputFromPort('InitialModelOutputDisplay'):
                initial_display = self.getInputFromPort('InitialModelOutputDisplay')
            else:
                initial_display = 'AUC'

            self.cellWidget = self.displayAndWait(SAHMOutputViewerCellWidget, (auc_graph, 
                                                                          text_output,
                                                                          response_curves,
                                                                          calibration_graph,
                                                                          confusion_graph,
                                                                          residuals_graph,
                                                                          variable_graph,
                                                                          model_label,
                                                                          initial_display))
        else:
            fileValue = None