Witches day

This commit is contained in:
rskoupy
2024-04-29 18:00:39 +02:00
parent 1af8c70c77
commit b1d668c352
3 changed files with 308 additions and 89 deletions

View File

@ -30,14 +30,14 @@
},
{
"cell_type": "code",
"execution_count": 380,
"execution_count": 20,
"id": "7937f054-fcd0-4e67-a20f-7696f5903a94",
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "0b1b53b08a164896893f0f563fa29206",
"model_id": "13c78bb2a5be48d79c3d210afa1c877e",
"version_major": 2,
"version_minor": 0
},
@ -81,7 +81,7 @@
},
{
"cell_type": "code",
"execution_count": 379,
"execution_count": 19,
"id": "3ca2e3fd-4e61-4d4c-9d58-4b72f16999dc",
"metadata": {},
"outputs": [],
@ -92,6 +92,7 @@
"\n",
"import numpy as np\n",
"import scipy.constants as cons\n",
"from scipy.stats import norm\n",
"import plotly.graph_objects as go\n",
"from scipy.interpolate import splrep, BSpline \n",
"from copy import deepcopy\n",
@ -245,7 +246,7 @@
" excel_line = excel_data[excel_data.Probe.isin(['Def0Diameter'])]\n",
" beam_0_diameter = np.array([excel_line[aperture]]).astype(float)\n",
" beam_0_diameter = beam_0_diameter.item()\n",
" self.beam_diameter = defocus*2*np.tan(self.angle_corr/1000)+beam_0_diameter\n",
" self.beam_diameter = 2*defocus*np.tan(self.angle_corr/1000)+beam_0_diameter\n",
" return self.beam_diameter\n",
" \n",
" def get_0beam_diameter(self, aperture):\n",
@ -383,7 +384,7 @@
"restriction_name = Label(value = 'PAAR',layout=Layout(width='95%', grid_area='restriction_name'),)\n",
"restriction = ToggleButtons(options=[('.',False), ('..',True)], value = False, description='',icons = ['ban','check'], layout=Layout(width='95%', grid_area='camera_set2'),style = {'description_width': '80px','button_width': '48%', 'font_weight': 'bold'}, button_style='')\n",
"binning_name = Label(value = 'Binning',layout=Layout(width='95%', grid_area='binning_name'),)\n",
"binning = ToggleButtons(options=[('.',1), ('2',2), ('4',4), ('8',8), ('16',16), ('24',24), ('32',32)], value=1, description='', icons = ['ban','',''], layout=Layout(width='95%', grid_area='camera_set3'), **ali3)\n",
"binning = ToggleButtons(options=[('.',1), ('2',2), ('4',4), ('8',8), ('16',16), ('24',24), ('32',32), ('48',48)], value=1, description='', icons = ['ban','',''], layout=Layout(width='95%', grid_area='camera_set3'), **ali3)\n",
"\n",
"beam_res = Label(value = f'λ (pm) '+ str(\"{:.1f}\".format(pty.get_wavelength(beam.value)*1e12)),layout=Layout(width='auto', grid_area='sidebar1'),)\n",
"beam.observe(inte.show_wavelength, names='value') \n",
@ -456,7 +457,7 @@
" \" charts charts charts charts charts\"\n",
" '''))\n",
"\n",
"small_controls1 = GridBox(children=[header4, ctf_xaxis], layout=Layout(width='95%', grid_template_rows='auto', grid_template_columns='67% 75px 23%', grid_template_areas='''\". header4 ctxaxis \"'''))\n",
"small_controls1 = GridBox(children=[header4, ctf_xaxis], layout=Layout(width='95%', grid_template_rows='auto', grid_template_columns='47% 75px 43%', grid_template_areas='''\". header4 ctxaxis \"'''))\n",
"top_set = Button(description='',layout=Layout(width='99%', grid_area='scanning_set'), style=ButtonStyle(button_color='white', font_weight= 'bold',font_size= '16px',text_color='#0d48a1'),disabled = True)\n",
"\n",
"\n",
@ -482,7 +483,7 @@
" if overlap < 0:\n",
" overlap = 0\n",
" dose = ((matrix**2)*(dwell_time/1e6)*(current/1e12/cons.e))/((((matrix-1)*step_size_corr)**2)*100)\n",
" probe_window = (wavelength*cl_det/100)/(2*size_pixel/1e6)/1000 # now in nm\n",
" probe_window = (wavelength*cl_det/100)/(size_pixel/1e6)/1000 # now in nm\n",
" \n",
" ### ALL CAMERA LENGTHS PARAMETERS ###\n",
" pixel_covers = pty.get_pixel_covers(camera, binning) \n",
@ -497,12 +498,13 @@
" else:\n",
" ptycho_pixel_size_all = (wavelength * np.array(opt.cameralengths_eff() )) /(num_pixels/2*size_pixel/1e6)/1e4\n",
" \n",
" probe_window_all = (wavelength*np.array(opt.cameralengths_eff())/100)/(2*size_pixel/1e6)/1000 # now in nm\n",
" probe_window_all = (wavelength*np.array(opt.cameralengths_eff())/100)/(size_pixel/1e6)/1000 # now in nm\n",
" usable_probe_semi_window_all = probe_window_all/4\n",
" detector_cover_a_all = detector_cover_all/semi_angle_corr\n",
" max_defocus_all = (usable_probe_semi_window_all - pty.get_0beam_diameter(aperture)/2)/np.tan(semi_angle_corr/1000)\n",
" max_defocus_all = (usable_probe_semi_window_all)/np.tan(semi_angle_corr/1000)\n",
" # max_defocus_all = (usable_probe_semi_window_all - pty.get_0beam_diameter(aperture)/2)/np.tan(semi_angle_corr/1000) # with r0\n",
" max_defocus_all[max_defocus_all < 0] = 'nan'\n",
" \n",
" #\n",
" omega = np.linspace(1e-6,2,100) \n",
" pctf = pty.get_ssb_ctf()\n",
" apertury = opt.apertures()\n",
@ -530,7 +532,7 @@
" fig5.add_annotation(x=2.25*step_size_corr, y=-2*step_size_corr, text=str(np.round(10*beam_diameter,2))+' Å', showarrow=False, yshift=-15)\n",
" \n",
" if method == 'direct':\n",
" xx = 2*wavelength/(np.sin(semi_angle_corr*omega/1000))/100\n",
" xx = wavelength/(np.sin(semi_angle_corr*omega/1000))/100\n",
" fig5.add_trace(go.Scatter(showlegend=True, x=[-1], y=[-1],marker_size=12, marker_color='green', name='Rec step '+str(np.round(xx[-1]/3,2))+' Å')) \n",
"\n",
" if method == 'iterative':\n",
@ -548,20 +550,15 @@
" fig6 = make_subplots(specs=[[{\"secondary_y\": True}]])\n",
" fig6.update_xaxes(title_text=\"\", range=[0.5, num_pixels+0.5], tickvals = [1, num_pixels/2+0.5, num_pixels], ticktext = [1, \"Detector pixel array\", num_pixels], showticklabels=True,showgrid=True) \n",
" fig6.update_yaxes(range=[0.5, num_pixels+0.5], showticklabels=False, showgrid=False, secondary_y=False)\n",
" \n",
" fig6.add_shape(type=\"circle\",xref=\"x\", yref=\"y\",opacity=0.5, fillcolor=\"#FF7F7F\", x0=(num_pixels+1)/2-beam_diameter_pix/2, y0=(num_pixels+1)/2-beam_diameter_pix/2, x1=(num_pixels+1)/2+beam_diameter_pix/2, y1=(num_pixels+1)/2+beam_diameter_pix/2,line_color=\"red\",secondary_y=False)\n",
" fig6.add_shape(type=\"rect\",xref=\"x\", yref=\"y\",opacity=0.5, fillcolor=\"#f0f921\", x0=0.5, y0=0.5, x1=1.5, y1=1.5,line_color=\"#000004\",secondary_y=False)\n",
" \n",
" fig6.add_annotation(x=(num_pixels+1)/2-beam_diameter_pix/2, y=(num_pixels+1)/2, ax=(num_pixels+1)/2+beam_diameter_pix/2, ay=(num_pixels+1)/2, xref='x',yref='y',axref='x',ayref='y',text='', showarrow=True,arrowhead=2,arrowsize=2,arrowwidth=1,arrowcolor='black')\n",
" fig6.add_annotation(x=(num_pixels+1)/2+beam_diameter_pix/2,y=(num_pixels+1)/2, ax=(num_pixels+1)/2-beam_diameter_pix/2, ay=(num_pixels+1)/2, xref='x',yref='y',axref='x',ayref='y', text='', showarrow=True,arrowhead=2,arrowsize=2,arrowwidth=1,arrowcolor='black')\n",
" fig6.add_annotation(x=(num_pixels+1)/2, y=(num_pixels+1)/2, text=str(np.round(beam_diameter_pix,1))+\" pix\", showarrow=False, yshift=10)\n",
" fig6.add_annotation(x=1, y=1, text=str(np.round(size_pixel,2))+\" μm ≈ \" +str(np.round(pixel_angle,4))+\" mrad\", showarrow=False, xshift=70+(50/np.sqrt(num_pixels)), yshift=10+(50/np.sqrt(num_pixels)))\n",
"\n",
" fig6.add_trace(go.Scatter(showlegend=False,x=[-1], y=[-1]),secondary_y=True)\n",
" fig6.update_yaxes(title_text=\"\", range=[-1, 1], showticklabels=True, showgrid=False, tickvals = [-1, 0, 0.85], ticktext = [\"\", \"Max cover angle (mrad)\", str(np.round(detector_cover,1))], secondary_y=True) \n",
" fig6.update_yaxes(tickangle=-90)\n",
"\n",
" \n",
" fig6.update_layout(width=3.8*graph_size, height=3.1*graph_size, margin = dict(l=0.6*graph_size, r=0.48*graph_size, t=0.1*graph_size, b=0.1*graph_size))\n",
"\n",
" \n",
@ -577,10 +574,7 @@
" fig8 = go.Figure() \n",
" fig8.update_xaxes(range=[-width, width], showticklabels=False,zeroline=False)\n",
" fig8.update_yaxes(range=[-y_down, reduc*y_down], showticklabels=False,)\n",
"\n",
"\n",
" fig8.add_shape(type=\"rect\",xref=\"x\", yref=\"y\",opacity=0.05, fillcolor=\"gray\", x0=-width, y0=-y_down, x1=width, y1=reduc*y_down,line_color=\"gray\")\n",
" \n",
" fig8.add_shape(type=\"rect\",xref=\"x\", yref=\"y\",opacity=0.7, fillcolor=\"red\", x0=-100, y0=reduc*0.8*y_down, x1=100, y1=reduc*0.9*y_down,line_color=\"red\")\n",
" fig8.add_trace(go.Scatter(showlegend=False, x=[-150, -2*semi_angle, None, 2*semi_angle, 150], y=[reduc*0.8*y_down,reduc*0.8*y_down,None,reduc*0.8*y_down, reduc*0.8*y_down],mode='lines', line=dict(color='black',width=7)))\n",
" fig8.add_annotation(x=-0.7*width, y=reduc*0.8*y_down, text=\"<b>Aperture </b>\", showarrow=False, yshift=2)\n",
@ -593,7 +587,6 @@
" else:\n",
" defo = 0 \n",
"\n",
"\n",
" # Beam\n",
" fig8.add_trace(go.Scatter(showlegend=False, x=[0, 2*semi_angle, 0, 0], y=[defo*y_down, reduc*0.8*y_down, reduc*0.8*y_down, defo*y_down], mode='lines',fill=\"toself\", fillcolor=\"#FF7F7F\", opacity=0.7,line=dict(color='#FF7F7F',width=1)))\n",
" fig8.add_trace(go.Scatter(showlegend=False, x=[0, 0, -2*semi_angle, 0], y=[defo*y_down, reduc*0.8*y_down, reduc*0.8*y_down, defo*y_down],mode='lines', fill=\"toself\", fillcolor=\"red\", opacity=0.7,line=dict(color='red',width=1)))\n",
@ -670,8 +663,8 @@
" ### PROBE ##########################################\n",
" fig = go.Figure() \n",
" fig.update_yaxes(title_text=\"Contrast transfer func.\")\n",
" xx = wavelength/(np.sin(semi_angle_corr*omega/1000))/100\n",
" # xx = 2*wavelength/(np.sin(semi_angle_corr*omega/1000))/100\n",
"\n",
" xx = wavelength/(np.sin(semi_angle_corr*omega/1000))/100 # Full pitch size\n",
" \n",
" if ctf_xaxis == 'α': \n",
" fig.add_trace(go.Scatter(x=omega, y=pctf, marker_color='red', name=str(np.round(semi_angle_corr,2))+ ' mrad',))\n",
@ -686,25 +679,30 @@
"\n",
" elif ctf_xaxis == 'A':\n",
" for x in apertury:\n",
" d = wavelength/(np.sin(pty.get_angle_corr(x)*omega/1000))/100\n",
" d = wavelength/(np.sin(pty.get_angle_corr(x)*omega/1000))/100 # Full pitch size\n",
" fig.add_trace(go.Scatter(showlegend=False, x=d, y=pctf, marker_color='gray', name='SSB-CTF',))\n",
"\n",
" # fig.add_trace(go.Scatter(x=xx, y=pctf, marker_color='red', name=str(np.round(semi_angle_corr,2))+ ' mrad',))\n",
"\n",
" # SmB6\n",
" fig.add_trace(go.Scatter(x=[4.13, 4.13], y=[0, 0.41], marker_color='green', ))\n",
" fig.add_trace(go.Scatter(x=[2.92, 2.92], y=[0, 0.41], marker_color='green', ))\n",
" fig.add_trace(go.Scatter(showlegend=False,x=[4.13, 4.13], y=[0, 0.41], marker_color='green', ))\n",
" fig.add_trace(go.Scatter(showlegend=False,x=[2.92, 2.92], y=[0, 0.41], marker_color='green', ))\n",
"\n",
" fig.add_trace(go.Scatter(x=[1.71, 1.71], y=[0, 0.41], marker_color='blue', ))\n",
" fig.add_trace(go.Scatter(x=[1.21, 1.21], y=[0, 0.41], marker_color='blue', ))\n",
" fig.add_trace(go.Scatter(showlegend=False,x=[1.71, 1.71], y=[0, 0.41], marker_color='blue', ))\n",
" fig.add_trace(go.Scatter(showlegend=False,x=[1.21, 1.21], y=[0, 0.41], marker_color='blue', ))\n",
"\n",
" \n",
" fig.update_xaxes(title_text=\"Real space distance (Å)\", range=[-0.5, 2.5], type=\"log\", zeroline=False)\n",
" fig.update_xaxes(title_text=\"Real space periode (Å)\", range=[-0.25, 2.5], type=\"log\", zeroline=False)\n",
"\n",
" # fig.update_layout(legend=dict(orientation=\"h\",yanchor=\"bottom\",y=0.75,xanchor=\"right\",x=1))\n",
" # fig3.update_layout(title={'text': \"CTF\",'y':0.93, 'x':0.12,'xanchor': 'left','yanchor': 'top'})\n",
" fig.update_layout(width=6*graph_size, height=2.5*graph_size, margin = dict(l=1.3*graph_size, r=0.3*graph_size, t=0.0*graph_size, b=0.3*graph_size))\n",
" \n",
" \n",
" fig.update_layout(width=5*graph_size, height=2.5*graph_size, margin = dict(l=1.3*graph_size, r=0.3*graph_size, t=0.0*graph_size, b=0.3*graph_size))\n",
" fig.update_layout(width=5*graph_size, height=2.5*graph_size, margin = dict(l=1.3*graph_size, r=0.3*graph_size, t=0.0*graph_size, b=0.3*graph_size))\n",
"\n",
"\n",
"\n",
"\n",
" ### CAMERA LENGTH GRAPH ##########################################\n",
" fig4 = make_subplots(specs=[[{\"secondary_y\": True}]])\n",
" fig4.add_trace(go.Scatter(showlegend=False, x=opt.cameralengths(), y=detector_cover_all, marker_color='gray'), secondary_y=False,)\n",
@ -772,20 +770,64 @@
"\n",
" case 'A':\n",
" for x in apertury:\n",
" d = 2*wavelength/(np.sin(pty.get_angle_corr(x)*xnew/1000))/100\n",
" d = wavelength/(np.sin(pty.get_angle_corr(x)*xnew/1000))/100\n",
" fig.add_trace(go.Scatter(showlegend=False, x=d, y=pctf_new, marker_color='gray', name='CTF',))\n",
" \n",
" xx = 2*wavelength/(np.sin(semi_angle_corr*xnew/1000))/100\n",
" xx = wavelength/(np.sin(semi_angle_corr*xnew/1000))/100\n",
" fig.add_trace(go.Scatter(x=xx, y=pctf_new, marker_color='red', name=str(np.round(semi_angle_corr,2))+ ' mrad',))\n",
" fig.update_xaxes(title_text=\"Real space distance (Å)\",range=[-0.5, 2], type=\"log\", zeroline=False) # \n",
"\n",
" fig.update_layout(legend=dict(orientation=\"h\",yanchor=\"bottom\",y=0.8,xanchor=\"right\",x=0.95))\n",
" # fig3.update_layout(title={'text': \"CTF\",'y':0.93, 'x':0.12,'xanchor': 'left','yanchor': 'top'})\n",
" fig.update_layout(width=9.25*graph_size, height=2.2*graph_size, margin = dict(l=1.3*graph_size, r=0.3*graph_size, t=0.0*graph_size, b=0.6*graph_size))\n",
" fig.update_layout(width=5*graph_size, height=2.2*graph_size, margin = dict(l=1.3*graph_size, r=0.3*graph_size, t=0.0*graph_size, b=0.45*graph_size))\n",
" \n",
" checks = VBox([Label('Final checks'),check1, check2, check3]) \n",
" checks.layout = Layout(border='dashed 1px gray', margin='0px 30px 20px 120px', padding='5px 5px 5px 5px')\n",
" \n",
" ### INTENSIY DISTRIBUTION ##################################\n",
" fig9 = go.Figure() \n",
" fig9.update_yaxes(title_text=\"Probe intensity [-]\")\n",
" fig9.update_xaxes(title_text=\"Sample plane (nm)\", range=[-4*step_size_corr, 4*step_size_corr], zeroline=False)\n",
"\n",
" # define constants\n",
" mu = 0\n",
" # sigma = beam_diameter/(2*np.sqrt(8*np.log(2))) # WHAT ABOUT THE FORMULA?????? SHOULD BE beam_diameter/np.sqrt(8*np.log(2)) IS BEAM DEFINED BY DIAMETER +-2 SIGMA?\n",
" sigma = beam_diameter/4 # WHAT ABOUT THE FORMULA?????? SHOULD BE beam_diameter/np.sqrt(8*np.log(2)) IS BEAM DEFINED BY DIAMETER +-2 SIGMA?\n",
" # sigma = beam_diameter/np.sqrt(8*np.log(2)) # WHAT ABOUT THE FORMULA?????? SHOULD BE beam_diameter/np.sqrt(8*np.log(2)) IS BEAM DEFINED BY DIAMETER +-2 SIGMA?\n",
" # sigma = beam_diameter/np.sqrt(8*np.log(2)) # WHAT ABOUT THE FORMULA?????? SHOULD BE beam_diameter/np.sqrt(8*np.log(2)) IS BEAM DEFINED BY DIAMETER +-2 SIGMA?\n",
" x = np.linspace(-4*step_size_corr, 4*step_size_corr, 300)\n",
"\n",
" possitions = 10\n",
" yy = np.zeros(len(x))\n",
" for i in np.linspace(-possitions,possitions,2*possitions+1).astype(int):\n",
" \n",
" y = norm.pdf(x,mu-i*step_size_corr,sigma)\n",
" yy = yy+y\n",
" if i == 0:\n",
" fig9.add_trace(go.Scatter(x=x, y=y, marker_color='gray',name='Individual probes')) \n",
" fig9.add_trace(go.Scatter(showlegend=False,x=x, y=y, marker_color='gray')) \n",
" \n",
" fig9.add_trace(go.Scatter(x=x, y=yy, marker_color='red', name='Sumed probes'))\n",
" fig9.add_annotation(x=0, y=np.max(yy),text=\"Hilliness \"+str(np.round( ((np.max(yy[100:200])-np.min(yy[100:200]))/np.max(yy[100:200])*100),1))+\" %\", showarrow=False,align= 'left', yshift=15)\n",
" fig9.update_layout(legend=dict(orientation=\"v\",yanchor=\"bottom\",y=0.1,xanchor=\"right\",x=0.95))\n",
" fig9.update_layout(width=5*graph_size, height=2.2*graph_size, margin = dict(l=0.5*graph_size, r=1*graph_size, t=0.0*graph_size, b=0.0*graph_size))\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
" \n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
" \n",
" ### PROBE WINDOW ##########################################\n",
" if beam_diameter < probe_window/2:\n",
@ -814,7 +856,7 @@
" fig7.add_shape(type=\"circle\",xref=\"x\", yref=\"y\", opacity=0.4, fillcolor=color, x0=probe_window/2-beam_diameter/2, y0=probe_window/2-beam_diameter/2, x1=probe_window/2+beam_diameter/2, y1=probe_window/2+beam_diameter/2, line_color=color,)\n",
"\n",
" \n",
" fig7.update_xaxes(title_text=\"Probe window (nm)\", range=[0, probe_window], tickvals = [0, probe_window/4, probe_window/2, 3*probe_window/4, probe_window], ticktext = [0, np.round(probe_window/4,2),np.round(probe_window/4,2),np.round(probe_window/2,2),np.round(3*probe_window/4,2),np.round(probe_window,2)])\n",
" fig7.update_xaxes(title_text=\"Probe window (nm)\", range=[0, probe_window], tickvals = [0, probe_window/4, probe_window/2, 3*probe_window/4, probe_window], ticktext = [0, np.round(probe_window/4,2),np.round(probe_window/2,2),np.round(3*probe_window/4,2),np.round(probe_window,2)])\n",
" fig7.update_yaxes(range=[0, probe_window], tickvals = [0, probe_window/4, probe_window/2, 3*probe_window/4, probe_window], showticklabels=False,)\n",
" fig7.update_yaxes(range=[0, probe_window], showticklabels=False,)\n",
" fig7.update_yaxes(range=[0, probe_window], showticklabels=False,)\n",
@ -884,10 +926,10 @@
" total = VBox([go.FigureWidget(fig8),go.FigureWidget(fig6)])\n",
" case 'dedic':\n",
" sample_overlap = HBox([go.FigureWidget(fig5), go.FigureWidget(fig7)]) \n",
" total = VBox([HBox([go.FigureWidget(fig)]), sample_overlap, cltab,checks]) \n",
" total = VBox([HBox([go.FigureWidget(fig),go.FigureWidget(fig9)]), sample_overlap, cltab,checks]) \n",
" case _:\n",
" sample_overlap = HBox([go.FigureWidget(fig5), go.FigureWidget(fig7)]) \n",
" right_column = VBox([HBox([go.FigureWidget(fig)]), sample_overlap, cltab,checks]) \n",
" right_column = VBox([HBox([go.FigureWidget(fig),go.FigureWidget(fig9)]), sample_overlap, cltab,checks]) \n",
" left_column = VBox([go.FigureWidget(fig8), go.FigureWidget(fig6)]) \n",
" total = HBox([left_column, right_column]) \n",
" \n",
@ -900,6 +942,27 @@
"gui = interactive_output(ptycho_interact, {\"beam\": beam, \"aperture\": aperture,\"aperture_res\": aperture_res,\"aperture_res2\": aperture_res2, \"probe\": probe, \"cl\": cl, \"matrix\": matrix, \"defocus\": defocus, \"mag\": mag, \"camera\": camera,\n",
" \"binning\": binning, \"dwell_time\": dwell_time, \"restriction\": restriction, \"method\": method, \"ctf_xaxis\": ctf_xaxis, \"graph_size\": graph_size,\"chart\": chart,\"cl_checks\": cl_checks}) \n"
]
},
{
"cell_type": "code",
"execution_count": 17,
"id": "5a35407f-11fd-4214-940e-ecdf089cf2c2",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"2.3548200450309493"
]
},
"execution_count": 17,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"np.sqrt(8*np.log(2)) "
]
}
],
"metadata": {

Binary file not shown.

View File

@ -30,14 +30,14 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": 63,
"id": "7937f054-fcd0-4e67-a20f-7696f5903a94",
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "f5d3146d31ae4954b265e5d673e86d12",
"model_id": "37e8ce59eb9944afa169fd1047ace692",
"version_major": 2,
"version_minor": 0
},
@ -81,7 +81,15 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": null,
"id": "de350192-85ae-4d38-8ed3-14ad43843e01",
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": 62,
"id": "3ca2e3fd-4e61-4d4c-9d58-4b72f16999dc",
"metadata": {},
"outputs": [],
@ -92,6 +100,7 @@
"\n",
"import numpy as np\n",
"import scipy.constants as cons\n",
"from scipy.stats import norm\n",
"import plotly.graph_objects as go\n",
"from scipy.interpolate import splrep, BSpline \n",
"from copy import deepcopy\n",
@ -245,7 +254,7 @@
" excel_line = excel_data[excel_data.Probe.isin(['Def0Diameter'])]\n",
" beam_0_diameter = np.array([excel_line[aperture]]).astype(float)\n",
" beam_0_diameter = beam_0_diameter.item()\n",
" self.beam_diameter = defocus*2*np.tan(self.angle_corr/1000)+beam_0_diameter\n",
" self.beam_diameter = 2*defocus*np.tan(self.angle_corr/1000)+beam_0_diameter\n",
" return self.beam_diameter\n",
" \n",
" def get_0beam_diameter(self, aperture):\n",
@ -383,7 +392,7 @@
"restriction_name = Label(value = 'PAAR',layout=Layout(width='95%', grid_area='restriction_name'),)\n",
"restriction = ToggleButtons(options=[('.',False), ('..',True)], value = False, description='',icons = ['ban','check'], layout=Layout(width='95%', grid_area='camera_set2'),style = {'description_width': '80px','button_width': '48%', 'font_weight': 'bold'}, button_style='')\n",
"binning_name = Label(value = 'Binning',layout=Layout(width='95%', grid_area='binning_name'),)\n",
"binning = ToggleButtons(options=[('.',1), ('2',2), ('4',4), ('8',8), ('16',16), ('24',24), ('32',32)], value=1, description='', icons = ['ban','',''], layout=Layout(width='95%', grid_area='camera_set3'), **ali3)\n",
"binning = ToggleButtons(options=[('.',1), ('2',2), ('4',4), ('8',8), ('16',16), ('24',24), ('32',32), ('48',48)], value=1, description='', icons = ['ban','',''], layout=Layout(width='95%', grid_area='camera_set3'), **ali3)\n",
"\n",
"beam_res = Label(value = f'λ (pm) '+ str(\"{:.1f}\".format(pty.get_wavelength(beam.value)*1e12)),layout=Layout(width='auto', grid_area='sidebar1'),)\n",
"beam.observe(inte.show_wavelength, names='value') \n",
@ -456,7 +465,7 @@
" \" charts charts charts charts charts\"\n",
" '''))\n",
"\n",
"small_controls1 = GridBox(children=[header4, ctf_xaxis], layout=Layout(width='95%', grid_template_rows='auto', grid_template_columns='67% 75px 23%', grid_template_areas='''\". header4 ctxaxis \"'''))\n",
"small_controls1 = GridBox(children=[header4, ctf_xaxis], layout=Layout(width='95%', grid_template_rows='auto', grid_template_columns='47% 75px 43%', grid_template_areas='''\". header4 ctxaxis \"'''))\n",
"top_set = Button(description='',layout=Layout(width='99%', grid_area='scanning_set'), style=ButtonStyle(button_color='white', font_weight= 'bold',font_size= '16px',text_color='#0d48a1'),disabled = True)\n",
"\n",
"\n",
@ -482,7 +491,7 @@
" if overlap < 0:\n",
" overlap = 0\n",
" dose = ((matrix**2)*(dwell_time/1e6)*(current/1e12/cons.e))/((((matrix-1)*step_size_corr)**2)*100)\n",
" probe_window = (wavelength*cl_det/100)/(2*size_pixel/1e6)/1000 # now in nm\n",
" probe_window = (wavelength*cl_det/100)/(size_pixel/1e6)/1000 # now in nm\n",
" \n",
" ### ALL CAMERA LENGTHS PARAMETERS ###\n",
" pixel_covers = pty.get_pixel_covers(camera, binning) \n",
@ -497,12 +506,13 @@
" else:\n",
" ptycho_pixel_size_all = (wavelength * np.array(opt.cameralengths_eff() )) /(num_pixels/2*size_pixel/1e6)/1e4\n",
" \n",
" probe_window_all = (wavelength*np.array(opt.cameralengths_eff())/100)/(2*size_pixel/1e6)/1000 # now in nm\n",
" probe_window_all = (wavelength*np.array(opt.cameralengths_eff())/100)/(size_pixel/1e6)/1000 # now in nm\n",
" usable_probe_semi_window_all = probe_window_all/4\n",
" detector_cover_a_all = detector_cover_all/semi_angle_corr\n",
" max_defocus_all = (usable_probe_semi_window_all - pty.get_0beam_diameter(aperture)/2)/np.tan(semi_angle_corr/1000)\n",
" max_defocus_all = (usable_probe_semi_window_all)/np.tan(semi_angle_corr/1000)\n",
" # max_defocus_all = (usable_probe_semi_window_all - pty.get_0beam_diameter(aperture)/2)/np.tan(semi_angle_corr/1000) # with r0\n",
" max_defocus_all[max_defocus_all < 0] = 'nan'\n",
" \n",
" #\n",
" omega = np.linspace(1e-6,2,100) \n",
" pctf = pty.get_ssb_ctf()\n",
" apertury = opt.apertures()\n",
@ -510,57 +520,123 @@
"\n",
" ### SAMPLE PLANE ##########################################\n",
" yyy = np.append(np.linspace(0,overlap,100), 200)\n",
" wid = np.array([-2, -1, 0, 1, 2]) * step_size_corr\n",
"\n",
"\n",
" beam_pos = 5\n",
" wid = np.linspace(-beam_pos/2,beam_pos/2,beam_pos+1) * step_size_corr\n",
"\n",
"\n",
" fov_show = 0.5 # nm\n",
" \n",
" fig5 = make_subplots(specs=[[{\"secondary_y\": True}]])\n",
" fig5.update_xaxes(title_text=\"Sample plane (nm)\", range=[-4*step_size_corr, 4*step_size_corr], showgrid=False, zeroline=False)\n",
" fig5.update_yaxes(range=[-4*step_size_corr, 4*step_size_corr],showgrid=False, showticklabels=False)\n",
"\n",
" print(step_size_corr)\n",
" fig5.update_xaxes(title_text=\"Sample plane (nm)\", range=[-fov_show/2, fov_show/2], showgrid=False, zeroline=False)\n",
" fig5.update_yaxes(range=[-fov_show/2, fov_show/2],showgrid=False, showticklabels=False)\n",
" \n",
" for x in range(len(wid)):\n",
" fig5.add_trace(go.Scatter(showlegend=False, x=wid, y=np.ones(len(wid))*wid[x], marker_color='blue'),secondary_y=False)\n",
" fig5.add_trace(go.Scatter(showlegend=False, x=wid, y=np.ones(len(wid))*wid[x], marker_color='black'),secondary_y=False)\n",
" \n",
" for x in range(len(wid)): \n",
" for y in range(len(wid)): \n",
" fig5.add_shape(type=\"circle\",xref=\"x\", yref=\"y\", opacity=0.1, fillcolor=\"#FF7F7F\",name=False, x0=wid[x]-beam_diameter/2, y0=wid[y]-beam_diameter/2, x1=wid[x]+beam_diameter/2, y1=wid[y]+beam_diameter/2, line_color=\"red\",secondary_y=False)\n",
" \n",
" fig5.add_annotation(x=-1*step_size_corr, y=-2*step_size_corr, ax=-2*step_size_corr, ay=-2*step_size_corr, xref='x',yref='y',axref='x',ayref='y',text='', showarrow=True,arrowhead=2,arrowsize=2,arrowwidth=1,arrowcolor='black')\n",
" fig5.add_annotation(x=-2*step_size_corr, y=-1*step_size_corr, ax=-2*step_size_corr, ay=-2*step_size_corr, xref='x',yref='y',axref='x',ayref='y',text='', showarrow=True,arrowhead=2,arrowsize=2,arrowwidth=1,arrowcolor='black')\n",
" fig5.add_annotation(x=-1.25*step_size_corr, y=-1.5*step_size_corr, text=str(np.round(10*step_size_corr,3))+' Å', showarrow=False, yshift=0)\n",
" fig5.add_annotation(x=2*step_size_corr-0.75*beam_diameter/2, y=-2*step_size_corr-0.75*beam_diameter/2, ax=2*step_size_corr, ay=-2*step_size_corr,xref='x',yref='y',axref='x',ayref='y',text='', showarrow=True,arrowhead=2,arrowsize=2,arrowwidth=1,arrowcolor='black')\n",
" fig5.add_annotation(x=2*step_size_corr+0.75*beam_diameter/2, y=-2*step_size_corr+0.75*beam_diameter/2, ax=2*step_size_corr, ay=-2*step_size_corr,xref='x',yref='y',axref='x',ayref='y',text='', showarrow=True,arrowhead=2,arrowsize=2,arrowwidth=1,arrowcolor='black')\n",
" fig5.add_annotation(x=2.25*step_size_corr, y=-2*step_size_corr, text=str(np.round(10*beam_diameter,2))+' Å', showarrow=False, yshift=-15)\n",
" # fig5.add_annotation(x=-1*step_size_corr, y=-2*step_size_corr, ax=-2*step_size_corr, ay=-2*step_size_corr, xref='x',yref='y',axref='x',ayref='y',text='', showarrow=True,arrowhead=2,arrowsize=2,arrowwidth=1,arrowcolor='black')\n",
" # fig5.add_annotation(x=-2*step_size_corr, y=-1*step_size_corr, ax=-2*step_size_corr, ay=-2*step_size_corr, xref='x',yref='y',axref='x',ayref='y',text='', showarrow=True,arrowhead=2,arrowsize=2,arrowwidth=1,arrowcolor='black')\n",
" # fig5.add_annotation(x=-1.25*step_size_corr, y=-1.5*step_size_corr, text=str(np.round(10*step_size_corr,3))+' Å', showarrow=False, yshift=0)\n",
" # fig5.add_annotation(x=2*step_size_corr-0.75*beam_diameter/2, y=-2*step_size_corr-0.75*beam_diameter/2, ax=2*step_size_corr, ay=-2*step_size_corr,xref='x',yref='y',axref='x',ayref='y',text='', showarrow=True,arrowhead=2,arrowsize=2,arrowwidth=1,arrowcolor='black')\n",
" # fig5.add_annotation(x=2*step_size_corr+0.75*beam_diameter/2, y=-2*step_size_corr+0.75*beam_diameter/2, ax=2*step_size_corr, ay=-2*step_size_corr,xref='x',yref='y',axref='x',ayref='y',text='', showarrow=True,arrowhead=2,arrowsize=2,arrowwidth=1,arrowcolor='black')\n",
" # fig5.add_annotation(x=2.25*step_size_corr, y=-2*step_size_corr, text=str(np.round(10*beam_diameter,2))+' Å', showarrow=False, yshift=-15)\n",
" \n",
" if method == 'direct':\n",
" xx = 2*wavelength/(np.sin(semi_angle_corr*omega/1000))/100\n",
" xx = wavelength/(np.sin(semi_angle_corr*omega/1000))/100\n",
" fig5.add_trace(go.Scatter(showlegend=True, x=[-1], y=[-1],marker_size=12, marker_color='green', name='Rec step '+str(np.round(xx[-1]/3,2))+' Å')) \n",
"\n",
" if method == 'iterative':\n",
" fig5.add_trace(go.Scatter(showlegend=True, x=[-1], y=[-1],marker_size=12, marker_color='#FF7F7F', name='Beam ⌀ '+str(np.round(10*beam_diameter,2))+' Å', opacity = 0)) \n",
"\n",
" fig5.update_layout(legend=dict(orientation=\"v\",yanchor=\"bottom\",y=1.0,xanchor=\"right\",x=0.9))\n",
" fig5.add_trace(go.Scatter(showlegend=False, x = -4*step_size_corr*np.ones(len(yyy)), y=yyy, opacity=1,mode='markers',marker_symbol = \"triangle-down\",marker=dict(size=20, color=yyy, colorscale='rainbow_r', showscale=False)),secondary_y=True) \n",
" fig5.add_trace(go.Scatter(showlegend=False, x = -fov_show/2*np.ones(len(yyy)), y=yyy, opacity=1,mode='markers',marker_symbol = \"triangle-down\",marker=dict(size=20, color=yyy, colorscale='rainbow_r', showscale=False)),secondary_y=True) \n",
" fig5.update_yaxes(range=[0, 100], showgrid=False, showticklabels=False, secondary_y=True)\n",
" fig5.update_yaxes(title_text=\"Overlap %\", showgrid=False, showticklabels=True, tickvals = [-4*step_size_corr, -2*step_size_corr, 0, 2*step_size_corr, 4*step_size_corr],ticktext = ['0', '25', '50', '75', '100'], secondary_y=False)\n",
" fig5.update_yaxes(title_text=\"Overlap %\", showgrid=False, showticklabels=True, tickvals = [-fov_show/2, -fov_show/4, 0, fov_show/4, fov_show/2],ticktext = ['0', '25', '50', '75', '100'], secondary_y=False)\n",
" fig5.update_layout(title={'text': \"Sample\",'y': 0.975, 'x': 0.30,'xanchor': 'left','yanchor': 'top'})\n",
" fig5.update_layout(width=5.25*graph_size, height=3.9*graph_size, margin =dict(l=1.3*graph_size, r=0.3*graph_size, t=0.1*graph_size, b=0))\n",
"\n",
" fig5.update_layout(legend=dict(orientation=\"v\",yanchor=\"bottom\",y=1.01,xanchor=\"right\",x=0.9))\n",
" fig5.update_layout(plot_bgcolor='white')\n",
" fig5.update_xaxes(mirror=True,ticks='outside',showline=True,linecolor='black',gridcolor='lightgrey')\n",
" fig5.update_yaxes(mirror=True,ticks='inside',showline=True,linecolor='black',gridcolor='lightgrey')\n",
" fig5.update_yaxes(title_font_color=\"#000000\")\n",
" fig5.update_xaxes(title_font_color=\"#000000\")\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
" \n",
" # yyy = np.append(np.linspace(0,overlap,100), 200)\n",
" # wid = np.array([-2, -1, 0, 1, 2]) * step_size_corr\n",
" # fig5 = make_subplots(specs=[[{\"secondary_y\": True}]])\n",
" # fig5.update_xaxes(title_text=\"Sample plane (nm)\", range=[-4*step_size_corr, 4*step_size_corr], showgrid=False, zeroline=False)\n",
" # fig5.update_yaxes(range=[-4*step_size_corr, 4*step_size_corr],showgrid=False, showticklabels=False)\n",
" \n",
" # for x in range(len(wid)):\n",
" # fig5.add_trace(go.Scatter(showlegend=False, x=wid, y=np.ones(len(wid))*wid[x], marker_color='blue'),secondary_y=False)\n",
" \n",
" # for x in range(len(wid)): \n",
" # for y in range(len(wid)): \n",
" # fig5.add_shape(type=\"circle\",xref=\"x\", yref=\"y\", opacity=0.1, fillcolor=\"#FF7F7F\",name=False, x0=wid[x]-beam_diameter/2, y0=wid[y]-beam_diameter/2, x1=wid[x]+beam_diameter/2, y1=wid[y]+beam_diameter/2, line_color=\"red\",secondary_y=False)\n",
" \n",
" # fig5.add_annotation(x=-1*step_size_corr, y=-2*step_size_corr, ax=-2*step_size_corr, ay=-2*step_size_corr, xref='x',yref='y',axref='x',ayref='y',text='', showarrow=True,arrowhead=2,arrowsize=2,arrowwidth=1,arrowcolor='black')\n",
" # fig5.add_annotation(x=-2*step_size_corr, y=-1*step_size_corr, ax=-2*step_size_corr, ay=-2*step_size_corr, xref='x',yref='y',axref='x',ayref='y',text='', showarrow=True,arrowhead=2,arrowsize=2,arrowwidth=1,arrowcolor='black')\n",
" # fig5.add_annotation(x=-1.25*step_size_corr, y=-1.5*step_size_corr, text=str(np.round(10*step_size_corr,3))+' Å', showarrow=False, yshift=0)\n",
" # fig5.add_annotation(x=2*step_size_corr-0.75*beam_diameter/2, y=-2*step_size_corr-0.75*beam_diameter/2, ax=2*step_size_corr, ay=-2*step_size_corr,xref='x',yref='y',axref='x',ayref='y',text='', showarrow=True,arrowhead=2,arrowsize=2,arrowwidth=1,arrowcolor='black')\n",
" # fig5.add_annotation(x=2*step_size_corr+0.75*beam_diameter/2, y=-2*step_size_corr+0.75*beam_diameter/2, ax=2*step_size_corr, ay=-2*step_size_corr,xref='x',yref='y',axref='x',ayref='y',text='', showarrow=True,arrowhead=2,arrowsize=2,arrowwidth=1,arrowcolor='black')\n",
" # fig5.add_annotation(x=2.25*step_size_corr, y=-2*step_size_corr, text=str(np.round(10*beam_diameter,2))+' Å', showarrow=False, yshift=-15)\n",
" \n",
" # if method == 'direct':\n",
" # xx = wavelength/(np.sin(semi_angle_corr*omega/1000))/100\n",
" # fig5.add_trace(go.Scatter(showlegend=True, x=[-1], y=[-1],marker_size=12, marker_color='green', name='Rec step '+str(np.round(xx[-1]/3,2))+' Å')) \n",
"\n",
" # if method == 'iterative':\n",
" # fig5.add_trace(go.Scatter(showlegend=True, x=[-1], y=[-1],marker_size=12, marker_color='#FF7F7F', name='Beam ⌀ '+str(np.round(10*beam_diameter,2))+' Å', opacity = 0)) \n",
"\n",
" # fig5.update_layout(legend=dict(orientation=\"v\",yanchor=\"bottom\",y=1.0,xanchor=\"right\",x=0.9))\n",
" # fig5.add_trace(go.Scatter(showlegend=False, x = -4*step_size_corr*np.ones(len(yyy)), y=yyy, opacity=1,mode='markers',marker_symbol = \"triangle-down\",marker=dict(size=20, color=yyy, colorscale='rainbow_r', showscale=False)),secondary_y=True) \n",
" # fig5.update_yaxes(range=[0, 100], showgrid=False, showticklabels=False, secondary_y=True)\n",
" # fig5.update_yaxes(title_text=\"Overlap %\", showgrid=False, showticklabels=True, tickvals = [-4*step_size_corr, -2*step_size_corr, 0, 2*step_size_corr, 4*step_size_corr],ticktext = ['0', '25', '50', '75', '100'], secondary_y=False)\n",
" # fig5.update_layout(title={'text': \"Sample\",'y': 0.975, 'x': 0.30,'xanchor': 'left','yanchor': 'top'})\n",
" # fig5.update_layout(width=5.25*graph_size, height=3.9*graph_size, margin =dict(l=1.3*graph_size, r=0.3*graph_size, t=0.1*graph_size, b=0))\n",
"\n",
"\n",
" # fig5.update_layout(legend=dict(orientation=\"v\",yanchor=\"bottom\",y=1.01,xanchor=\"right\",x=0.9))\n",
" # fig5.update_layout(plot_bgcolor='white')\n",
" # fig5.update_xaxes(mirror=True,ticks='outside',showline=True,linecolor='black',gridcolor='lightgrey')\n",
" # fig5.update_yaxes(mirror=True,ticks='inside',showline=True,linecolor='black',gridcolor='lightgrey')\n",
" # fig5.update_yaxes(title_font_color=\"#000000\")\n",
" # fig5.update_xaxes(title_font_color=\"#000000\")\n",
"\n",
" \n",
" ### DETECTOR PLANE ##########################################\n",
" fig6 = make_subplots(specs=[[{\"secondary_y\": True}]])\n",
" fig6.update_xaxes(title_text=\"\", range=[0.5, num_pixels+0.5], tickvals = [1, num_pixels/2+0.5, num_pixels], ticktext = [1, \"Detector pixel array\", num_pixels], showticklabels=True,showgrid=True) \n",
" fig6.update_yaxes(range=[0.5, num_pixels+0.5], showticklabels=False, showgrid=False, secondary_y=False)\n",
" \n",
" fig6.add_shape(type=\"circle\",xref=\"x\", yref=\"y\",opacity=0.5, fillcolor=\"#FF7F7F\", x0=(num_pixels+1)/2-beam_diameter_pix/2, y0=(num_pixels+1)/2-beam_diameter_pix/2, x1=(num_pixels+1)/2+beam_diameter_pix/2, y1=(num_pixels+1)/2+beam_diameter_pix/2,line_color=\"red\",secondary_y=False)\n",
" fig6.add_shape(type=\"rect\",xref=\"x\", yref=\"y\",opacity=0.5, fillcolor=\"#f0f921\", x0=0.5, y0=0.5, x1=1.5, y1=1.5,line_color=\"#000004\",secondary_y=False)\n",
" \n",
" fig6.add_annotation(x=(num_pixels+1)/2-beam_diameter_pix/2, y=(num_pixels+1)/2, ax=(num_pixels+1)/2+beam_diameter_pix/2, ay=(num_pixels+1)/2, xref='x',yref='y',axref='x',ayref='y',text='', showarrow=True,arrowhead=2,arrowsize=2,arrowwidth=1,arrowcolor='black')\n",
" fig6.add_annotation(x=(num_pixels+1)/2+beam_diameter_pix/2,y=(num_pixels+1)/2, ax=(num_pixels+1)/2-beam_diameter_pix/2, ay=(num_pixels+1)/2, xref='x',yref='y',axref='x',ayref='y', text='', showarrow=True,arrowhead=2,arrowsize=2,arrowwidth=1,arrowcolor='black')\n",
" fig6.add_annotation(x=(num_pixels+1)/2, y=(num_pixels+1)/2, text=str(np.round(beam_diameter_pix,1))+\" pix\", showarrow=False, yshift=10)\n",
" fig6.add_annotation(x=1, y=1, text=str(np.round(size_pixel,2))+\" μm ≈ \" +str(np.round(pixel_angle,4))+\" mrad\", showarrow=False, xshift=70+(50/np.sqrt(num_pixels)), yshift=10+(50/np.sqrt(num_pixels)))\n",
"\n",
" fig6.add_trace(go.Scatter(showlegend=False,x=[-1], y=[-1]),secondary_y=True)\n",
" fig6.update_yaxes(title_text=\"\", range=[-1, 1], showticklabels=True, showgrid=False, tickvals = [-1, 0, 0.85], ticktext = [\"\", \"Max cover angle (mrad)\", str(np.round(detector_cover,1))], secondary_y=True) \n",
" fig6.update_yaxes(tickangle=-90)\n",
"\n",
" fig6.update_layout(plot_bgcolor='white')\n",
" fig6.update_xaxes(mirror=True,ticks='outside',showline=True,linecolor='black',gridcolor='lightgrey')\n",
" fig6.update_yaxes(mirror=True,ticks='inside',showline=True,linecolor='black',gridcolor='lightgrey')\n",
" fig6.update_yaxes(title_font_color=\"#000000\")\n",
" fig6.update_xaxes(title_font_color=\"#000000\")\n",
" \n",
" fig6.update_layout(width=3.8*graph_size, height=3.1*graph_size, margin = dict(l=0.6*graph_size, r=0.48*graph_size, t=0.1*graph_size, b=0.1*graph_size))\n",
"\n",
@ -577,10 +653,7 @@
" fig8 = go.Figure() \n",
" fig8.update_xaxes(range=[-width, width], showticklabels=False,zeroline=False)\n",
" fig8.update_yaxes(range=[-y_down, reduc*y_down], showticklabels=False,)\n",
"\n",
"\n",
" fig8.add_shape(type=\"rect\",xref=\"x\", yref=\"y\",opacity=0.05, fillcolor=\"gray\", x0=-width, y0=-y_down, x1=width, y1=reduc*y_down,line_color=\"gray\")\n",
" \n",
" fig8.add_shape(type=\"rect\",xref=\"x\", yref=\"y\",opacity=0.7, fillcolor=\"red\", x0=-100, y0=reduc*0.8*y_down, x1=100, y1=reduc*0.9*y_down,line_color=\"red\")\n",
" fig8.add_trace(go.Scatter(showlegend=False, x=[-150, -2*semi_angle, None, 2*semi_angle, 150], y=[reduc*0.8*y_down,reduc*0.8*y_down,None,reduc*0.8*y_down, reduc*0.8*y_down],mode='lines', line=dict(color='black',width=7)))\n",
" fig8.add_annotation(x=-0.7*width, y=reduc*0.8*y_down, text=\"<b>Aperture </b>\", showarrow=False, yshift=2)\n",
@ -593,7 +666,6 @@
" else:\n",
" defo = 0 \n",
"\n",
"\n",
" # Beam\n",
" fig8.add_trace(go.Scatter(showlegend=False, x=[0, 2*semi_angle, 0, 0], y=[defo*y_down, reduc*0.8*y_down, reduc*0.8*y_down, defo*y_down], mode='lines',fill=\"toself\", fillcolor=\"#FF7F7F\", opacity=0.7,line=dict(color='#FF7F7F',width=1)))\n",
" fig8.add_trace(go.Scatter(showlegend=False, x=[0, 0, -2*semi_angle, 0], y=[defo*y_down, reduc*0.8*y_down, reduc*0.8*y_down, defo*y_down],mode='lines', fill=\"toself\", fillcolor=\"red\", opacity=0.7,line=dict(color='red',width=1)))\n",
@ -669,9 +741,9 @@
" \n",
" ### PROBE ##########################################\n",
" fig = go.Figure() \n",
" fig.update_yaxes(title_text=\"Contrast transfer func.\")\n",
" xx = wavelength/(np.sin(semi_angle_corr*omega/1000))/100\n",
" # xx = 2*wavelength/(np.sin(semi_angle_corr*omega/1000))/100\n",
" fig.update_yaxes(title_text=\"Contrast transfer [-]\")\n",
"\n",
" xx = wavelength/(np.sin(semi_angle_corr*omega/1000))/100 # Full pitch size\n",
" \n",
" if ctf_xaxis == 'α': \n",
" fig.add_trace(go.Scatter(x=omega, y=pctf, marker_color='red', name=str(np.round(semi_angle_corr,2))+ ' mrad',))\n",
@ -679,32 +751,54 @@
" \n",
" if ctf_xaxis == 'mrad': \n",
" for x in apertury:\n",
" fig.add_trace(go.Scatter(showlegend=False, x=pty.get_angle_corr(x) *omega, y=pctf, marker_color='gray', name='SSB-CTF',))\n",
" fig.add_trace(go.Scatter(showlegend=False, x=pty.get_angle_corr(x) *omega, y=pctf, marker_color='black', name='SSB-CTF',))\n",
"\n",
" fig.add_trace(go.Scatter(x=semi_angle_corr*omega, y=pctf, marker_color='red', name=str(np.round(semi_angle_corr,2))+ ' mrad',))\n",
" # fig.add_trace(go.Scatter(x=semi_angle_corr*omega, y=pctf, marker_color='black', name=str(np.round(semi_angle_corr,2))+ ' mrad',))\n",
" fig.update_layout(legend=dict(orientation=\"h\",yanchor=\"bottom\",y=0.85,xanchor=\"right\",x=1))\n",
" fig.update_xaxes(title_text=\"Spacial frequency (mrad)\", range=[0, 60], zeroline=False)\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
" \n",
" elif ctf_xaxis == 'A':\n",
" for x in apertury:\n",
" d = wavelength/(np.sin(pty.get_angle_corr(x)*omega/1000))/100\n",
" fig.add_trace(go.Scatter(showlegend=False, x=d, y=pctf, marker_color='gray', name='SSB-CTF',))\n",
" d = wavelength/(np.sin(pty.get_angle_corr(x)*omega/1000))/100 # Full pitch size\n",
" fig.add_trace(go.Scatter(showlegend=False, x=d, y=pctf, marker_color='black', name='SSB-CTF',))\n",
"\n",
" # fig.add_trace(go.Scatter(x=xx, y=pctf, marker_color='red', name=str(np.round(semi_angle_corr,2))+ ' mrad',))\n",
"\n",
" # SmB6\n",
" fig.add_trace(go.Scatter(x=[4.13, 4.13], y=[0, 0.41], marker_color='green', ))\n",
" fig.add_trace(go.Scatter(x=[2.92, 2.92], y=[0, 0.41], marker_color='green', ))\n",
" # fig.add_trace(go.Scatter(showlegend=False,x=[4.13, 4.13], y=[0, 0.41], marker_color='green', ))\n",
" # fig.add_trace(go.Scatter(showlegend=False,x=[2.92, 2.92], y=[0, 0.41], marker_color='green', ))\n",
"\n",
" fig.add_trace(go.Scatter(x=[1.71, 1.71], y=[0, 0.41], marker_color='blue', ))\n",
" fig.add_trace(go.Scatter(x=[1.21, 1.21], y=[0, 0.41], marker_color='blue', ))\n",
" # fig.add_trace(go.Scatter(showlegend=False,x=[1.71, 1.71], y=[0, 0.41], marker_color='blue', ))\n",
" # fig.add_trace(go.Scatter(showlegend=False,x=[1.21, 1.21], y=[0, 0.41], marker_color='blue', ))\n",
"\n",
" \n",
" fig.update_xaxes(title_text=\"Real space distance (Å)\", range=[-0.5, 2.5], type=\"log\", zeroline=False)\n",
" fig.update_xaxes(title_text=\"Real space distance (Å)\", range=[-0.5, 2], type=\"log\", zeroline=False)\n",
"\n",
" # fig.update_layout(legend=dict(orientation=\"h\",yanchor=\"bottom\",y=0.75,xanchor=\"right\",x=1))\n",
" # fig3.update_layout(title={'text': \"CTF\",'y':0.93, 'x':0.12,'xanchor': 'left','yanchor': 'top'})\n",
" fig.update_layout(width=6*graph_size, height=2.5*graph_size, margin = dict(l=1.3*graph_size, r=0.3*graph_size, t=0.0*graph_size, b=0.3*graph_size))\n",
" \n",
"\n",
"\n",
" fig.update_layout(plot_bgcolor='white')\n",
" fig.update_xaxes(mirror=True,ticks='outside',showline=True,linecolor='black',gridcolor='lightgrey')\n",
" fig.update_yaxes(mirror=True,ticks='outside',showline=True,linecolor='black',gridcolor='lightgrey')\n",
" fig.update_yaxes(title_font_color=\"#000000\")\n",
" fig.update_xaxes(title_font_color=\"#000000\")\n",
"\n",
" \n",
" fig.update_layout(width=5*graph_size, height=2.5*graph_size, margin = dict(l=1.3*graph_size, r=0.3*graph_size, t=0.0*graph_size, b=0.3*graph_size))\n",
" \n",
"\n",
"\n",
"\n",
"\n",
" ### CAMERA LENGTH GRAPH ##########################################\n",
" fig4 = make_subplots(specs=[[{\"secondary_y\": True}]])\n",
" fig4.add_trace(go.Scatter(showlegend=False, x=opt.cameralengths(), y=detector_cover_all, marker_color='gray'), secondary_y=False,)\n",
@ -772,20 +866,69 @@
"\n",
" case 'A':\n",
" for x in apertury:\n",
" d = 2*wavelength/(np.sin(pty.get_angle_corr(x)*xnew/1000))/100\n",
" d = wavelength/(np.sin(pty.get_angle_corr(x)*xnew/1000))/100\n",
" fig.add_trace(go.Scatter(showlegend=False, x=d, y=pctf_new, marker_color='gray', name='CTF',))\n",
" \n",
" xx = 2*wavelength/(np.sin(semi_angle_corr*xnew/1000))/100\n",
" xx = wavelength/(np.sin(semi_angle_corr*xnew/1000))/100\n",
" fig.add_trace(go.Scatter(x=xx, y=pctf_new, marker_color='red', name=str(np.round(semi_angle_corr,2))+ ' mrad',))\n",
" fig.update_xaxes(title_text=\"Real space distance (Å)\",range=[-0.5, 2], type=\"log\", zeroline=False) # \n",
"\n",
" fig.update_layout(legend=dict(orientation=\"h\",yanchor=\"bottom\",y=0.8,xanchor=\"right\",x=0.95))\n",
" # fig3.update_layout(title={'text': \"CTF\",'y':0.93, 'x':0.12,'xanchor': 'left','yanchor': 'top'})\n",
" fig.update_layout(width=9.25*graph_size, height=2.2*graph_size, margin = dict(l=1.3*graph_size, r=0.3*graph_size, t=0.0*graph_size, b=0.6*graph_size))\n",
" fig.update_layout(width=5*graph_size, height=2.2*graph_size, margin = dict(l=1.3*graph_size, r=0.3*graph_size, t=0.0*graph_size, b=0.45*graph_size))\n",
" \n",
" checks = VBox([Label('Final checks'),check1, check2, check3]) \n",
" checks.layout = Layout(border='dashed 1px gray', margin='0px 30px 20px 120px', padding='5px 5px 5px 5px')\n",
" \n",
" ### INTENSIY DISTRIBUTION ##################################\n",
" fig9 = go.Figure() \n",
" fig9.update_yaxes(title_text=\"Probe intensity [-]\")\n",
" fig9.update_xaxes(title_text=\"Sample plane (nm)\", range=[-4*step_size_corr, 4*step_size_corr], zeroline=False)\n",
"\n",
" # define constants\n",
" mu = 0\n",
" # sigma = beam_diameter/(2*np.sqrt(8*np.log(2))) # WHAT ABOUT THE FORMULA?????? SHOULD BE beam_diameter/np.sqrt(8*np.log(2)) IS BEAM DEFINED BY DIAMETER +-2 SIGMA?\n",
" \n",
" \n",
" # sigma = beam_diameter/4 # WHAT ABOUT THE FORMULA?????? SHOULD BE beam_diameter/np.sqrt(8*np.log(2)) IS BEAM DEFINED BY DIAMETER +-2 SIGMA?\n",
" sigma = beam_diameter/1.66 # WHAT ABOUT THE FORMULA?????? SHOULD BE beam_diameter/np.sqrt(8*np.log(2)) IS BEAM DEFINED BY DIAMETER +-2 SIGMA?\n",
"\n",
" \n",
" # sigma = beam_diameter/np.sqrt(8*np.log(2)) # WHAT ABOUT THE FORMULA?????? SHOULD BE beam_diameter/np.sqrt(8*np.log(2)) IS BEAM DEFINED BY DIAMETER +-2 SIGMA?\n",
" # sigma = beam_diameter/np.sqrt(8*np.log(2)) # WHAT ABOUT THE FORMULA?????? SHOULD BE beam_diameter/np.sqrt(8*np.log(2)) IS BEAM DEFINED BY DIAMETER +-2 SIGMA?\n",
" x = np.linspace(-4*step_size_corr, 4*step_size_corr, 300)\n",
"\n",
" possitions = 10\n",
" yy = np.zeros(len(x))\n",
" for i in np.linspace(-possitions,possitions,2*possitions+1).astype(int):\n",
" \n",
" y = norm.pdf(x,mu-i*step_size_corr,sigma)\n",
" yy = yy+y\n",
" if i == 0:\n",
" fig9.add_trace(go.Scatter(x=x, y=y, marker_color='gray',name='Individual probes')) \n",
" fig9.add_trace(go.Scatter(showlegend=False,x=x, y=y, marker_color='gray')) \n",
" \n",
" fig9.add_trace(go.Scatter(x=x, y=yy, marker_color='red', name='Sumed probes'))\n",
" fig9.add_annotation(x=0, y=np.max(yy),text=\"Hilliness \"+str(np.round( ((np.max(yy[100:200])-np.min(yy[100:200]))/np.max(yy[100:200])*100),1))+\" %\", showarrow=False,align= 'left', yshift=15)\n",
" fig9.update_layout(legend=dict(orientation=\"v\",yanchor=\"bottom\",y=0.1,xanchor=\"right\",x=0.95))\n",
" fig9.update_layout(width=5*graph_size, height=2.2*graph_size, margin = dict(l=0.5*graph_size, r=1*graph_size, t=0.0*graph_size, b=0.0*graph_size))\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
" \n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
" \n",
" ### PROBE WINDOW ##########################################\n",
" if beam_diameter < probe_window/2:\n",
@ -799,10 +942,10 @@
" name = 'Beam ⌀ is too big'\n",
"\n",
" fig7 = go.Figure() \n",
" fig7.add_shape(type=\"rect\",xref=\"x\", yref=\"y\",opacity=0.3, fillcolor=\"LightSkyBlue\", x0=probe_window/4, y0=probe_window/4, x1=3*probe_window/4, y1=3*probe_window/4,line_color=\"LightSkyBlue\")\n",
" fig7.add_shape(type=\"rect\",xref=\"x\", yref=\"y\",opacity=0.3, fillcolor=\"#6F6F6F\", x0=probe_window/4, y0=probe_window/4, x1=3*probe_window/4, y1=3*probe_window/4,line_color=\"#6F6F6F\")\n",
" # fig7.add_trace(go.Scatter(x=np.array(probe_window/2), y=np.array(probe_window/2), showlegend=False, marker_color=\"LightSkyBlue\"))\n",
" fig7.add_trace(go.Scatter(x=np.array(probe_window/2), y=np.array(probe_window/2), name=name, showlegend=True, marker_color=color, opacity = 0))\n",
" fig7.add_annotation(x=probe_window/2, y=3*probe_window/4, text=\"<b>Usable area </b>\", showarrow=False, yshift=-15)\n",
" # fig7.add_annotation(x=probe_window/2, y=3*probe_window/4, text=\"<b>Usable area </b>\", font_color=\"#FFFFFF\", showarrow=False, yshift=-15)\n",
"\n",
" fig7.add_shape(type=\"circle\",xref=\"x\", yref=\"y\", opacity=0.2, fillcolor=color, x0=probe_window/2-beam_diameter/8, y0=probe_window/2-beam_diameter/8, x1=probe_window/2+beam_diameter/8, y1=probe_window/2+beam_diameter/8, line_color=color,)\n",
" fig7.add_shape(type=\"circle\",xref=\"x\", yref=\"y\", opacity=0.2, fillcolor=color, x0=probe_window/2-beam_diameter/6, y0=probe_window/2-beam_diameter/6, x1=probe_window/2+beam_diameter/6, y1=probe_window/2+beam_diameter/6, line_color=color,)\n",
@ -814,13 +957,26 @@
" fig7.add_shape(type=\"circle\",xref=\"x\", yref=\"y\", opacity=0.4, fillcolor=color, x0=probe_window/2-beam_diameter/2, y0=probe_window/2-beam_diameter/2, x1=probe_window/2+beam_diameter/2, y1=probe_window/2+beam_diameter/2, line_color=color,)\n",
"\n",
" \n",
" fig7.update_xaxes(title_text=\"Probe window (nm)\", range=[0, probe_window], tickvals = [0, probe_window/4, probe_window/2, 3*probe_window/4, probe_window], ticktext = [0, np.round(probe_window/4,2),np.round(probe_window/4,2),np.round(probe_window/2,2),np.round(3*probe_window/4,2),np.round(probe_window,2)])\n",
" fig7.update_xaxes(title_text=\"Probe window (nm)\", range=[0, probe_window], tickvals = [0, probe_window/4, probe_window/2, 3*probe_window/4, probe_window], ticktext = [0, np.round(probe_window/4,2),np.round(probe_window/2,2),np.round(3*probe_window/4,2),np.round(probe_window,2)])\n",
" fig7.update_yaxes(range=[0, probe_window], tickvals = [0, probe_window/4, probe_window/2, 3*probe_window/4, probe_window], showticklabels=False,)\n",
" fig7.update_yaxes(range=[0, probe_window], showticklabels=False,)\n",
" fig7.update_yaxes(range=[0, probe_window], showticklabels=False,)\n",
" fig7.update_layout(legend=dict(orientation=\"v\",yanchor=\"bottom\",y=1.0,xanchor=\"right\",x=1))\n",
" fig7.update_layout(legend=dict(orientation=\"v\",yanchor=\"bottom\",y=1.01,xanchor=\"right\",x=1))\n",
" fig7.update_layout(title={'text': \"Probe\",'y':0.975, 'x':0.10,'xanchor': 'left','yanchor': 'top'})\n",
" fig7.update_layout(width=4*graph_size, height=4*graph_size, margin =dict(l=0.3*graph_size, r=0.3*graph_size, t=0.1*graph_size, b=0)) \n",
"\n",
"\n",
"\n",
"\n",
" fig7.update_layout(plot_bgcolor='white')\n",
" fig7.update_xaxes(mirror=True,ticks='outside',showline=True,linecolor='black',gridcolor='lightgrey')\n",
" fig7.update_yaxes(mirror=True,ticks='inside',showline=True,linecolor='black',gridcolor='lightgrey')\n",
" fig7.update_yaxes(title_font_color=\"#000000\")\n",
" fig7.update_xaxes(title_font_color=\"#000000\")\n",
"\n",
"\n",
"\n",
"\n",
" \n",
" ### CAMERA LENGTH TABLE ########################################## \n",
" dictionary = {}\n",
@ -884,10 +1040,10 @@
" total = VBox([go.FigureWidget(fig8),go.FigureWidget(fig6)])\n",
" case 'dedic':\n",
" sample_overlap = HBox([go.FigureWidget(fig5), go.FigureWidget(fig7)]) \n",
" total = VBox([HBox([go.FigureWidget(fig)]), sample_overlap, cltab,checks]) \n",
" total = VBox([HBox([go.FigureWidget(fig),go.FigureWidget(fig9)]), sample_overlap, cltab,checks]) \n",
" case _:\n",
" sample_overlap = HBox([go.FigureWidget(fig5), go.FigureWidget(fig7)]) \n",
" right_column = VBox([HBox([go.FigureWidget(fig)]), sample_overlap, cltab,checks]) \n",
" right_column = VBox([HBox([go.FigureWidget(fig),go.FigureWidget(fig9)]), sample_overlap, cltab,checks]) \n",
" left_column = VBox([go.FigureWidget(fig8), go.FigureWidget(fig6)]) \n",
" total = HBox([left_column, right_column]) \n",
" \n",