From 0ae4c6920c90e84bfbb46921328813f134e0d3fb Mon Sep 17 00:00:00 2001 From: Markus Rosenstihl Date: Tue, 25 Mar 2025 21:05:24 +0100 Subject: [PATCH] added proper range --- isotables/isotopapp/views.py | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/isotables/isotopapp/views.py b/isotables/isotopapp/views.py index 1d2bf08..723b6a3 100644 --- a/isotables/isotopapp/views.py +++ b/isotables/isotopapp/views.py @@ -70,32 +70,39 @@ def result(request): radius = 2.5 center = (0, 0) w = Wedge(center, radius, theta1, theta2, fc='#D5D9FFB2', edgecolor='black') + w_upper = Wedge((0,2.5), radius, theta1, theta2, fc='#D5D9FF42', edgecolor='black') + w_lower = Wedge((0,-2.5), radius, theta1, theta2, fc='#D5D9FF42', edgecolor='black') + + ax.set_xlim([-8, 8]) + ax.set_ylim([-8, 8]) + ax.grid(True) + + ax.add_patch(w_upper) + ax.add_patch(w_lower) ax.add_patch(w) sample_diameter = 5e-3 gradient = float(request.GET.get('gradient')) - freq_range = sample_diameter/2 * gradient * isotope1.gamma + close_isotopes = [] for isotope in Isotope.objects.all(): if isotope.gamma == 0: continue if not isotope.stable: continue - f_Larmor = field_T*isotope.gamma z = (freq/isotope.gamma-field_T)/gradient - if abs(z) <= sample_diameter/2: + if abs(z) <= sample_diameter: i_info = isotope_info(isotope, field_T) #i_info[3] = f"{z*1e3:.1f} mm" close_isotopes.append(i_info) - arr = FancyArrowPatch((np.sqrt(2.5**2-(z*1e3)**2),z*1e3), (-np.sqrt(2.5**2-(z*1e3)**2), z*1e3), - arrowstyle='<->,head_width=.1', mutation_scale=20) + arr = FancyArrowPatch((-2.5,z*1e3), (2.5, z*1e3), + arrowstyle='<->,head_width=.1', mutation_scale=20, linewidth=2) ax.add_patch(arr) - ax.annotate(f"{isotope.n_nucleons}{isotope.symbol}", (1.05, 0), xycoords=arr, ha='left', va='center',fontsize=7) + ax.annotate(f"{isotope.n_nucleons}{isotope.symbol}", (1.1, 0), xycoords=arr, ha='left', va='center',fontsize=8) ax.set_aspect('equal') - ax.set_xlim([-4, 4]) - ax.set_ylim([-4, 4]) + ax.set_ylabel('z (mm)') - ax.grid(True) + buf = BytesIO() plt.savefig(buf, format='png') figure = base64.b64encode(buf.getvalue()).decode('utf-8').replace('\n', '')