Skip to content

Commit d5e78a8

Browse files
committed
Solved bug in example16 residuals and added 1 to second Y axis, issue #111
1 parent 03de1a6 commit d5e78a8

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

examples/example_16/ob03235_2_full.yaml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,6 @@ other_output:
106106
file name: ob03235_2_all_models.txt
107107
yaml output:
108108
file name: ob03235_2_all_results.yaml
109-
other_output:
110-
residuals:
111-
# "-" below means the we don't output residuals for second file
112-
files: ob03235_1_res.txt -
109+
residuals:
110+
# "-" below means the we don't output residuals for second file
111+
files: ob03235_2_res.txt -

examples/example_16/ulens_model_fit.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3119,7 +3119,7 @@ def _mark_second_Y_axis_in_best_plot(self):
31193119
ticks = mm.Utils.get_mag_from_flux(flux)
31203120
ax2.set_ylabel(label).set_color(color)
31213121
ax2.spines['right'].set_color(color)
3122-
ax2.set_ylim(ylim[0], ylim[1])
3122+
ax2.set_ylim(ticks[0], ylim[1])
31233123
ax2.tick_params(axis='y', colors=color)
31243124
plt.yticks(ticks, labels, color=color)
31253125

@@ -3144,6 +3144,8 @@ def _second_Y_axis_optimal(self, ax2, A_min, A_max):
31443144
ax2.set_ylim(A_min, A_max)
31453145
A_values = ax2.yaxis.get_ticklocs().round(7)
31463146
A_values = A_values[(A_values >= max(1, A_min)) & (A_values < A_max)]
3147+
if 1. not in A_values:
3148+
A_values = np.insert(A_values, 0, 1.)
31473149
is_integer = [mag.is_integer() for mag in A_values]
31483150
if all(is_integer):
31493151
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):
31743176
"be translated to magnitudes.")
31753177
warnings.warn(msg.format(np.sum(np.logical_not(mask))))
31763178

3177-
if (np.min(A_values) < A_min or np.max(A_values) > A_max or
3179+
if (np.min(A_values) < min(A_min, 1) or np.max(A_values) > A_max or
31783180
np.any(flux < 0.)):
31793181
msg = ("Provided magnifications for the second (i.e., right-hand "
31803182
"side) Y-axis scale are from {:} to {:},\nbut the range "

0 commit comments

Comments
 (0)