コード例 #1
0
ファイル: utils.py プロジェクト: typesanitizer/xarray
def register_pandas_datetime_converter_if_needed():
    # based on https://github.com/pandas-dev/pandas/pull/17710
    global _registered
    if not _registered:
        from pandas.tseries import converter
        converter.register()
        _registered = True
コード例 #2
0
    def plot(self, date1: str, date2: str, data='Global Horiz'):
        df = self.loading()
        converter.register()

        d1 = datetime.strptime(date1, '%Y-%m-%d')
        d2 = datetime.strptime(date2, '%Y-%m-%d')

        df2plot = df.loc[d1:d2]
        sns.set(style="darkgrid")
        f, ax = plt.subplots(figsize=(10, 5))
        sns.lineplot(x=df2plot.index, y=df2plot[data])

        # Removing top and right borders
        ax.spines['top'].set_visible(False)
        ax.spines['right'].set_visible(False)

        # Finalize the plot
        sns.despine(bottom=True)
        plt.setp(f.axes,
                 xticks=[],
                 xlabel='Interval\nfrom: {0}\nto: {1}'.format(date1, date2),
                 ylabel='Solar Irradiation (W/m²)')
        plt.tight_layout(h_pad=2)

        plt.savefig("output.png")
        print('Image saved.')
コード例 #3
0
ファイル: utils.py プロジェクト: jnecus/xarray
def register_pandas_datetime_converter_if_needed():
    # based on https://github.com/pandas-dev/pandas/pull/17710
    global _registered
    if not _registered:
        from pandas.tseries import converter
        converter.register()
        _registered = True
コード例 #4
0
ファイル: test_converter.py プロジェクト: BobMcFry/pandas
    def test_old_import_warns(self):
        with tm.assert_produces_warning(FutureWarning) as w:
            from pandas.tseries import converter
            converter.register()

        assert len(w)
        assert ('pandas.plotting.register_matplotlib_converters' in
                str(w[0].message))
コード例 #5
0
ファイル: test_converter.py プロジェクト: joe-harkman/pandas
    def test_old_import_warns(self):
        with tm.assert_produces_warning(FutureWarning) as w:
            from pandas.tseries import converter
            converter.register()

        assert len(w)
        assert ('pandas.plotting.register_matplotlib_converters' in
                str(w[0].message))
コード例 #6
0
ファイル: monitor_fcdr.py プロジェクト: jmollard/FCDR_HIRS
def main():
    # NB: https://github.com/pydata/xarray/issues/1661#issuecomment-339525582
    from pandas.tseries import converter
    converter.register()
    p = parse_cmdline()
    common.set_logger(logging.DEBUG if p.verbose else logging.INFO,
                      p.log,
                      loggers={"FCDR_HIRS", "typhon"})
    plot(p)
コード例 #7
0
def test_date2num_dst_pandas():
    # Test for github issue #3896, but in date2num around DST transitions
    # with a timezone-aware pandas date_range object.
    pd = pytest.importorskip('pandas')
    from pandas.tseries import converter
    converter.register()

    def tz_convert(*args):
        return pd.DatetimeIndex.tz_convert(*args).astype(object)

    _test_date2num_dst(pd.date_range, tz_convert)
コード例 #8
0
ファイル: test_dates.py プロジェクト: gepcel/matplotlib
def test_date2num_dst_pandas():
    # Test for github issue #3896, but in date2num around DST transitions
    # with a timezone-aware pandas date_range object.
    pd = pytest.importorskip('pandas')
    from pandas.tseries import converter
    converter.register()

    def tz_convert(*args):
        return pd.DatetimeIndex.tz_convert(*args).astype(object)

    _test_date2num_dst(pd.date_range, tz_convert)
コード例 #9
0
ファイル: sonde.py プロジェクト: juhi24/negi
def heatmap(*args, classes=None, cmap=DEFAULT_DISCRETE_CMAP, **kws):
    """j24.visualization.heatmap wrapper for sounding data"""
    # This is needed because of a bug in pandas 0.21
    from pandas.tseries import converter
    converter.register()
    fig, ax = vis.heatmap(*args, cmap='jet', **kws)
    fmt_m2km(ax.yaxis)
    ax.set_ylabel('Height, km')
    if classes is not None:
        vis.class_colors(classes, ax=ax, cmap=cmap)
    return fig, ax
コード例 #10
0
ファイル: utils.py プロジェクト: edoddridge/xarray
def register_pandas_datetime_converter_if_needed():
    # based on https://github.com/pandas-dev/pandas/pull/17710
    global _registered
    if not _registered:
        try:
            from pandas.plotting import register_matplotlib_converters
            register_matplotlib_converters()
        except ImportError:
            # register_matplotlib_converters new in pandas 0.22
            from pandas.tseries import converter
            converter.register()
        _registered = True
