<commit_before>from __future__ import division, print_function
import matplotlib.pyplot as plt
import matplotlib.ticker as tk
import matplotlib.colors as clr
import numpy as np


def traj_scatter(data, lons, lats, hymap, zorder=19, colormap=plt.cm.Blues,
                 edgecolor='none', size=25, sizedata=None, cnormalize=None,
                 snormalize=None, vmin=None, vmax=None, levels=11,
                 suppres_printmsg=False, **kwargs):
    """
    Scatter-plot of ``Trajectory``, ``TrajectoryGroup``, or ``Cluster`` data.

    Parameters
    ----------
    data : 1D ndarray of floats, ints
        The information to plot as color change.
    lons : 1D ndarray of floats, ints
        X-coordinates of ``data`` in decimal degrees
    lats : 1D ndarray of floats, ints
        Y-coordinates of ``data`` in decimal degrees
    hymap : ``Basemap`` instance
        Any ``Basemap`` instance.  For easy map creation, see ``MapDesign``
        class
    zorder : int
        Default 19.  Data zorder.
    colormap : colormap
        Default ``plt.cm.Blues``.  Any ``matplotlib`` colormap.
    edgecolor : string, tuple
        Default 'none'.  Any ``matplotlib``-accepted color
    size : int
        Default 25.  Point size of data unless ``sizedata`` specified.  Then,
        will be multiplied with ``sizedata``.
    sizedata : 1D ndarray of floats
        Default ``None``.  The data to plot as a change in marker size.
    cnormalize : string or float
        Default ``None``.  [None|'boundary'|'log'|'ln'|'sqrt'|float]
        Normalization of color scale.  If 'boundary', will create a discrete
        color map with ``levels`` number of colors.  For other norms, colorbar
        ticklabels will be updated with 'log' but not 'ln', 'sqrt', because
        no corresponding ``matplotlib colors Normalize`` classes are available.
        If a float is provided, a ``PowerNorm`` will be performed.
    snormalize : string
        Default ``None``.  [None|'log'|'ln'|'sqrt'].  Similar to cnormalize,
        except 'boundary' not available and does not use ``Normalize``.
    vmin : int or float
        Default ``None``.  Used to scale/normalize ``data``.
        If ``None``, then set to ``data`` min
    vmax : int or float
        Default ``None``.  Used to scale/normalize ``data``.
        If ``None``, then set to ``data`` max
    levels : int
        Only used in BoundaryNorm
    **kwargs
        passed to ``Basemap.scatter()`` and ``Axes.scatter()``

    Returns
    -------
    cm : ``matplotlib PathCollection`` instance
        Mappable for use in creating colorbars.  Colorbars may be created
        in ``PySPLIT`` using ``make_cbar()`` or ``make_cax_cbar()``

    """
    # cnormalize = str.lower(cnormalize)
    norm = None
    msg = ('Use `cbar.ax.set_yticklabels()` ' +
           'or cbar.ax.set_xticklabels()` to change tick labels')

    transform_dict = {'sqrt': np.sqrt,
                      'log': np.log10,
                      'ln': np.log}

    if cnormalize is 'boundary':
        if vmin is None:
            vmin = data.min()
        if vmax is None:
            vmax = data.max()
        bounds = np.linspace(vmin, vmax, levels)
        norm = clr.BoundaryNorm(bounds, colormap.N)
    elif cnormalize is 'norm':
        norm = clr.Norm(vmin=vmin, vmax=vmax)
    elif cnormalize is 'log':
        norm = clr.LogNorm(vmin=vmin, vmax=vmax)
    elif cnormalize is 'ln':
        data = np.log(data)
        if not suppres_printmsg:
            print(msg, '\nnatural log normalization')
    elif cnormalize is 'sqrt':
        data = np.sqrt(data)
        if not suppres_printmsg:
            print(msg, '\nsqrt normalization')
    else:
        try:
            norm = clr.PowerNorm(cnormalize, vmin=vmin, vmax=vmax)
        except:
            pass

    if sizedata is not None:
        if snormalize is not None:
            sizedata = transform_dict[snormalize](sizedata)
        size = sizedata * size

    cm = hymap.scatter(lons, lats, c=data, s=size, cmap=colormap,
                       vmin=vmin, vmax=vmax, zorder=zorder,
                       edgecolor=edgecolor, norm=norm, latlon=True, **kwargs)

    return cm


def traj_path(hymap, lons, lats, color, lw, marker=None, linestyle='-',
              markeredgecolor='none', zorder=19, **kwargs):
    """
    Line plot of ``Trajectory`` or ``cluster`` path.

    Parameters
    ----------
    hymap : Basemap instance
        Any ``Basemap`` instance.  For easy map creation, see ``MapDesign``
        class
    lons : 1D ndarray of floats, ints
        X-coordinates of ``data`` in decimal degrees
    lats : 1D ndarray of floats, ints
        Y-coordinates of ``data`` in decimal degrees
    color : string, tuple
        ``Trajectory`` path and/or marker color.  Any ``matplotlib``-accepted
        color
    lw : int
        ``Trajectory`` path linewidth
    marker : string
        Default ``None``.  The timestep marker style.
    linestyle : string
        Default '-'.  The ``Trajectory`` path linestyle.
    markeredgecolor : string, tuple
        Default 'none'.  The time step marker edge color.
    zorder : int
        Default 19.  The zorder of the ``Trajectory`` path.
    **kwargs
        Passed to ``Basemap.plot()`` and ``Axes.plot()``

    """
    hymap.plot(lons, lats, color, linewidth=lw, linestyle=linestyle,
               marker=marker, latlon=True, zorder=zorder,
               markeredgecolor=markeredgecolor, **kwargs)


