Exemple #1
0
    def draw_visits(self, track_graphics: TrackGraphics, brightness: int, color_palette: ColorPalette):
        assert brightness in [-1, 0, 1, 2]

        visits, min_visits, max_visits = self.get_visits_and_scope_range(brightness)

        if not visits:
            return

        colour_multiplier = 255 / max_visits / max_visits * 2

        if brightness == 1:
            colour_multiplier *= 2
        elif brightness == 2:
            colour_multiplier *= 3.5
        elif brightness == -1:
            colour_multiplier /= 2

        for yy, visits in enumerate(visits):
            for xx, visit in enumerate(visits):
                if visit >= min_visits:
                    x = self.min_x + self._granularity * xx
                    y = self.min_y + self._granularity * yy

                    data = min(1.0, 30/255 + colour_multiplier / 255 * visit * visit)
                    colour = get_color_for_data(data, color_palette)
                    track_graphics.plot_box(x, y, x + self._granularity, y + self._granularity, colour)
Exemple #2
0
def multi_draw(track_graphics: TrackGraphics, visitors, colours, threshold):
    assert len(colours) == len(visitors)
    assert threshold >= 1

    min_x = visitors[0].min_x
    min_y = visitors[0].min_y
    granularity = visitors[0].granularity

    for yy in range(0, len(visitors[0].visits)):
        for xx in range(0, len(visitors[0].visits[0])):
            visits = []
            for v in range(0, len(visitors)):
                visits.append(visitors[v].visits[yy][xx])

            if sum(visits) >= threshold:
                target = max(visits)
                colour = ""
                for i, v in enumerate(visits):
                    if v >= target:
                        colour = colours[i]

                x = min_x + granularity * xx
                y = min_y + granularity * yy

                track_graphics.plot_box(x, y, x + granularity, y + granularity,
                                        colour)
Exemple #3
0
    def draw_brightness_statistic(self, track_graphics: TrackGraphics, adjust_brightness: int,
                                  color_palette: ColorPalette, visits_heatmap):
        assert adjust_brightness in [-1, 0, 1, 2]

        if adjust_brightness == 1:
            multiplier = 1.1
        elif adjust_brightness == 2:
            multiplier = 1.2
        elif adjust_brightness == -1:
            multiplier = 0.9
        else:
            multiplier = 1.0

        (stats, _, _) = self._get_stats_array(np.median, adjust_brightness, visits_heatmap)

        for yy, stats in enumerate(stats):
            for xx, stat in enumerate(stats):
                if not math.isnan(stat):
                    x = self.min_x + self._granularity * xx
                    y = self.min_y + self._granularity * yy
                    colour = get_color_for_data(max(0.1, min(1, stat * multiplier)), color_palette)
                    track_graphics.plot_box(x, y, x + self._granularity, y + self._granularity, colour)
Exemple #4
0
    def draw_statistic(self, track_graphics: TrackGraphics, brightness: int, color_palette: ColorPalette, visits_heatmap,
                       forced_max_stat=-1, forced_min_stat=-1):
        assert brightness in [-1, 0, 1, 2]

        (stats, min_stat, max_stat) = self._get_stats_array(np.median, brightness, visits_heatmap)
        if max_stat == 0:
            return

        if forced_max_stat > 0:
            max_stat = forced_max_stat
        if forced_min_stat > 0:
            min_stat = forced_min_stat

        if brightness == 1:
            max_stat *= 0.93
        elif brightness == 2:
            max_stat *= 0.85
            min_stat *= 0.95
        elif brightness == -1:
            min_stat *= 1.1

        if min_stat >= max_stat:
            min_stat = 0.99 * max_stat

        stat_range = max_stat - min_stat

        for yy, stats in enumerate(stats):
            for xx, stat in enumerate(stats):
                if not math.isnan(stat):
                    x = self.min_x + self._granularity * xx
                    y = self.min_y + self._granularity * yy

                    gap_from_best = max_stat - stat
                    data = max(0.1, min(1, 1 - 0.9 * gap_from_best / stat_range))
                    colour = get_color_for_data(data, color_palette)
                    track_graphics.plot_box(x, y, x + self._granularity, y + self._granularity, colour)
Exemple #5
0
    def draw(self, track_graphics: TrackGraphics, brightness: int,
             color_palette: ColorPalette):
        # self.print_debug()

        assert brightness in [-1, 0, 1, 2]

        max_visits = max(max(x) for x in self.visits)

        if max_visits == 0:
            return

        colour_multiplier = 255 / max_visits / max_visits * 2
        min_visits = max_visits / 10

        if brightness == 1:
            colour_multiplier *= 2
            min_visits /= 2
        elif brightness == 2:
            colour_multiplier *= 3.5
            min_visits /= 3.5
        elif brightness == -1:
            colour_multiplier /= 2
            min_visits *= 1.5

        for yy, visits in enumerate(self.visits):
            for xx, visit in enumerate(visits):
                if visit >= min_visits:
                    x = self.min_x + self.granularity * xx
                    y = self.min_y + self.granularity * yy

                    data = min(
                        1.0,
                        30 / 255 + colour_multiplier / 255 * visit * visit)
                    colour = get_color_for_data(data, color_palette)
                    track_graphics.plot_box(x, y, x + self.granularity,
                                            y + self.granularity, colour)