Esempio n. 1
0
def set_matplotlib_colors_89pct(min_tb=105, max_tb=280):

    if min_tb >= 125 or max_tb <= 265:
        raise ('89pct range must include 125 and 265')

    from geoips2.image_utils.colormaps import create_linear_segmented_colormap
    transition_vals = [(min_tb, 125), (125, 150), (150, 175), (175, 212),
                       (212, 230), (230, 250), (250, 265), (265, max_tb)]
    # (280, max_tb)]
    transition_colors = [('orange', 'chocolate'), ('chocolate', 'indianred'),
                         ('indianred', 'firebrick'), ('firebrick', 'red'),
                         ('gold', 'yellow'), ('lime', 'limegreen'),
                         ('deepskyblue', 'blue'), ('navy', 'slateblue')]
    # ('magenta', 'white')]

    ticks = [int(xx[0]) for xx in transition_vals]

    #special selection of label

    # ticks = [min_tb, 125, 150, 175, 200, 225, 250, 275, max_tb]

    # selection of min and max values for colormap if needed
    min_tb = transition_vals[0][0]
    max_tb = transition_vals[-1][1]
    ticks = ticks + [int(max_tb)]

    LOG.info('Setting cmap')
    mpl_cmap = create_linear_segmented_colormap('89pct_cmap', min_tb, max_tb,
                                                transition_vals,
                                                transition_colors)

    LOG.info('Setting norm')
    from matplotlib.colors import Normalize
    mpl_norm = Normalize(vmin=min_tb, vmax=max_tb)

    cbar_label = 'TB (K)'

    # Must be uniform or proportional, None not valid for Python 3
    cbar_spacing = 'proportional'
    mpl_tick_labels = None
    mpl_boundaries = None

    # from geoips2.image_utils.mpl_utils import create_colorbar
    # only create colorbar for final imagery
    # cbar = create_colorbar(fig, mpl_cmap, mpl_norm, ticks, cbar_label=cbar_label)
    mpl_colors_info = {
        'cmap': mpl_cmap,
        'norm': mpl_norm,
        'cbar_ticks': ticks,
        'cbar_tick_labels': mpl_tick_labels,
        'cbar_label': cbar_label,
        'boundaries': mpl_boundaries,
        'cbar_spacing': cbar_spacing,
        'colorbar': True,
        'cbar_full_width': True
    }

    # return cbar, min_tb, max_tb
    return mpl_colors_info
Esempio n. 2
0
def set_matplotlib_colors_37H(min_tb=125, max_tb=300):

    if min_tb >= 185 or max_tb <= 280:
        raise ('89pct range must include 125 and 265')

    from geoips2.image_utils.colormaps import create_linear_segmented_colormap
    transition_vals = [(min_tb, 185), (185, 210), (210, 240), (240, 260),
                       (260, 280), (280, max_tb)]
    transition_colors = [('lightyellow', 'darkmagenta'), ('purple', 'cyan'),
                         ('cyan', 'yellow'), ('yellow', 'red'),
                         ('red', 'darkred'), ('silver', 'black')]

    ticks = [xx[0] for xx in transition_vals]

    #special selection of label

    # ticks = [125, 150, 175, 200, 225, 250, 275, 300]

    # selection of min and max values for colormap if needed
    min_tb = transition_vals[0][0]
    max_tb = transition_vals[-1][1]
    ticks = ticks + [int(max_tb)]

    LOG.info('Setting cmap')
    mpl_cmap = create_linear_segmented_colormap('37h_cmap', min_tb, max_tb,
                                                transition_vals,
                                                transition_colors)

    LOG.info('Setting norm')
    from matplotlib.colors import Normalize
    mpl_norm = Normalize(vmin=min_tb, vmax=max_tb)

    cbar_label = 'TB (K)'

    # Must be uniform or proportional, None not valid for Python 3
    cbar_spacing = 'proportional'
    mpl_tick_labels = None
    mpl_boundaries = None

    # from geoips2.image_utils.mpl_utils import create_colorbar
    # only create colorbar for final imagery
    # cbar = create_colorbar(fig, mpl_cmap, mpl_norm, ticks, cbar_label=cbar_label)
    mpl_colors_info = {
        'cmap': mpl_cmap,
        'norm': mpl_norm,
        'cbar_ticks': ticks,
        'cbar_tick_labels': mpl_tick_labels,
        'cbar_label': cbar_label,
        'boundaries': mpl_boundaries,
        'cbar_spacing': cbar_spacing,
        'colorbar': True,
        'cbar_full_width': True
    }

    # return cbar, min_tb, max_tb
    return mpl_colors_info