def meteo_contouring(hymap, data, longitudes, latitudes, contourf=True,<commit_msg>Fix typo in kwarg, bye bye traj_path, change traj_scatter default colormap<commit_after>from __future__ import division, print_function
import matplotlib.pyplot as plt
import matplotlib.ticker as tk
import matplotlib.colors as clr
import numpy as np


def traj_scatter(data, lons, lats, hymap, zorder=19, colormap=plt.cm.viridis,
                 edgecolor='none', size=25, sizedata=None, cnormalize=None,
                 snormalize=None, vmin=None, vmax=None, levels=11,
                 suppress_printmsg=False, **kwargs):
    """
    Scatter-plot of ``Trajectory``, ``TrajectoryGroup``, or ``Cluster`` data.

    Parameters
    ----------
    data : 1D ndarray of floats, ints
        The information to plot as color change.
    lons : 1D ndarray of floats, ints
        X-coordinates of ``data`` in decimal degrees
    lats : 1D ndarray of floats, ints
        Y-coordinates of ``data`` in decimal degrees
    hymap : ``Basemap`` instance
        Any ``Basemap`` instance.  For easy map creation, see ``MapDesign``
        class
    zorder : int
        Default 19.  Data zorder.
    colormap : colormap
        Default ``plt.cm.viridis``.  Any ``matplotlib`` colormap.
    edgecolor : string, tuple
        Default 'none'.  Any ``matplotlib``-accepted color
    size : int
        Default 25.  Point size of data unless ``sizedata`` specified.  Then,
        will be multiplied with ``sizedata``.
    sizedata : 1D ndarray of floats
        Default ``None``.  The data to plot as a change in marker size.
    cnormalize : string or float
        Default ``None``.  [None|'boundary'|'log'|'ln'|'sqrt'|float]
        Normalization of color scale.  If 'boundary', will create a discrete
        color map with ``levels`` number of colors.  For other norms, colorbar
        ticklabels will be updated with 'log' but not 'ln', 'sqrt', because
        no corresponding ``matplotlib colors Normalize`` classes are available.
        If a float is provided, a ``PowerNorm`` will be performed.
    snormalize : string
        Default ``None``.  [None|'log'|'ln'|'sqrt'].  Similar to cnormalize,
        except 'boundary' not available and does not use ``Normalize``.
    vmin : int or float
        Default ``None``.  Used to scale/normalize ``data``.
        If ``None``, then set to ``data`` min
    vmax : int or float
        Default ``None``.  Used to scale/normalize ``data``.
        If ``None``, then set to ``data`` max
    levels : int
        Only used in BoundaryNorm
    **kwargs
        passed to ``Basemap.scatter()`` and ``Axes.scatter()``

    Returns
    -------
    cm : ``matplotlib PathCollection`` instance
        Mappable for use in creating colorbars.  Colorbars may be created
        in ``PySPLIT`` using ``make_cbar()`` or ``make_cax_cbar()``

    """
    # cnormalize = str.lower(cnormalize)
    norm = None
    msg = ('Use `cbar.ax.set_yticklabels()` ' +
           'or cbar.ax.set_xticklabels()` to change tick labels')

    transform_dict = {'sqrt': np.sqrt,
                      'log': np.log10,
                      'ln': np.log}

    if cnormalize is 'boundary':
        if vmin is None:
            vmin = data.min()
        if vmax is None:
            vmax = data.max()
        bounds = np.linspace(vmin, vmax, levels)
        norm = clr.BoundaryNorm(bounds, colormap.N)
    elif cnormalize is 'norm':
        norm = clr.Norm(vmin=vmin, vmax=vmax)
    elif cnormalize is 'log':
        norm = clr.LogNorm(vmin=vmin, vmax=vmax)
    elif cnormalize is 'ln':
        data = np.log(data)
        if not suppress_printmsg:
            print(msg, '\nnatural log normalization')
    elif cnormalize is 'sqrt':
        data = np.sqrt(data)
        if not suppress_printmsg:
            print(msg, '\nsqrt normalization')
    else:
        try:
            norm = clr.PowerNorm(cnormalize, vmin=vmin, vmax=vmax)
        except:
            pass

    if sizedata is not None:
        if snormalize is not None:
            sizedata = transform_dict[snormalize](sizedata)
        size = sizedata * size

    cm = hymap.scatter(lons, lats, c=data, s=size, cmap=colormap,
                       vmin=vmin, vmax=vmax, zorder=zorder,
                       edgecolor=edgecolor, norm=norm, latlon=True, **kwargs)

    return cm


def meteo_contouring(hymap, data, longitudes, latitudes, contourf=True,
{'fraction_non_alphanumeric': 0.11424227065382667, 'fraction_numerical': 0.003852002027369488, 'mean_word_length': 2.3649386084583903, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3350791', 'n_tokens_mistral': 3146, 'n_tokens_neox': 3023, 'n_words': 969}