power_plotter.py 1 KB
Newer Older
1 2
# -*- coding: utf-8 -*-

Theo Steininger's avatar
Theo Steininger committed
3 4
import numpy as np

Martin Reinecke's avatar
Martin Reinecke committed
5
from ...spaces import PowerSpace
6

Martin Reinecke's avatar
Martin Reinecke committed
7 8 9
from ..descriptors import Axis
from ..figures import Figure2D
from ..plots import Cartesian2D
Theo Steininger's avatar
Theo Steininger committed
10
from .plotter_base import PlotterBase
11 12


Theo Steininger's avatar
Theo Steininger committed
13
class PowerPlotter(PlotterBase):
14 15 16
    def __init__(self, interactive=False, path='plot.html', line=None,
                 marker=None):
        super(PowerPlotter, self).__init__(interactive, path)
17 18 19 20 21 22 23
        self.line = line
        self.marker = marker

    @property
    def domain_classes(self):
        return (PowerSpace, )

Theo Steininger's avatar
Theo Steininger committed
24 25 26 27
    def _initialize_plot(self):
        return Cartesian2D(data=None)

    def _initialize_figure(self):
28 29
        xaxis = Axis(log=True)
        yaxis = Axis(log=True)
Theo Steininger's avatar
Theo Steininger committed
30
        return Figure2D(plots=None, xaxis=xaxis, yaxis=yaxis)
31

Theo Steininger's avatar
Theo Steininger committed
32 33 34 35 36 37 38
    def _parse_data(self, data, field, spaces):
        y_data = data
        power_space = field.domain[spaces[0]]
        xy_data = np.empty((2, y_data.shape[0]))
        xy_data[1] = y_data
        xy_data[0] = power_space.kindex
        return xy_data