dep0 = (None, None, None, None) ref_mu = FunctionParam("lnsquare2", 3.62, 5.77, None) ref_sigma = FunctionParam("asymdecrease3", 0, 0.324, 0.404) dist1 = LognormalDistribution(sigma=ref_sigma, mu=ref_mu) dep1 = (0, None, 0) distributions = [dist0, dist1] dependencies = [dep0, dep1] mul_dist = MultivariateDistribution(distributions, dependencies) ref_f = mul_dist.pdf(x.T) ref_f_expweib = mul_dist.distributions[0].pdf(x[:, 0]) ref_ln = mul_dist.distributions[1] ref_f_ln = [] for given in my_given: y = np.stack([np.full_like(x[:, 1], given), x[:, 1]]) ref_f_ln.append(ref_ln.pdf(x[:, 1], y, (0, None, 0))) ref_f_ln = np.stack(ref_f_ln, axis=1) ref_isorm = ISormContour(mul_dist, return_period, state_duration) ref_coordinates = np.stack(ref_isorm.coordinates, axis=1)
trs = [1, 50, 250] fms = np.empty(shape=(3, 1)) for i, tr in enumerate(trs): HDC = HighestDensityContour(joint_dist, return_period=tr, state_duration=1, limits=[(0, 20), (0, 0.1)]) fms[i] = HDC.fm h_step = 0.05 s_step = 0.00025 h_grid, s_grid = np.mgrid[0:18:h_step, 0:0.08:s_step] f = np.empty_like(h_grid) for i in range(h_grid.shape[0]): for j in range(h_grid.shape[1]): f[i, j] = joint_dist.pdf([h_grid[i, j], s_grid[i, j]]) print('Done with calculating f') axs[2].scatter(tp, hs, c='black', s=5, alpha=0.5, rasterized=True) axs[2].spines['right'].set_visible(False) axs[2].spines['top'].set_visible(False) axs[2].set_xlabel(tp_label) axs[2].set_ylabel(hs_label) colors = ['red', 'blue', 'green'] labels = ['1-yr', '50-yr', '250-yr'] for i, (fm, c, l) in enumerate(zip(fms, colors, labels)): CS = axs[0].contour(h_grid, s_grid, f, [fm], colors=c, label=[l]) # Now transform the contour to tp hs_s_contour = CS.allsegs[0][0] hs_contour = hs_s_contour[:, 0]
axs1[i + 2].set_xlabel(var_symbols[i] + ', theoretical quantiles') for ax in axs1: ax.spines['right'].set_visible(False) ax.spines['top'].set_visible(False) # Joint model plot to analyze the dependence structure fig2, axs2 = plt.subplots(1, 3, figsize=(12, 4)) # Constant density lines v_step = 0.1 h_step = 0.1 vgrid, hgrid = np.mgrid[0:40:v_step, 0:20:h_step] f = np.empty_like(vgrid) for i in range(vgrid.shape[0]): for j in range(vgrid.shape[1]): f[i, j] = joint_model_4.pdf([vgrid[i, j], hgrid[i, j]]) density_levels = [1E-6, 1E-5, 1E-4, 1E-3, 1E-2, 1E-1] axs2[0].scatter(u, hs, s=3, c='black', alpha=0.5, zorder=-2, rasterized=True) from palettable.colorbrewer.diverging import Spectral_6 as mycorder level_colors = np.array(mycorder.mpl_colors) CS = axs2[0].contour(vgrid, hgrid, f, density_levels, colors=level_colors) axs2[0].set_xlim(0, 35) axs2[0].set_ylim(0, 16) lines = [ CS.collections[0], CS.collections[1], CS.collections[2], CS.collections[3], CS.collections[4], CS.collections[5] ] labels = [ '$10^{-6}$', '$10^{-5}$', '$10^{-4}$', '$10^{-3}$', '$10^{-2}$',