# Path: artist/plot.py
# class PolarPlot(Plot):
# 
#     """Create a plot containing a single polar subplot.
# 
#     Same as the Plot but uses polar axes. The x values are the phi
#     coordinates in degrees (or radians). The y values are the r
#     coordinates in arbitrary units.
# 
#     :param use_radians: If this keyword is set to True the units for x (phi)
#         values and x (phi) axis labels are radians.
# 
#     """
# 
#     def __init__(self, *args, **kwargs):
#         self.use_radians = kwargs.pop('use_radians', False)
#         super(PolarPlot, self).__init__(*args, **kwargs)
#         environment = jinja2.Environment(loader=jinja2.PackageLoader(
#             'artist', 'templates'), finalize=self._convert_none)
#         self.template = environment.get_template('polar_plot.tex')
# 
#         if not self.use_radians:
#             self.set_xtick_suffix('degree')
#         else:
#             self.set_xticks([0, 30, 60, 90, 120, 150, 180, 210, 240, 270, 300,
#                              330])
#             self.set_xtick_labels([r'$0$', r'$\frac{1}{6}\pi$',
#                                    r'$\frac{2}{6}\pi$', r'$\frac{1}{2}\pi$',
#                                    r'$\frac{4}{6}\pi$', r'$\frac{5}{6}\pi$',
#                                    r'$\pm\pi$', r'$-\frac{5}{6}\pi$',
#                                    r'$-\frac{4}{6}\pi$', r'$-\frac{1}{2}\pi$',
#                                    r'$-\frac{2}{6}\pi$', r'$-\frac{1}{6}\pi$'])
# 
#     def plot(self, phi, r, **kwargs):
#         """Add a data series to the plot.
# 
#         :param phi: array containing phi-values, should be in degrees
#                     (or radians).
#         :param r: array containing r-values.
# 
#         For further options see the plot function of the super class.
# 
#         """
#         if self.use_radians:
#             phi = np.degrees(phi)
#         super(PolarPlot, self).plot(phi, r, **kwargs)
# 
#     def histogram(self, counts, bin_edges, linestyle='solid'):
#         """Plot a polar histogram.
# 
#         The user needs to supply the histogram.  This method only plots
#         the results.  You can use NumPy's histogram function.
# 
#         :param counts: array containing the count values.
#         :param bin_edges: array containing the bin edges in degrees
#                           (or radians).
#         :param linestyle: the line style used to connect the data points.
#             May be None, or any line style accepted by TikZ (e.g. solid,
#             dashed, dotted, thick, or even combinations like
#             "red,thick,dashed").
# 
#         Example::
# 
#             >>> plot = artist.PolarPlot()
#             >>> x = np.random.uniform(0, 360, size=1000)
#             >>> n, bins = np.histogram(x, bins=np.linspace(0, 360, 37))
#             >>> plot.histogram(n, bins)
# 
#         """
#         if len(bin_edges) - 1 != len(counts):
#             raise RuntimeError(
#                 'The length of bin_edges should be length of counts + 1')
# 
#         x = []
#         y = []
# 
#         if self.use_radians:
#             circle = 2 * np.pi
#         else:
#             circle = 360.
# 
#         step = circle / 1800.
# 
#         for i in range(len(bin_edges) - 1):
#             for bin_edge in np.arange(bin_edges[i], bin_edges[i + 1],
#                                       step=step):
#                 x.append(bin_edge)
#                 y.append(counts[i])
#             x.append(bin_edges[i + 1])
#             y.append(counts[i])
# 
#         # If last edge is same as first bin edge, connect the ends.
#         if bin_edges[-1] % circle == bin_edges[0] % circle:
#             x.append(bin_edges[0])
#             y.append(counts[0])
# 
#         self.plot(x, y, mark=None, linestyle=linestyle)
# 
#     def histogram2d(self, *args):
#         """Do not allow 2D histograms, it produces undesireable results."""
# 
#         warnings.warn('Plotting 2D histograms is not supported for PolarPlot')
# 
#     def set_xlimits(self, min=None, max=None):
#         """Do not allow setting x limits, it messes with the axes."""
# 
#         warnings.warn('Setting x limits is not supported for PolarPlot')


import numpy as np
from artist import PolarPlot



def main():

    directions = np.genfromtxt('data/discrete-directions.txt',
                               names=['azimuth', 'zenith'])


