This commit is contained in:
rskoupy
2024-08-28 16:23:13 +02:00
parent ef7afacbed
commit 5e013b4654
2 changed files with 194 additions and 164 deletions

View File

@ -56,7 +56,7 @@
},
{
"cell_type": "code",
"execution_count": 640,
"execution_count": 2,
"id": "de350192-85ae-4d38-8ed3-14ad43843e01",
"metadata": {},
"outputs": [],
@ -81,22 +81,14 @@
},
{
"cell_type": "code",
"execution_count": 159,
"id": "3ca2e3fd-4e61-4d4c-9d58-4b72f16999dc",
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": 682,
"execution_count": 15,
"id": "7937f054-fcd0-4e67-a20f-7696f5903a94",
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "393206d6b8c94bf0a367f7b255fa3238",
"model_id": "c9cf20bfd02a4b7483a582dca71bdb4e",
"version_major": 2,
"version_minor": 0
},
@ -115,7 +107,7 @@
},
{
"cell_type": "code",
"execution_count": 681,
"execution_count": 14,
"id": "41ac78f4-8a75-4258-bfd4-539b28746088",
"metadata": {},
"outputs": [],
@ -149,7 +141,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)], 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",
@ -221,6 +213,7 @@
"ctf_xaxis = ToggleButtons(options=['α','mrad', 'Å'], layout=Layout(grid_area='ctxaxis'), style = {'button_width': '30%'}, disabled=False)\n",
"overlap_fig = ToggleButtons(options=['Geometrical','Intensity'], layout=Layout(grid_area='overlap_fig'), style = {'button_width': '45%'}, disabled=False)\n",
"beam_pos = IntSlider(value=4, min=4, max=16, step=2, description='Add beams:', disabled=False, continuous_update=False, orientation='horizontal', readout=True, readout_format='d', layout=Layout(grid_area='beam_pos', width = '100%'))\n",
"\n",
"fov_show = FloatSlider(value=0.3, min=0.1, max=10, step=0.1, description='FoV (nm):', disabled=False, continuous_update=False, orientation='horizontal', readout=True, readout_format='.1f', layout=Layout(grid_area='fov_show', width = '100%'))\n",
"top_set = Button(description='',layout=Layout(width='%', grid_area='scanning_set'), style=ButtonStyle(button_color='white', font_weight= 'bold',font_size= '16px',text_color='#0d48a1'),disabled = True)\n",
"red_box = Dropdown(options=[('tiny', 0.1), ('small', 0.2), ('middle', 0.3), ('large', 0.4), ('whole', 0.5)], value=0.1, description='Uniformity box', layout=Layout(grid_area='red_box', width = '95%'),style=style)\n",
@ -325,12 +318,8 @@
" \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='red')\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='red')\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='magenta')\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='magenta')\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",
"\n",
" fig5.add_trace(go.Scatter(showlegend=True, x=[-1], y=[-1],marker_size=12, marker_color='red', name='Step size '+str(np.round(10*step_size_corr,2))+' Å')) \n",
" fig5.add_trace(go.Scatter(showlegend=True, x=[-1], y=[-1],marker_size=12, marker_color='magenta', name='Beam ⌀ '+str(np.round(10*beam_diameter,2))+' Å')) \n",
" \n",
@ -339,14 +328,9 @@
" 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",
" fig5.update_layout(legend=dict(orientation=\"v\",yanchor=\"bottom\",y=1.0,xanchor=\"right\",x=0.9))\n",
"\n",
"\n",
" \n",
" \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 = [-fov_show/2, -fov_show/4, 0, fov_show/4, fov_show/2],ticktext = ['0', '25', '50', '75', '100'], secondary_y=False)\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',title_font_color=\"#000000\")\n",
@ -368,15 +352,15 @@
" text_trap = io.StringIO()\n",
" sys.stdout = text_trap\n",
" \n",
" sampling= 0.05 # sampling of the simulated potential in A\n",
" probe = Probe(sampling = sampling, extent = int(5*beam_diameter*10), energy = beam*1e3, semiangle_cutoff = semi_angle_corr, defocus = defocus*10)\n",
" sampling= 0.02 # sampling of the simulated potential in A\n",
"\n",
" probe = Probe(sampling = sampling, extent = 2*beam_diameter*10, energy = beam*1e3, semiangle_cutoff = semi_angle_corr, defocus = defocus*10)\n",
" # probe = Probe(sampling=sampling, extent= A , energy=beam*1e3 eV, semiangle_cutoff = mrad, defocus= A)\n",
" intensity = probe.build().intensity().compute()\n",
" intensity = intensity.array\n",
" # now restore stdout function\n",
" # # now restore stdout function\n",
" sys.stdout = sys.__stdout__\n",
"\n",
"\n",
" x_pix = int(step_size_corr*10/sampling) # step size from nm to A\n",
" field = np.zeros([intensity.shape[0]+(beam_pos)*x_pix, intensity.shape[1]+(beam_pos)*x_pix])\n",
" cen = int(intensity.shape[0]/2)\n",
@ -387,10 +371,9 @@
" xy = x_pix*j\n",
" field[cen-o+xy : cen+o+xy, cen-o+xx : cen+o+xx] = field[cen-o+xy : cen+o+xy, cen-o+xx : cen+o+xx] + intensity\n",
"\n",
" \n",
" field_cen = int(field.shape[0]/2)\n",
" middle = field[int(field_cen-(x_pix*(beam_pos+1)*red_box)): int(field_cen+(x_pix*(beam_pos+1)*red_box)), int(field_cen-(x_pix*(beam_pos+1)*red_box)): int(field_cen+(x_pix*(beam_pos+1)*red_box))]\n",
" uniformity = 1-((np.max(middle)-np.min(middle))/np.max(middle))\n",
" middle = field[int(field_cen-(x_pix*(beam_pos)*red_box)): int(field_cen+(x_pix*(beam_pos)*red_box)), int(field_cen-(x_pix*(beam_pos)*red_box)): int(field_cen+(x_pix*(beam_pos)*red_box))]\n",
" uniformity = (1-((np.max(middle)-np.min(middle))/np.max(middle)))*100\n",
" \n",
" fig5 = go.Figure() \n",
" fig5.add_trace(px.imshow(field).data[0],)\n",
@ -399,21 +382,20 @@
" field_cen = int(field.shape[0]/2) \n",
" \n",
" fig5.add_shape(type=\"rect\",x0= field_cen-red_box*field_size, y0=field_cen-red_box*field_size, x1= field_cen+red_box*field_size, y1=field_cen+red_box*field_size,line=dict(color=box_col),)\n",
" fig5.update_layout(title={'text': \"Uniformity: \"+str(np.round(uniformity,1))+\"%\",'y':0.96, 'x':0.35,'xanchor': 'left','yanchor': 'top'})\n",
" fig5.update_traces(dict(showscale=False, coloraxis=None, colorscale='plasma'), selector={'type':'heatmap'})\n",
"\n",
"\n",
"\n",
" fig5.update_yaxes(showticklabels=False)\n",
" fig5.update_xaxes(mirror=True,ticks='outside',showline=True,linecolor='black',gridcolor='lightgrey',title_font_color=\"#000000\")\n",
" fig5.update_xaxes(title_text=\"Sample plane (nm)\", showgrid=False, showticklabels=True, tickvals = [0, field.shape[0]/2, field.shape[0]-1], \n",
" ticktext = [0, np.round((field.shape[0]/2)*sampling,1), np.round((field.shape[0]-1)*sampling)])\n",
"\n",
" \n",
" fig5.update_layout(title={'text': \"Uniformity: \"+str(np.round(uniformity,2)),'y':0.96, 'x':0.26,'xanchor': 'left','yanchor': 'top'})\n",
" fig5.update_xaxes(mirror=True,ticks='outside',showline=True,linecolor='black',gridcolor='lightgrey', title_font_color=\"#000000\")\n",
" fig5.update_yaxes(mirror=True,ticks='inside',showline=True,linecolor='black',gridcolor='lightgrey', title_font_color=\"#000000\")\n",
" \n",
" \n",
" if method == 'direct':\n",
" fig5.update_layout(width=3.7*graph_size, height=2.85*graph_size, margin =dict(l=0.5*graph_size, r=0.1*graph_size, t=0.3*graph_size, b=0))\n",
" fig5.update_layout(width=3.2*graph_size, height=3.2*graph_size, margin =dict(l=0.4*graph_size, r=0.05*graph_size, t=0.3*graph_size, b=0))\n",
"\n",
" if method == 'iterative':\n",
" fig5.update_layout(width=4.3*graph_size, height=2.85*graph_size, margin =dict(l=1.1*graph_size, r=0.3*graph_size, t=0.3*graph_size, b=0))\n",
" fig5.update_layout(width=3.9*graph_size, height=3.1*graph_size, margin =dict(l=1.3*graph_size, r=0.2*graph_size, t=0.3*graph_size, b=0))\n",
"\n",
"\n",
"\n",
@ -655,40 +637,82 @@
"\n",
" \n",
" ### PROBE WINDOW ##########################################\n",
" if beam_diameter < probe_window/2:\n",
" color = \"green\"\n",
" name = 'Beam ⌀ is fine'\n",
" elif beam_diameter < probe_window:\n",
" color = \"orange\"\n",
" name = 'Beam ⌀ is quite big'\n",
" else:\n",
" color = \"red\"\n",
" name = 'Beam ⌀ is too big'\n",
" if overlap_fig == 'Geometrical': \n",
" if beam_diameter < probe_window/2:\n",
" color = \"green\"\n",
" name = 'Beam ⌀ is fine'\n",
" elif beam_diameter < probe_window:\n",
" color = \"orange\"\n",
" name = 'Beam ⌀ is quite big'\n",
" else:\n",
" color = \"red\"\n",
" name = 'Beam ⌀ is too big'\n",
"\n",
" fig7 = go.Figure() \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), name=name, showlegend=True, marker_color=color, opacity = 0))\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",
" fig7.add_shape(type=\"circle\",xref=\"x\", yref=\"y\", opacity=0.2, fillcolor=color, x0=probe_window/2-beam_diameter/5, y0=probe_window/2-beam_diameter/5, x1=probe_window/2+beam_diameter/5, y1=probe_window/2+beam_diameter/5, line_color=color,)\n",
" fig7.add_shape(type=\"circle\",xref=\"x\", yref=\"y\", opacity=0.2, fillcolor=color, x0=probe_window/2-beam_diameter/4.25, y0=probe_window/2-beam_diameter/4.25, x1=probe_window/2+beam_diameter/4.25, y1=probe_window/2+beam_diameter/4.25, line_color=color,)\n",
" fig7.add_shape(type=\"circle\",xref=\"x\", yref=\"y\", opacity=0.2, fillcolor=color, x0=probe_window/2-beam_diameter/3.5, y0=probe_window/2-beam_diameter/3.5, x1=probe_window/2+beam_diameter/3.5, y1=probe_window/2+beam_diameter/3.5, line_color=color,)\n",
" fig7.add_shape(type=\"circle\",xref=\"x\", yref=\"y\", opacity=0.2, fillcolor=color, x0=probe_window/2-beam_diameter/3, y0=probe_window/2-beam_diameter/3, x1=probe_window/2+beam_diameter/3, y1=probe_window/2+beam_diameter/3, line_color=color,)\n",
" fig7.add_shape(type=\"circle\",xref=\"x\", yref=\"y\", opacity=0.2, fillcolor=color, x0=probe_window/2-beam_diameter/2.5, y0=probe_window/2-beam_diameter/2.5, x1=probe_window/2+beam_diameter/2.5, y1=probe_window/2+beam_diameter/2.5, line_color=color,)\n",
" 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",
" fig7.update_xaxes(title_text=\"Reconstruction box (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.01,xanchor=\"right\",x=1),title={'text': \"Probe\",'y':0.975, 'x':0.05,'xanchor': 'left','yanchor': 'top'})\n",
" fig7.update_layout(width=2.7*graph_size, height=3.1*graph_size, margin =dict(l=0, r=0, t=0.1*graph_size, b=0)) \n",
" fig7.update_layout(plot_bgcolor='white')\n",
" fig7.update_xaxes(mirror=True,ticks='outside',showline=True,linecolor='black',gridcolor='lightgrey',title_font_color=\"#000000\")\n",
" fig7.update_yaxes(mirror=True,ticks='inside',showline=True,linecolor='black',gridcolor='lightgrey',title_font_color=\"#000000\")\n",
" fig7 = go.Figure() \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), name=name, showlegend=True, marker_color=color, opacity = 0))\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",
" fig7.add_shape(type=\"circle\",xref=\"x\", yref=\"y\", opacity=0.2, fillcolor=color, x0=probe_window/2-beam_diameter/5, y0=probe_window/2-beam_diameter/5, x1=probe_window/2+beam_diameter/5, y1=probe_window/2+beam_diameter/5, line_color=color,)\n",
" fig7.add_shape(type=\"circle\",xref=\"x\", yref=\"y\", opacity=0.2, fillcolor=color, x0=probe_window/2-beam_diameter/4.25, y0=probe_window/2-beam_diameter/4.25, x1=probe_window/2+beam_diameter/4.25, y1=probe_window/2+beam_diameter/4.25, line_color=color,)\n",
" fig7.add_shape(type=\"circle\",xref=\"x\", yref=\"y\", opacity=0.2, fillcolor=color, x0=probe_window/2-beam_diameter/3.5, y0=probe_window/2-beam_diameter/3.5, x1=probe_window/2+beam_diameter/3.5, y1=probe_window/2+beam_diameter/3.5, line_color=color,)\n",
" fig7.add_shape(type=\"circle\",xref=\"x\", yref=\"y\", opacity=0.2, fillcolor=color, x0=probe_window/2-beam_diameter/3, y0=probe_window/2-beam_diameter/3, x1=probe_window/2+beam_diameter/3, y1=probe_window/2+beam_diameter/3, line_color=color,)\n",
" fig7.add_shape(type=\"circle\",xref=\"x\", yref=\"y\", opacity=0.2, fillcolor=color, x0=probe_window/2-beam_diameter/2.5, y0=probe_window/2-beam_diameter/2.5, x1=probe_window/2+beam_diameter/2.5, y1=probe_window/2+beam_diameter/2.5, line_color=color,)\n",
" 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",
" fig7.update_xaxes(title_text=\"Reconstruction box (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.01,xanchor=\"right\",x=1),title={'text': \"Probe\",'y':0.975, 'x':0.05,'xanchor': 'left','yanchor': 'top'})\n",
" fig7.update_layout(width=2.7*graph_size, height=3.1*graph_size, margin =dict(l=0, r=0, t=0.1*graph_size, b=0)) \n",
" fig7.update_layout(plot_bgcolor='white')\n",
" fig7.update_xaxes(mirror=True,ticks='outside',showline=True,linecolor='black',gridcolor='lightgrey',title_font_color=\"#000000\")\n",
" fig7.update_yaxes(mirror=True,ticks='inside',showline=True,linecolor='black',gridcolor='lightgrey',title_font_color=\"#000000\")\n",
"\n",
"\n",
" ####################\n",
" ####################\n",
" ####################\n",
" ####################\n",
" ####################\n",
" elif method == 'iterative': \n",
" sampling= 0.1 # sampling of the simulated potential in A\n",
" probe = Probe(sampling = sampling, extent = 2*probe_window*10, energy = beam*1e3, semiangle_cutoff = semi_angle_corr, defocus = defocus*10)\n",
" # probe = Probe(sampling=sampling, extent= A , energy=beam*1e3 eV, semiangle_cutoff = mrad, defocus= A)\n",
" intensity2 = probe.build().intensity().compute()\n",
" intensity2 = intensity2.array\n",
" inten = intensity2/np.max(intensity2)\n",
" \n",
" cen2 = inten.shape\n",
" sirkaA = cen2[0]*sampling\n",
" sirkaB = probe_window*10/sampling\n",
"\n",
" just_probe_window = inten[int(cen2[0]/2)-int(sirkaB/2) : int(cen2[0]/2)+int(sirkaB/2), int(cen2[0]/2)-int(sirkaB/2) : int(cen2[0]/2)+int(sirkaB/2)]\n",
" int_tot = np.sum(just_probe_window)/np.sum(inten)*100\n",
"\n",
" fig7 = go.Figure() \n",
" fig7.add_trace(px.imshow(inten).data[0],)\n",
" fig7.add_shape(type=\"rect\",x0= cen2[0]/2-sirkaB/2, y0=cen2[0]/2-sirkaB/2, x1= cen2[1]/2+sirkaB/2, y1=cen2[1]/2+sirkaB/2, line=dict(color=\"white\"),)\n",
" fig7.update_layout(title={'text': \"Probe cover \",'y':0.96, 'x':0.05,'xanchor': 'left','yanchor': 'top'})\n",
" fig7.update_layout(width=2.7*graph_size, height=2.65*graph_size, margin =dict(l=0.1*graph_size, r=0.1*graph_size, t=0.3*graph_size, b=0))\n",
" fig7.update_traces(dict(showscale=False, \n",
" coloraxis=None, \n",
" colorscale='plasma'), selector={'type':'heatmap'})\n",
" fig7.update_xaxes(showticklabels=False).update_yaxes(showticklabels=False)\n",
" fig7.add_annotation(x=cen2[0]/2, y=cen2[0]/2+sirkaB/2, text='Recon. box '+str(np.round(probe_window,2))+' nm', showarrow=False, yshift=15)\n",
" fig7.add_annotation(x=cen2[0]/2, y=cen2[0]/2-sirkaB/2, text='Probe covered '+str(np.round(int_tot,1))+' %', showarrow=False, yshift=-15)\n",
" fig7.update_annotations(font=dict(color=\"white\"))\n",
" # fig7.update_annotations(font=dict(family=\"sans serif\", size=18, color=\"red\"))\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
" \n",
" \n",
"\n",
" \n",
" ### CAMERA LENGTH TABLE ########################################## \n",
" dictionary = {}\n",
@ -786,7 +810,7 @@
},
{
"cell_type": "code",
"execution_count": 173,
"execution_count": 3,
"id": "68780f2b-efa0-4240-870b-2b0876977e90",
"metadata": {},
"outputs": [],

View File

@ -56,7 +56,7 @@
},
{
"cell_type": "code",
"execution_count": 640,
"execution_count": null,
"id": "de350192-85ae-4d38-8ed3-14ad43843e01",
"metadata": {},
"outputs": [],
@ -81,33 +81,10 @@
},
{
"cell_type": "code",
"execution_count": 159,
"id": "3ca2e3fd-4e61-4d4c-9d58-4b72f16999dc",
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": 682,
"execution_count": null,
"id": "7937f054-fcd0-4e67-a20f-7696f5903a94",
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "393206d6b8c94bf0a367f7b255fa3238",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"VBox(children=(Button(disabled=True, layout=Layout(grid_area='scanning_set', width='%'), style=ButtonStyle(but…"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"outputs": [],
"source": [
"\n",
"display(VBox([top_set, HBox([controls, VBox([small_controls, gui])])]))\n"
@ -115,7 +92,7 @@
},
{
"cell_type": "code",
"execution_count": 681,
"execution_count": null,
"id": "41ac78f4-8a75-4258-bfd4-539b28746088",
"metadata": {},
"outputs": [],
@ -135,7 +112,7 @@
" aperture = ToggleButtons(options=opt.apertures(), description='', layout=Layout(width='95%', grid_area='beam_set2'), **ali3)\n",
"\n",
"probe = Dropdown(options=opt.probes(), value='8C', description='Probe', layout=Layout(width='95%', grid_area='beam_set3'), **ali)\n",
"defocus = IntSlider(description='Defocus (nm)', value=0, min=0, max=1000, step=1, continuous_update=False, layout=Layout(width='95%', grid_area='beam_set4'), **ali)\n",
"defocus = FloatSlider(description='Defocus (nm)', value=0, min=0, max=1000, step=0.5, continuous_update=False, layout=Layout(width='95%', grid_area='beam_set4'), **ali)\n",
"\n",
"scanning_set = Button(description='Scanning parameters',layout=Layout(width='95%', grid_area='scanning_set'),style=ButtonStyle(button_color='#222261', font_weight= 'bold',font_size= '16px',text_color='white'),disabled = False)\n",
"mag = Dropdown(options=opt.magnifications(),value=20,description='Magnification Mx', layout=Layout(width='95%', grid_area='scanning_set1'), **ali)\n",
@ -149,7 +126,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)], 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",
@ -220,7 +197,8 @@
"ctf_xaxis_name = Label(value = 'x-axis',layout=Layout(width='95%', grid_area='ctf_xaxis_name'),)\n",
"ctf_xaxis = ToggleButtons(options=['α','mrad', 'Å'], layout=Layout(grid_area='ctxaxis'), style = {'button_width': '30%'}, disabled=False)\n",
"overlap_fig = ToggleButtons(options=['Geometrical','Intensity'], layout=Layout(grid_area='overlap_fig'), style = {'button_width': '45%'}, disabled=False)\n",
"beam_pos = IntSlider(value=4, min=4, max=16, step=2, description='Add beams:', disabled=False, continuous_update=False, orientation='horizontal', readout=True, readout_format='d', layout=Layout(grid_area='beam_pos', width = '100%'))\n",
"beam_pos = IntSlider(value=4, min=4, max=100, step=2, description='Add beams:', disabled=False, continuous_update=False, orientation='horizontal', readout=True, readout_format='d', layout=Layout(grid_area='beam_pos', width = '100%'))\n",
"\n",
"fov_show = FloatSlider(value=0.3, min=0.1, max=10, step=0.1, description='FoV (nm):', disabled=False, continuous_update=False, orientation='horizontal', readout=True, readout_format='.1f', layout=Layout(grid_area='fov_show', width = '100%'))\n",
"top_set = Button(description='',layout=Layout(width='%', grid_area='scanning_set'), style=ButtonStyle(button_color='white', font_weight= 'bold',font_size= '16px',text_color='#0d48a1'),disabled = True)\n",
"red_box = Dropdown(options=[('tiny', 0.1), ('small', 0.2), ('middle', 0.3), ('large', 0.4), ('whole', 0.5)], value=0.1, description='Uniformity box', layout=Layout(grid_area='red_box', width = '95%'),style=style)\n",
@ -325,12 +303,8 @@
" \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='red')\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='red')\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='magenta')\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='magenta')\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",
"\n",
" fig5.add_trace(go.Scatter(showlegend=True, x=[-1], y=[-1],marker_size=12, marker_color='red', name='Step size '+str(np.round(10*step_size_corr,2))+' Å')) \n",
" fig5.add_trace(go.Scatter(showlegend=True, x=[-1], y=[-1],marker_size=12, marker_color='magenta', name='Beam ⌀ '+str(np.round(10*beam_diameter,2))+' Å')) \n",
" \n",
@ -339,14 +313,9 @@
" 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",
" fig5.update_layout(legend=dict(orientation=\"v\",yanchor=\"bottom\",y=1.0,xanchor=\"right\",x=0.9))\n",
"\n",
"\n",
" \n",
" \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 = [-fov_show/2, -fov_show/4, 0, fov_show/4, fov_show/2],ticktext = ['0', '25', '50', '75', '100'], secondary_y=False)\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',title_font_color=\"#000000\")\n",
@ -368,52 +337,46 @@
" text_trap = io.StringIO()\n",
" sys.stdout = text_trap\n",
" \n",
" sampling= 0.05 # sampling of the simulated potential in A\n",
" probe = Probe(sampling = sampling, extent = int(5*beam_diameter*10), energy = beam*1e3, semiangle_cutoff = semi_angle_corr, defocus = defocus*10)\n",
" sampling= 0.02 # sampling of the simulated potential in A\n",
"\n",
" probe = Probe(sampling = sampling, extent = 2*beam_diameter*10, energy = beam*1e3, semiangle_cutoff = semi_angle_corr, defocus = defocus*10)\n",
" # probe = Probe(sampling=sampling, extent= A , energy=beam*1e3 eV, semiangle_cutoff = mrad, defocus= A)\n",
" intensity = probe.build().intensity().compute()\n",
" intensity = intensity.array\n",
" # now restore stdout function\n",
" intensity = np.abs(intensity)\n",
" # # now restore stdout function\n",
" sys.stdout = sys.__stdout__\n",
"\n",
"\n",
" x_pix = int(step_size_corr*10/sampling) # step size from nm to A\n",
" field = np.zeros([intensity.shape[0]+(beam_pos)*x_pix, intensity.shape[1]+(beam_pos)*x_pix])\n",
" cen = int(intensity.shape[0]/2)\n",
" o = int(intensity.shape[0]/2)\n",
" \n",
" for i in range(0,beam_pos+1):\n",
" for j in range(0,beam_pos+1):\n",
" xx = x_pix*i\n",
" xy = x_pix*j\n",
" field[cen-o+xy : cen+o+xy, cen-o+xx : cen+o+xx] = field[cen-o+xy : cen+o+xy, cen-o+xx : cen+o+xx] + intensity\n",
"\n",
" \n",
" field_cen = int(field.shape[0]/2)\n",
" middle = field[int(field_cen-(x_pix*(beam_pos+1)*red_box)): int(field_cen+(x_pix*(beam_pos+1)*red_box)), int(field_cen-(x_pix*(beam_pos+1)*red_box)): int(field_cen+(x_pix*(beam_pos+1)*red_box))]\n",
" uniformity = 1-((np.max(middle)-np.min(middle))/np.max(middle))\n",
" \n",
" fig5 = go.Figure() \n",
" fig5.add_trace(px.imshow(field).data[0],)\n",
" field[xy : intensity.shape[0]+xy, xx : intensity.shape[0]+xx] = field[xy : intensity.shape[0]+xy, xx : intensity.shape[0]+xx] + intensity\n",
"\n",
" field_size = int(field.shape[0]) \n",
" field_cen = int(field.shape[0]/2) \n",
" field_cen = int(field.shape[0]/2)\n",
" middle = field[int(field_cen-(x_pix*(beam_pos)*red_box)): int(field_cen+(x_pix*(beam_pos)*red_box)), int(field_cen-(x_pix*(beam_pos)*red_box)): int(field_cen+(x_pix*(beam_pos)*red_box))]\n",
" uniformity = (1-(np.max(middle)-np.min(middle)) / (np.max(field)-np.min(field)))*100\n",
" \n",
" fig5 = go.Figure() \n",
" fig5.add_trace(px.imshow(field).data[0],)\n",
" fig5.add_shape(type=\"rect\",x0= field_cen-red_box*field_size, y0=field_cen-red_box*field_size, x1= field_cen+red_box*field_size, y1=field_cen+red_box*field_size,line=dict(color=box_col),)\n",
" fig5.update_layout(title={'text': \"Uniformity: \"+str(np.round(uniformity,1))+\"%\",'y':0.96, 'x':0.35,'xanchor': 'left','yanchor': 'top'})\n",
" fig5.update_traces(dict(showscale=False, coloraxis=None, colorscale='plasma'), selector={'type':'heatmap'})\n",
" fig5.update_yaxes(showticklabels=False)\n",
" fig5.update_xaxes(mirror=True,ticks='outside',showline=True,linecolor='black',gridcolor='lightgrey',title_font_color=\"#000000\")\n",
" fig5.update_xaxes(title_text=\"Sample plane (nm)\", showgrid=False, showticklabels=True, tickvals = [0, field.shape[0]/2, field.shape[0]-1], \n",
" ticktext = [0, np.round((field.shape[0]/2)*sampling,1), np.round((field.shape[0]-1)*sampling,1)])\n",
"\n",
"\n",
"\n",
"\n",
" \n",
" fig5.update_layout(title={'text': \"Uniformity: \"+str(np.round(uniformity,2)),'y':0.96, 'x':0.26,'xanchor': 'left','yanchor': 'top'})\n",
" fig5.update_xaxes(mirror=True,ticks='outside',showline=True,linecolor='black',gridcolor='lightgrey', title_font_color=\"#000000\")\n",
" fig5.update_yaxes(mirror=True,ticks='inside',showline=True,linecolor='black',gridcolor='lightgrey', title_font_color=\"#000000\")\n",
" \n",
" \n",
" if method == 'direct':\n",
" fig5.update_layout(width=3.7*graph_size, height=2.85*graph_size, margin =dict(l=0.5*graph_size, r=0.1*graph_size, t=0.3*graph_size, b=0))\n",
" fig5.update_layout(width=3.2*graph_size, height=3.2*graph_size, margin =dict(l=0.4*graph_size, r=0.05*graph_size, t=0.3*graph_size, b=0))\n",
"\n",
" if method == 'iterative':\n",
" fig5.update_layout(width=4.3*graph_size, height=2.85*graph_size, margin =dict(l=1.1*graph_size, r=0.3*graph_size, t=0.3*graph_size, b=0))\n",
" fig5.update_layout(width=3.9*graph_size, height=3.1*graph_size, margin =dict(l=1.3*graph_size, r=0.2*graph_size, t=0.3*graph_size, b=0))\n",
"\n",
"\n",
"\n",
@ -655,40 +618,82 @@
"\n",
" \n",
" ### PROBE WINDOW ##########################################\n",
" if beam_diameter < probe_window/2:\n",
" color = \"green\"\n",
" name = 'Beam ⌀ is fine'\n",
" elif beam_diameter < probe_window:\n",
" color = \"orange\"\n",
" name = 'Beam ⌀ is quite big'\n",
" else:\n",
" color = \"red\"\n",
" name = 'Beam ⌀ is too big'\n",
" if overlap_fig == 'Geometrical': \n",
" if beam_diameter < probe_window/2:\n",
" color = \"green\"\n",
" name = 'Beam ⌀ is fine'\n",
" elif beam_diameter < probe_window:\n",
" color = \"orange\"\n",
" name = 'Beam ⌀ is quite big'\n",
" else:\n",
" color = \"red\"\n",
" name = 'Beam ⌀ is too big'\n",
"\n",
" fig7 = go.Figure() \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), name=name, showlegend=True, marker_color=color, opacity = 0))\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",
" fig7.add_shape(type=\"circle\",xref=\"x\", yref=\"y\", opacity=0.2, fillcolor=color, x0=probe_window/2-beam_diameter/5, y0=probe_window/2-beam_diameter/5, x1=probe_window/2+beam_diameter/5, y1=probe_window/2+beam_diameter/5, line_color=color,)\n",
" fig7.add_shape(type=\"circle\",xref=\"x\", yref=\"y\", opacity=0.2, fillcolor=color, x0=probe_window/2-beam_diameter/4.25, y0=probe_window/2-beam_diameter/4.25, x1=probe_window/2+beam_diameter/4.25, y1=probe_window/2+beam_diameter/4.25, line_color=color,)\n",
" fig7.add_shape(type=\"circle\",xref=\"x\", yref=\"y\", opacity=0.2, fillcolor=color, x0=probe_window/2-beam_diameter/3.5, y0=probe_window/2-beam_diameter/3.5, x1=probe_window/2+beam_diameter/3.5, y1=probe_window/2+beam_diameter/3.5, line_color=color,)\n",
" fig7.add_shape(type=\"circle\",xref=\"x\", yref=\"y\", opacity=0.2, fillcolor=color, x0=probe_window/2-beam_diameter/3, y0=probe_window/2-beam_diameter/3, x1=probe_window/2+beam_diameter/3, y1=probe_window/2+beam_diameter/3, line_color=color,)\n",
" fig7.add_shape(type=\"circle\",xref=\"x\", yref=\"y\", opacity=0.2, fillcolor=color, x0=probe_window/2-beam_diameter/2.5, y0=probe_window/2-beam_diameter/2.5, x1=probe_window/2+beam_diameter/2.5, y1=probe_window/2+beam_diameter/2.5, line_color=color,)\n",
" 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",
" fig7.update_xaxes(title_text=\"Reconstruction box (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.01,xanchor=\"right\",x=1),title={'text': \"Probe\",'y':0.975, 'x':0.05,'xanchor': 'left','yanchor': 'top'})\n",
" fig7.update_layout(width=2.7*graph_size, height=3.1*graph_size, margin =dict(l=0, r=0, t=0.1*graph_size, b=0)) \n",
" fig7.update_layout(plot_bgcolor='white')\n",
" fig7.update_xaxes(mirror=True,ticks='outside',showline=True,linecolor='black',gridcolor='lightgrey',title_font_color=\"#000000\")\n",
" fig7.update_yaxes(mirror=True,ticks='inside',showline=True,linecolor='black',gridcolor='lightgrey',title_font_color=\"#000000\")\n",
" fig7 = go.Figure() \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), name=name, showlegend=True, marker_color=color, opacity = 0))\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",
" fig7.add_shape(type=\"circle\",xref=\"x\", yref=\"y\", opacity=0.2, fillcolor=color, x0=probe_window/2-beam_diameter/5, y0=probe_window/2-beam_diameter/5, x1=probe_window/2+beam_diameter/5, y1=probe_window/2+beam_diameter/5, line_color=color,)\n",
" fig7.add_shape(type=\"circle\",xref=\"x\", yref=\"y\", opacity=0.2, fillcolor=color, x0=probe_window/2-beam_diameter/4.25, y0=probe_window/2-beam_diameter/4.25, x1=probe_window/2+beam_diameter/4.25, y1=probe_window/2+beam_diameter/4.25, line_color=color,)\n",
" fig7.add_shape(type=\"circle\",xref=\"x\", yref=\"y\", opacity=0.2, fillcolor=color, x0=probe_window/2-beam_diameter/3.5, y0=probe_window/2-beam_diameter/3.5, x1=probe_window/2+beam_diameter/3.5, y1=probe_window/2+beam_diameter/3.5, line_color=color,)\n",
" fig7.add_shape(type=\"circle\",xref=\"x\", yref=\"y\", opacity=0.2, fillcolor=color, x0=probe_window/2-beam_diameter/3, y0=probe_window/2-beam_diameter/3, x1=probe_window/2+beam_diameter/3, y1=probe_window/2+beam_diameter/3, line_color=color,)\n",
" fig7.add_shape(type=\"circle\",xref=\"x\", yref=\"y\", opacity=0.2, fillcolor=color, x0=probe_window/2-beam_diameter/2.5, y0=probe_window/2-beam_diameter/2.5, x1=probe_window/2+beam_diameter/2.5, y1=probe_window/2+beam_diameter/2.5, line_color=color,)\n",
" 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",
" fig7.update_xaxes(title_text=\"Reconstruction box (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.01,xanchor=\"right\",x=1),title={'text': \"Probe\",'y':0.975, 'x':0.05,'xanchor': 'left','yanchor': 'top'})\n",
" fig7.update_layout(width=2.7*graph_size, height=3.1*graph_size, margin =dict(l=0, r=0, t=0.1*graph_size, b=0)) \n",
" fig7.update_layout(plot_bgcolor='white')\n",
" fig7.update_xaxes(mirror=True,ticks='outside',showline=True,linecolor='black',gridcolor='lightgrey',title_font_color=\"#000000\")\n",
" fig7.update_yaxes(mirror=True,ticks='inside',showline=True,linecolor='black',gridcolor='lightgrey',title_font_color=\"#000000\")\n",
"\n",
"\n",
" ####################\n",
" ####################\n",
" ####################\n",
" ####################\n",
" ####################\n",
" elif method == 'iterative': \n",
" sampling= 0.1 # sampling of the simulated potential in A\n",
" probe = Probe(sampling = sampling, extent = 2*probe_window*10, energy = beam*1e3, semiangle_cutoff = semi_angle_corr, defocus = defocus*10)\n",
" # probe = Probe(sampling=sampling, extent= A , energy=beam*1e3 eV, semiangle_cutoff = mrad, defocus= A)\n",
" intensity2 = probe.build().intensity().compute()\n",
" intensity2 = intensity2.array\n",
" inten = intensity2/np.max(intensity2)\n",
" \n",
" cen2 = inten.shape\n",
" sirkaA = cen2[0]*sampling\n",
" sirkaB = probe_window*10/sampling\n",
"\n",
" just_probe_window = inten[int(cen2[0]/2)-int(sirkaB/2) : int(cen2[0]/2)+int(sirkaB/2), int(cen2[0]/2)-int(sirkaB/2) : int(cen2[0]/2)+int(sirkaB/2)]\n",
" int_tot = np.sum(just_probe_window)/np.sum(inten)*100\n",
"\n",
" fig7 = go.Figure() \n",
" fig7.add_trace(px.imshow(inten).data[0],)\n",
" fig7.add_shape(type=\"rect\",x0= cen2[0]/2-sirkaB/2, y0=cen2[0]/2-sirkaB/2, x1= cen2[1]/2+sirkaB/2, y1=cen2[1]/2+sirkaB/2, line=dict(color=\"white\"),)\n",
" fig7.update_layout(title={'text': \"Probe cover \",'y':0.96, 'x':0.05,'xanchor': 'left','yanchor': 'top'})\n",
" fig7.update_layout(width=2.7*graph_size, height=2.65*graph_size, margin =dict(l=0.1*graph_size, r=0.1*graph_size, t=0.3*graph_size, b=0))\n",
" fig7.update_traces(dict(showscale=False, \n",
" coloraxis=None, \n",
" colorscale='plasma'), selector={'type':'heatmap'})\n",
" fig7.update_xaxes(showticklabels=False).update_yaxes(showticklabels=False)\n",
" fig7.add_annotation(x=cen2[0]/2, y=cen2[0]/2+sirkaB/2, text='Recon. box '+str(np.round(probe_window,2))+' nm', showarrow=False, yshift=15)\n",
" fig7.add_annotation(x=cen2[0]/2, y=cen2[0]/2-sirkaB/2, text='Probe covered '+str(np.round(int_tot,1))+' %', showarrow=False, yshift=-15)\n",
" fig7.update_annotations(font=dict(color=\"white\"))\n",
" # fig7.update_annotations(font=dict(family=\"sans serif\", size=18, color=\"red\"))\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
" \n",
" \n",
"\n",
" \n",
" ### CAMERA LENGTH TABLE ########################################## \n",
" dictionary = {}\n",
@ -767,7 +772,8 @@
" total = HBox([go.FigureWidget(fig8)])\n",
" case 'dedic':\n",
" sample_overlap = HBox([go.FigureWidget(fig5), go.FigureWidget(fig7), go.FigureWidget(fig6)]) \n",
" total = VBox([HBox([go.FigureWidget(fig),go.FigureWidget(fig9)]), sample_overlap, HBox([cltab, checks])]) \n",
" total = VBox([HBox([go.FigureWidget(fig), checks]), sample_overlap, cltab]) \n",
" \n",
" case _:\n",
" sample_overlap = HBox([go.FigureWidget(fig5), go.FigureWidget(fig7), go.FigureWidget(fig6)]) \n",
" right_column = VBox([HBox([go.FigureWidget(fig), checks]) , sample_overlap, cltab]) \n",
@ -786,7 +792,7 @@
},
{
"cell_type": "code",
"execution_count": 173,
"execution_count": null,
"id": "68780f2b-efa0-4240-870b-2b0876977e90",
"metadata": {},
"outputs": [],