Esempio n. 3
0
def set_matplotlib_colors_150H(min_tb=110, max_tb=310):

    from geoips2.image_utils.colormaps import create_linear_segmented_colormap
    transition_vals = [(min_tb, 130), (130, 160), (160, 180), (180, 210),
                       (210, 230), (230, 250), (250, 270), (270, 290),
                       (290, max_tb)]
    transition_colors = [('black', 'blue'), ('blue', 'cyan'),
                         ('cyan', 'green'), ('green', 'yellow'),
                         ('yellow', 'orange'), ('orange', 'red'),
                         ('red', 'maroon'), ('maroon', 'darkmagenta'),
                         ('darkmagenta', 'white')]

    #ticks = [xx[0] for xx in transition_vals]

    #special selection of label

    ticks = [110, 130, 150, 170, 190, 210, 230, 250, 270, 290, 310]

    # selection of min and max values for colormap if needed
    min_tb = transition_vals[0][0]
    max_tb = transition_vals[-1][1]

    LOG.info('Setting cmap')
    mpl_cmap = create_linear_segmented_colormap('150h_cmap', min_tb, max_tb,
                                                transition_vals,
                                                transition_colors)

    LOG.info('Setting norm')
    from matplotlib.colors import Normalize
    mpl_norm = Normalize(vmin=min_tb, vmax=max_tb)

    cbar_label = 'TB (K)'

    # Must be uniform or proportional, None not valid for Python 3
    cbar_spacing = 'proportional'
    mpl_tick_labels = None
    mpl_boundaries = None

    # from geoips2.image_utils.mpl_utils import create_colorbar
    # only create colorbar for final imagery
    # cbar = create_colorbar(fig, mpl_cmap, mpl_norm, ticks, cbar_label=cbar_label)
    mpl_colors_info = {
        'cmap': mpl_cmap,
        'norm': mpl_norm,
        'cbar_ticks': ticks,
        'cbar_tick_labels': mpl_tick_labels,
        'cbar_label': cbar_label,
        'boundaries': mpl_boundaries,
        'cbar_spacing': cbar_spacing,
        'colorbar': True
    }

    return mpl_colors_info
Esempio n. 4
0
def set_matplotlib_colors_37pct(min_tb=230, max_tb=280):

    from geoips2.image_utils.colormaps import create_linear_segmented_colormap
    transition_vals = [(min_tb, 240), (240, 260), (260, max_tb)]
    transition_colors = [('cyan', 'yellow'), ('yellow', 'red'),
                         ('red', 'darkred')]

    #special selection of label

    ticks = [230, 240, 250, 260, 270, 280]

    # selection of min and max values for colormap if needed
    min_tb = transition_vals[0][0]
    max_tb = transition_vals[-1][1]

    LOG.info('Setting cmap')
    mpl_cmap = create_linear_segmented_colormap('37pct_cmap', min_tb, max_tb,
                                                transition_vals,
                                                transition_colors)

    LOG.info('Setting norm')
    from matplotlib.colors import Normalize
    mpl_norm = Normalize(vmin=min_tb, vmax=max_tb)

    cbar_label = 'TB (K)'

    # Must be uniform or proportional, None not valid for Python 3
    cbar_spacing = 'proportional'
    mpl_tick_labels = None
    mpl_boundaries = None

    # from geoips2.image_utils.mpl_utils import create_colorbar
    # only create colorbar for final imagery
    # cbar = create_colorbar(fig, mpl_cmap, mpl_norm, ticks, cbar_label=cbar_label)
    mpl_colors_info = {
        'cmap': mpl_cmap,
        'norm': mpl_norm,
        'cbar_ticks': ticks,
        'cbar_tick_labels': mpl_tick_labels,
        'cbar_label': cbar_label,
        'boundaries': mpl_boundaries,
        'cbar_spacing': cbar_spacing,
        'colorbar': True
    }

    # return cbar, min_tb, max_tb
    return mpl_colors_info
