Exemple #1
0
def plot_percen(irma_tc, exp, if_exp, axs):
    """ Plot irma damage in %. """
    # south
    extent = [
        exp.longitude.min() - BUFFER_DEG,
        exp.longitude.max() + BUFFER_DEG,
        exp.latitude.min() - BUFFER_DEG,
        exp.latitude.max() + BUFFER_DEG
    ]
    axs.set_extent((extent))
    u_plot.add_shapes(axs)

    imp_irma = Impact()
    imp_irma.calc(exp, if_exp, irma_tc)
    imp_irma.eai_exp[exp.value > 0] = \
        imp_irma.eai_exp[exp.value > 0]/exp.value[exp.value > 0]*100
    imp_irma.eai_exp[exp.value == 0] = 0.
    sel_exp = imp_irma.eai_exp > 0
    im = axs.hexbin(exp.longitude[sel_exp],
                    exp.latitude[sel_exp],
                    C=imp_irma.eai_exp[sel_exp],
                    reduce_C_function=np.average,
                    transform=ccrs.PlateCarree(),
                    gridsize=2000,
                    cmap='YlOrRd',
                    vmin=0,
                    vmax=50)
    axs.set_title('')
    axs.grid(False)
    scale_bar(axs, (0.90, 0.90), 10)

    return im
def plot_left(exp, data_irma, tc_irma, ax, scale_pos, cntour_loc, label_loc):
    """ Plot exposed value, irma track and irma wind field. """
    extent = u_plot._get_borders(exp.coord)
    extent = ([extent[0] - BUFFER_DEG, extent[1] + BUFFER_DEG, extent[2] -\
               BUFFER_DEG, extent[3] + BUFFER_DEG])
    ax.set_extent((extent))
    u_plot.add_shapes(ax)

    sel_pos = np.argwhere(exp.value > 0)[:, 0]
    ax.hexbin(exp.coord[sel_pos, 1],
              exp.coord[sel_pos, 0],
              C=exp.value[sel_pos],
              reduce_C_function=np.average,
              transform=ccrs.PlateCarree(),
              gridsize=2000,
              norm=LogNorm(vmin=MIN_VAL, vmax=MAX_VAL),
              cmap='YlOrRd',
              vmin=1.0e2,
              vmax=MAX_VAL)
    ax.set_title('')
    ax.grid(False)
    scale_bar(ax, scale_pos, 10)

    track = data_irma.data[0]
    ax.plot(track.lon.values,
            track.lat.values,
            linestyle='solid',
            transform=ccrs.PlateCarree(),
            lw=2,
            color='k')
    leg_lines = [
        Line2D([0], [0], color='k', lw=2),
        Line2D([0], [0], color='grey', lw=1, ls=':')
    ]
    leg_names = ['Irma track', 'wind field (kn)']
    if 'bbox' in label_loc:
        ax.legend(leg_lines,
                  leg_names,
                  bbox_to_anchor=label_loc['bbox'],
                  loc=label_loc['loc'])
    else:
        ax.legend(leg_lines, leg_names, loc=label_loc['loc'])

    tc_irma.intensity *= MS2KN
    grid_x, grid_y = np.mgrid[tc_irma.centroids.coord[:, 1].min() : \
                              tc_irma.centroids.coord[:, 1].max() : complex(0, 2000), \
                              tc_irma.centroids.coord[:, 0].min() : \
                              tc_irma.centroids.coord[:, 0].max() : complex(0, 2000)]
    grid_im = griddata(
        (tc_irma.centroids.coord[:, 1], tc_irma.centroids.coord[:, 0]),
        np.array(tc_irma.intensity[0].todense()).squeeze(), (grid_x, grid_y))
    cs = ax.contour(grid_x, grid_y, grid_im, linewidths=1.0, linestyles=':', \
                    levels=[60, 80, 100, 120], colors=['grey', 'grey', 'grey', 'grey', 'grey'])
    ax.clabel(cs,
              inline=1,
              fontsize=10,
              manual=cntour_loc,
              rotation=-20,
              fmt='%1.0f')
    tc_irma.intensity /= MS2KN
Exemple #3
0
def plot_right(irma_tc, exp, ax, scale_pos, plot_line=False):
    """ Plot irma damage in USD. """
    if_exp = ImpactFuncSet()
    if_em = IFTropCyclone()
    if_em.set_emanuel_usa()
    if_exp.append(if_em)

    imp_irma = Impact()
    imp_irma.calc(exp, if_exp, irma_tc)
    extent = [
        exp.longitude.min() - BUFFER_DEG,
        exp.longitude.max() + BUFFER_DEG,
        exp.latitude.min() - BUFFER_DEG,
        exp.latitude.max() + BUFFER_DEG
    ]
    ax.set_extent((extent))
    u_plot.add_shapes(ax)

    sel_pos = np.argwhere(imp_irma.eai_exp > 0)[:, 0]
    hex_bin = ax.hexbin(imp_irma.coord_exp[sel_pos, 1],
                        imp_irma.coord_exp[sel_pos, 0],
                        C=imp_irma.eai_exp[sel_pos],
                        reduce_C_function=np.average,
                        transform=ccrs.PlateCarree(),
                        gridsize=2000,
                        norm=LogNorm(vmin=MIN_VAL, vmax=MAX_VAL),
                        cmap='YlOrRd',
                        vmin=MIN_VAL,
                        vmax=MAX_VAL)
    ax.set_title('')
    ax.grid(False)
    add_cntry_names(ax, extent)
    scale_bar(ax, scale_pos, 10)

    if plot_line:
        x1, y1 = [-64.57, -64.82], [18.28, 18.47]
        ax.plot(x1, y1, linewidth=1.0, color='grey', linestyle='--')

    return hex_bin