diff --git a/scripts/plot_NN_2D.py b/scripts/plot_NN_2D.py index 8a75af34efc073b8b05e5dd33959d5a7bda34f67..a5b65b052d15cd22a0c6e579b8d2793855424de8 100755 --- a/scripts/plot_NN_2D.py +++ b/scripts/plot_NN_2D.py @@ -62,7 +62,7 @@ layer = args.layer neuron = args.neuron if layer is None: - layer = c.layers + layer = len(c.model.layers)-1 varx_index = c.fields.index(args.varx) if not plot_vs_activation: @@ -86,8 +86,8 @@ vary_test = c.x_test[:,vary_index] x_not_masked = np.where(varx_test != mask_value)[0] y_not_masked = np.where(vary_test != mask_value)[0] -percentilesx = weighted_quantile(varx_test[x_not_masked], [0.1, 0.99], sample_weight=total_weights[x_not_masked]) -percentilesy = weighted_quantile(vary_test[y_not_masked], [0.1, 0.99], sample_weight=total_weights[y_not_masked]) +percentilesx = weighted_quantile(varx_test[x_not_masked], [0.01, 0.99], sample_weight=total_weights[x_not_masked]) +percentilesy = weighted_quantile(vary_test[y_not_masked], [0.01, 0.99], sample_weight=total_weights[y_not_masked]) if args.xrange is not None: if len(args.xrange) < 3: @@ -154,10 +154,16 @@ if args.mode.startswith("mean"): elif args.mode.startswith("profile"): + def my_average(x, weights): + if weights.sum() <= 0: + return np.nan + else: + return np.average(x, weights=weights) + metric_dict = { "mean" : np.mean, "max" : np.max, - "average" : np.average, + "average" : my_average, } if args.mode == "profile_sig":