Esempio n. 5
0
def set_matplotlib_colors_winds(min_wind_speed=0, max_wind_speed=200):
    ''' Generate appropriate matplotlib colors for plotting standard wind speeds.  set_matplotlib_colors_winds
        contains hard coded transition values for different colors, in order to have consistent imagery across all
        sensors / products

    Args:
        min_wind_speed (float) : Default 0
        max_wind_speed (float) : Default 200

    Returns:
        mpl_colors_info (dict) Specifies matplotlib Colors parameters for use in both plotting and colorbar generation
                                See geoips2.image_utils.mpl_utils.create_colorbar for field descriptions.
                                For Wind Speed colors, the following general fields are used:
            mpl_colors_info = {'cmap': (LinearSegmentedColormap)
                               'norm': (Normalize)
                               'cbar_ticks':  (list of transition values for wind speeds)
                               'cbar_tick_labels': (None)
                               'cbar_label': ('Surface Wind (knots)')
                               'boundaries': (None)
                               'cbar_spacing': ('proportional')
                               'colorbar': (True)}
    '''

    from geoips2.image_utils.colormaps import create_linear_segmented_colormap
    transition_vals = [
        (min_wind_speed, 34),
        (34, 50),
        (50, 64),
        (64, 80),
        # (64, 72),
        # (72, 80),
        (80, 100),
        (100, 120),
        (120, 150),
        (150, max_wind_speed)
    ]
    transition_colors = [
        ('lightblue', 'blue'),
        ('yellow', 'orange'),
        ('red', 'red'),

        # ('thistle', 'thistle'),
        # ('firebrick', 'firebrick'),
        # ('fuchsia', 'fuchsia'),
        # ('mediumvioletred', 'mediumvioletred'),
        ('rebeccapurple', 'rebeccapurple'),

        # ('purple', 'rebeccapurple'),
        # ('rebeccapurple', 'rebeccapurple'),
        # ('mediumvioletred', 'mediumvioletred'),
        ('palevioletred', 'palevioletred'),
        ('silver', 'silver'),
        ('gray', 'gray'),
        ('dimgray', 'dimgray')
    ]

    ticks = [xx[0] for xx in transition_vals]

    min_wind_speed = transition_vals[0][0]
    max_wind_speed = transition_vals[-1][1]

    LOG.info('Setting cmap')
    mpl_cmap = create_linear_segmented_colormap('windspeed_cmap',
                                                min_wind_speed, max_wind_speed,
                                                transition_vals,
                                                transition_colors)

    LOG.info('Setting norm')
    from matplotlib.colors import Normalize
    mpl_norm = Normalize(vmin=min_wind_speed, vmax=max_wind_speed)

    cbar_label = 'Surface Wind (knots)'

    # Must be uniform or proportional, None not valid for Python 3
    cbar_spacing = 'proportional'
    mpl_tick_labels = None
    mpl_boundaries = None

    # from geoips2.image_utils.mpl_utils import create_colorbar
    # only create colorbar for final imagery
    # cbar = create_colorbar(fig, mpl_cmap, mpl_norm, ticks, cbar_label=cbar_label)
    mpl_colors_info = {
        'cmap': mpl_cmap,
        'norm': mpl_norm,
        'cbar_ticks': ticks,
        'cbar_tick_labels': mpl_tick_labels,
        'cbar_label': cbar_label,
        'boundaries': mpl_boundaries,
        'cbar_spacing': cbar_spacing,
        'colorbar': True
    }

    # return cbar, min_wind_speed, max_wind_speed
    return mpl_colors_info
Esempio n. 6
0
def set_matplotlib_colors_IR(min_tb=-90, max_tb=30):

    # for Infrared images at 11 um.  Unit: Celsius

    if min_tb > -90 or max_tb < 30:
        raise ('Infrared TB range must include -90 and 30')

    from geoips2.image_utils.colormaps import create_linear_segmented_colormap
    transition_vals = [(min_tb, -80), (-80, -70), (-70, -50), (-50, -40),
                       (-40, -30), (-30, -15), (-15, 0), (0, 15), (15, max_tb)]
    transition_colors = [('darkorange', 'yellow'), ('darkred', 'red'),
                         ('green', 'palegreen'), ('navy', 'royalblue'),
                         ('royalblue', 'deepskyblue'),
                         ('whitesmoke', 'silver'), ('silver', 'grey'),
                         ('grey', 'dimgrey'), ('dimgrey', 'black')]

    #ticks = [int(xx[0]) for xx in transition_vals]

    #special selection of label

    ticks = [
        min_tb, -80, -70, -60, -50, -40, -30, -20, -10, 0, 10, 20, 30, max_tb
    ]

    # selection of min and max values for colormap if needed
    min_tb = transition_vals[0][0]
    max_tb = transition_vals[-1][1]
    ticks = ticks + [int(max_tb)]

    LOG.info('Setting cmap')
    mpl_cmap = create_linear_segmented_colormap('89pct_cmap', min_tb, max_tb,
                                                transition_vals,
                                                transition_colors)

    LOG.info('Setting norm')
    from matplotlib.colors import Normalize
    mpl_norm = Normalize(vmin=min_tb, vmax=max_tb)

    cbar_label = '11um BT (C)'

    # Must be uniform or proportional, None not valid for Python 3
    cbar_spacing = 'proportional'
    mpl_tick_labels = None
    mpl_boundaries = None

    # from geoips2.image_utils.mpl_utils import create_colorbar
    # only create colorbar for final imagery
    # cbar = create_colorbar(fig, mpl_cmap, mpl_norm, ticks, cbar_label=cbar_label)
    mpl_colors_info = {
        'cmap': mpl_cmap,
        'norm': mpl_norm,
        'cbar_ticks': ticks,
        'cbar_tick_labels': mpl_tick_labels,
        'cbar_label': cbar_label,
        'boundaries': mpl_boundaries,
        'cbar_spacing': cbar_spacing,
        'colorbar': True,
        'cbar_full_width': True
    }

    # return cbar, min_tb, max_tb
    return mpl_colors_info