# Path: artist/plot.py
# class PolarPlot(Plot):
# 
#     """Create a plot containing a single polar subplot.
# 
#     Same as the Plot but uses polar axes. The x values are the phi
#     coordinates in degrees (or radians). The y values are the r
#     coordinates in arbitrary units.
# 
#     :param use_radians: If this keyword is set to True the units for x (phi)
#         values and x (phi) axis labels are radians.
# 
#     """
# 
#     def __init__(self, *args, **kwargs):
#         self.use_radians = kwargs.pop('use_radians', False)
#         super(PolarPlot, self).__init__(*args, **kwargs)
#         environment = jinja2.Environment(loader=jinja2.PackageLoader(
#             'artist', 'templates'), finalize=self._convert_none)
#         self.template = environment.get_template('polar_plot.tex')
# 
#         if not self.use_radians:
#             self.set_xtick_suffix('degree')
#         else:
#             self.set_xticks([0, 30, 60, 90, 120, 150, 180, 210, 240, 270, 300,
#                              330])
#             self.set_xtick_labels([r'$0$', r'$\frac{1}{6}\pi$',
#                                    r'$\frac{2}{6}\pi$', r'$\frac{1}{2}\pi$',
#                                    r'$\frac{4}{6}\pi$', r'$\frac{5}{6}\pi$',
#                                    r'$\pm\pi$', r'$-\frac{5}{6}\pi$',
#                                    r'$-\frac{4}{6}\pi$', r'$-\frac{1}{2}\pi$',
#                                    r'$-\frac{2}{6}\pi$', r'$-\frac{1}{6}\pi$'])
# 
#     def plot(self, phi, r, **kwargs):
#         """Add a data series to the plot.
# 
#         :param phi: array containing phi-values, should be in degrees
#                     (or radians).
#         :param r: array containing r-values.
# 
#         For further options see the plot function of the super class.
# 
#         """
#         if self.use_radians:
#             phi = np.degrees(phi)
#         super(PolarPlot, self).plot(phi, r, **kwargs)
# 
#     def histogram(self, counts, bin_edges, linestyle='solid'):
#         """Plot a polar histogram.
# 
#         The user needs to supply the histogram.  This method only plots
#         the results.  You can use NumPy's histogram function.
# 
#         :param counts: array containing the count values.
#         :param bin_edges: array containing the bin edges in degrees
#                           (or radians).
#         :param linestyle: the line style used to connect the data points.
#             May be None, or any line style accepted by TikZ (e.g. solid,
#             dashed, dotted, thick, or even combinations like
#             "red,thick,dashed").
# 
#         Example::
# 
#             >>> plot = artist.PolarPlot()
#             >>> x = np.random.uniform(0, 360, size=1000)
#             >>> n, bins = np.histogram(x, bins=np.linspace(0, 360, 37))
#             >>> plot.histogram(n, bins)
# 
#         """
#         if len(bin_edges) - 1 != len(counts):
#             raise RuntimeError(
#                 'The length of bin_edges should be length of counts + 1')
# 
#         x = []
#         y = []
# 
#         if self.use_radians:
#             circle = 2 * np.pi
#         else:
#             circle = 360.
# 
#         step = circle / 1800.
# 
#         for i in range(len(bin_edges) - 1):
#             for bin_edge in np.arange(bin_edges[i], bin_edges[i + 1],
#                                       step=step):
#                 x.append(bin_edge)
#                 y.append(counts[i])
#             x.append(bin_edges[i + 1])
#             y.append(counts[i])
# 
#         # If last edge is same as first bin edge, connect the ends.
#         if bin_edges[-1] % circle == bin_edges[0] % circle:
#             x.append(bin_edges[0])
#             y.append(counts[0])
# 
#         self.plot(x, y, mark=None, linestyle=linestyle)
# 
#     def histogram2d(self, *args):
#         """Do not allow 2D histograms, it produces undesireable results."""
# 
#         warnings.warn('Plotting 2D histograms is not supported for PolarPlot')
# 
#     def set_xlimits(self, min=None, max=None):
#         """Do not allow setting x limits, it messes with the axes."""
# 
#         warnings.warn('Setting x limits is not supported for PolarPlot')


# Path: demo/demo_discrete_directions.py
import numpy as np
from artist import PolarPlot




def main():

    directions = np.genfromtxt('data/discrete-directions.txt',
                               names=['azimuth', 'zenith'])


    plot = PolarPlot(use_radians=True)