コード例 #11
0
ファイル: utils.py プロジェクト: tv3141/xarray
def register_pandas_datetime_converter_if_needed():
    # based on https://github.com/pandas-dev/pandas/pull/17710
    global _registered
    if not _registered:
        try:
            from pandas.plotting import register_matplotlib_converters
            register_matplotlib_converters()
        except ImportError:
            # register_matplotlib_converters new in pandas 0.22
            from pandas.tseries import converter
            converter.register()
        _registered = True
コード例 #12
0
ファイル: plotdata.py プロジェクト: mjm461/assessments
import pandas as pd
import numpy
import matplotlib.pyplot as plt
import argparse
from pandas.tseries import converter
converter.register()

if __name__ == '__main__':

    parser = argparse.ArgumentParser()
    parser.add_argument('--assessments',
                        type=str,
                        default="assessments.csv",
                        help="CSV file input")
    parser.add_argument('--parcel',
                        type=str,
                        help="The parcel to compare",
                        required=False)
    args = parser.parse_args()

    df = pd.read_csv(args.assessments)
    df['Sale Date'] = pd.to_datetime(df['Sale Date'], format='%m/%d/%Y')
    parcel = df.loc[df['Parcel Id'] == args.parcel]

    ax = df.plot(kind='scatter', x='Lot Area', y='County Land Value')
    parcel.plot(kind='scatter',
                x='Lot Area',
                y='County Land Value',
                color='red',
                ax=ax)
    ax = df.plot(kind='scatter',
コード例 #13
0
ファイル: __init__.py プロジェクト: basnijholt/holoviews
from .sankey import * # noqa (API import)
from .stats import * # noqa (API import)
from .tabular import * # noqa (API import)

from .renderer import MPLRenderer


mpl_ge_150 = LooseVersion(mpl.__version__) >= '1.5.0'

if pd:
    try:
        from pandas.plotting import register_matplotlib_converters
        register_matplotlib_converters()
    except ImportError:
        from pandas.tseries import converter
        converter.register()


def set_style(key):
    """
    Select a style by name, e.g. set_style('default'). To revert to the
    previous style use the key 'unset' or False.
    """
    if key is None:
        return
    elif not key or key in ['unset', 'backup']:
        if 'backup' in styles:
            plt.rcParams.update(styles['backup'])
        else:
            raise Exception('No style backed up to restore')
    elif key not in styles:
コード例 #14
0
ファイル: plotting.py プロジェクト: r0k3/pandas
import datetime

import numpy as np

from pandas.util.decorators import cache_readonly
import pandas.core.common as com
from pandas.core.index import MultiIndex
from pandas.core.series import Series, remove_na
from pandas.tseries.index import DatetimeIndex
from pandas.tseries.period import PeriodIndex
from pandas.tseries.frequencies import get_period_alias, get_base_alias
from pandas.tseries.offsets import DateOffset

try: # mpl optional
    import pandas.tseries.converter as conv
    conv.register()
except ImportError:
    pass

def _get_standard_kind(kind):
    return {'density' : 'kde'}.get(kind, kind)


def scatter_matrix(frame, alpha=0.5, figsize=None, ax=None, grid=False,
                   diagonal='hist', marker='.', **kwds):
    """
    Draw a matrix of scatter plots.

    Parameters
    ----------
    alpha : amount of transparency applied
コード例 #15
0
ファイル: graphs.py プロジェクト: ASRCsoft/xcite_apps
"""
Functions for generating nice lidar profile graphs
"""

# get matplotlib with agg backend for drawing graphs on servers with
# no display
import matplotlib
matplotlib.use('Agg')
matplotlib.rcParams['figure.figsize'] = (15, 7)
from matplotlib.backends.backend_agg import FigureCanvasAgg as FigureCanvas
from matplotlib.figure import Figure
import matplotlib.pyplot as plt
# see here: https://matplotlib.org/faq/howto_faq.html#plot-numpy-datetime64-values
from pandas.tseries import converter as pdtc
pdtc.register()

# useful stuff
import xml, rasppy
import datetime as dt
import numpy as np
import xarray as xr
from io import BytesIO
# matplotlib tools for calculating tickmark locations -- I'm using
# these to find nice windbarb intervals
from matplotlib.ticker import MaxNLocator
from matplotlib.dates import AutoDateLocator, num2date
# and this is needed to help monkey patch the barbs function
from dateutil.rrule import (rrule, MO, TU, WE, TH, FR, SA, SU, YEARLY,
                            MONTHLY, WEEKLY, DAILY, HOURLY, MINUTELY,
                            SECONDLY)
MICROSECONDLY = SECONDLY + 1