Beispiel #1
0
    def OnStats(self, event):
        """Displays regression information in messagebox
        """
        message = []
        title = _('Statistics for Profile(s)')

        for r in six.iterkeys(self.raster):
            try:
                rast = r.split('@')[0]
                statstr = 'Profile of %s\n\n' % rast

                iterable = (i[1] for i in self.raster[r]['datalist'])
                a = numpy.fromiter(iterable, numpy.float)

                statstr += 'n: %f\n' % a.size
                statstr += 'minimum: %f\n' % numpy.amin(a)
                statstr += 'maximum: %f\n' % numpy.amax(a)
                statstr += 'range: %f\n' % numpy.ptp(a)
                statstr += 'mean: %f\n' % numpy.mean(a)
                statstr += 'standard deviation: %f\n' % numpy.std(a)
                statstr += 'variance: %f\n' % numpy.var(a)
                cv = numpy.std(a) / numpy.mean(a)
                statstr += 'coefficient of variation: %f\n' % cv
                statstr += 'sum: %f\n' % numpy.sum(a)
                statstr += 'median: %f\n' % numpy.median(a)
                statstr += 'distance along transect: %f\n\n' % self.transect_length
                message.append(statstr)
            except:
                pass

        stats = PlotStatsFrame(self, id=wx.ID_ANY, message=message,
                               title=title)

        if stats.Show() == wx.ID_CLOSE:
            stats.Destroy()
Beispiel #2
0
    def OnRegression(self, event):
        """Displays regression information in messagebox
        """
        message = []
        title = _('Regression Statistics for Scatterplot(s)')

        for rpair in self.rasterList:
            if not isinstance(rpair, tuple):
                continue
            rast1, rast2 = rpair
            rast1 = rast1.split('@')[0]
            rast2 = rast2.split('@')[0]
            ret = grass.parse_command(
                'r.regression.line', mapx=rast1, mapy=rast2, flags='g',
                quiet=True, parse=(grass.parse_key_val, {'sep': '='}))
            eqtitle = _('Regression equation for raster map <%(rast1)s> vs. <%(rast2)s>:\n\n') % {
                'rast1': rast1, 'rast2': rast2}
            eq = '   %s = %s + %s(%s)\n\n' % (rast2, ret['a'], ret['b'], rast1)
            num = 'N = %s\n' % ret['N']
            rval = 'R = %s\n' % ret['R']
            rsq = 'R-squared = %f\n' % pow(float(ret['R']), 2)
            ftest = 'F = %s\n' % ret['F']
            str = eqtitle + eq + num + rval + rsq + ftest
            message.append(str)

        stats = PlotStatsFrame(self, id=wx.ID_ANY, message=message,
                               title=title)

        if stats.Show() == wx.ID_CLOSE:
            stats.Destroy()
Beispiel #3
0
    def OnRegression(self, event):
        """Displays regression information in messagebox"""
        message = []
        title = _("Regression Statistics for Scatterplot(s)")

        for rpair in self.rasterList:
            if not isinstance(rpair, tuple):
                continue
            rast1, rast2 = rpair
            rast1 = rast1.split("@")[0]
            rast2 = rast2.split("@")[0]
            ret = grass.parse_command(
                "r.regression.line",
                mapx=rast1,
                mapy=rast2,
                flags="g",
                quiet=True,
                parse=(grass.parse_key_val, {
                    "sep": "="
                }),
            )
            eqtitle = _(
                "Regression equation for raster map <%(rast1)s> vs. <%(rast2)s>:\n\n"
            ) % {
                "rast1": rast1,
                "rast2": rast2
            }
            eq = "   %s = %s + %s(%s)\n\n" % (rast2, ret["a"], ret["b"], rast1)
            num = "N = %s\n" % ret["N"]
            rval = "R = %s\n" % ret["R"]
            rsq = "R-squared = %f\n" % pow(float(ret["R"]), 2)
            ftest = "F = %s\n" % ret["F"]
            str = eqtitle + eq + num + rval + rsq + ftest
            message.append(str)

        stats = PlotStatsFrame(self,
                               id=wx.ID_ANY,
                               message=message,
                               title=title)

        if stats.Show() == wx.ID_CLOSE:
            stats.Destroy()
Beispiel #4
0
    def OnStats(self, event):
        """Displays regression information in messagebox"""
        message = []
        title = _("Statistics for Map(s) Histogrammed")

        for rast in self.rasterList:
            ret = grass.read_command("r.univar",
                                     map=rast,
                                     flags="e",
                                     quiet=True)
            stats = _(
                "Statistics for raster map <%s>") % rast + ":\n%s\n" % ret
            message.append(stats)

        stats = PlotStatsFrame(self,
                               id=wx.ID_ANY,
                               message=message,
                               title=title)

        if stats.Show() == wx.ID_CLOSE:
            stats.Destroy()