From d5e78a8496c10e65a47d7a8214dfe880b5f31afe Mon Sep 17 00:00:00 2001 From: "Raphael A. P. Oliveira" Date: Thu, 21 Dec 2023 23:44:15 +0100 Subject: [PATCH 1/2] Solved bug in example16 residuals and added 1 to second Y axis, issue #111 --- examples/example_16/ob03235_2_full.yaml | 7 +++---- examples/example_16/ulens_model_fit.py | 6 ++++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/examples/example_16/ob03235_2_full.yaml b/examples/example_16/ob03235_2_full.yaml index b660b92e4..04b247b59 100644 --- a/examples/example_16/ob03235_2_full.yaml +++ b/examples/example_16/ob03235_2_full.yaml @@ -106,7 +106,6 @@ other_output: file name: ob03235_2_all_models.txt yaml output: file name: ob03235_2_all_results.yaml - other_output: - residuals: - # "-" below means the we don't output residuals for second file - files: ob03235_1_res.txt - + residuals: + # "-" below means the we don't output residuals for second file + files: ob03235_2_res.txt - diff --git a/examples/example_16/ulens_model_fit.py b/examples/example_16/ulens_model_fit.py index 614f29c2a..fee0b9d00 100644 --- a/examples/example_16/ulens_model_fit.py +++ b/examples/example_16/ulens_model_fit.py @@ -3119,7 +3119,7 @@ def _mark_second_Y_axis_in_best_plot(self): ticks = mm.Utils.get_mag_from_flux(flux) ax2.set_ylabel(label).set_color(color) ax2.spines['right'].set_color(color) - ax2.set_ylim(ylim[0], ylim[1]) + ax2.set_ylim(ticks[0], ylim[1]) ax2.tick_params(axis='y', colors=color) plt.yticks(ticks, labels, color=color) @@ -3144,6 +3144,8 @@ def _second_Y_axis_optimal(self, ax2, A_min, A_max): ax2.set_ylim(A_min, A_max) A_values = ax2.yaxis.get_ticklocs().round(7) A_values = A_values[(A_values >= max(1, A_min)) & (A_values < A_max)] + if 1. not in A_values: + A_values = np.insert(A_values, 0, 1.) is_integer = [mag.is_integer() for mag in A_values] if all(is_integer): labels = [f"{int(x):d}" for x in A_values] @@ -3174,7 +3176,7 @@ def _second_Y_axis_warnings(self, flux, labels, A_values, A_min, A_max): "be translated to magnitudes.") warnings.warn(msg.format(np.sum(np.logical_not(mask)))) - if (np.min(A_values) < A_min or np.max(A_values) > A_max or + if (np.min(A_values) < min(A_min, 1) or np.max(A_values) > A_max or np.any(flux < 0.)): msg = ("Provided magnifications for the second (i.e., right-hand " "side) Y-axis scale are from {:} to {:},\nbut the range " From 63aa94e237f799a3665abebd837cd331ca456879 Mon Sep 17 00:00:00 2001 From: "Raphael A. P. Oliveira" Date: Fri, 22 Dec 2023 14:24:32 +0100 Subject: [PATCH 2/2] Minor corrections to magnification=1.0, issue #111 --- examples/example_16/ulens_model_fit.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/example_16/ulens_model_fit.py b/examples/example_16/ulens_model_fit.py index fee0b9d00..697b982d7 100644 --- a/examples/example_16/ulens_model_fit.py +++ b/examples/example_16/ulens_model_fit.py @@ -38,7 +38,7 @@ except Exception: raise ImportError('\nYou have to install MulensModel first!\n') -__version__ = '0.34.2' +__version__ = '0.34.3' class UlensModelFit(object): @@ -3119,7 +3119,7 @@ def _mark_second_Y_axis_in_best_plot(self): ticks = mm.Utils.get_mag_from_flux(flux) ax2.set_ylabel(label).set_color(color) ax2.spines['right'].set_color(color) - ax2.set_ylim(ticks[0], ylim[1]) + ax2.set_ylim(ylim[0], ylim[1]) ax2.tick_params(axis='y', colors=color) plt.yticks(ticks, labels, color=color) @@ -3144,7 +3144,7 @@ def _second_Y_axis_optimal(self, ax2, A_min, A_max): ax2.set_ylim(A_min, A_max) A_values = ax2.yaxis.get_ticklocs().round(7) A_values = A_values[(A_values >= max(1, A_min)) & (A_values < A_max)] - if 1. not in A_values: + if 1. not in A_values and A_min <= 1: A_values = np.insert(A_values, 0, 1.) is_integer = [mag.is_integer() for mag in A_values] if all(is_integer): @@ -3176,7 +3176,7 @@ def _second_Y_axis_warnings(self, flux, labels, A_values, A_min, A_max): "be translated to magnitudes.") warnings.warn(msg.format(np.sum(np.logical_not(mask)))) - if (np.min(A_values) < min(A_min, 1) or np.max(A_values) > A_max or + if (np.min(A_values) < A_min or np.max(A_values) > A_max or np.any(flux < 0.)): msg = ("Provided magnifications for the second (i.e., right-hand " "side) Y-axis scale are from {:} to {:},\nbut the range "