some bugs
This commit is contained in:
@ -1,9 +1,62 @@
|
||||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "1e474cb7-5fd4-4113-a3fa-ddf5ca152ce5",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"# ptychoScopy\n",
|
||||
"\n",
|
||||
"Jupyter based interactive data acquisition tool designed for appropriate ptychographic data collection. It computes nessesary characteristics which play crutial role in final data reconstruction. \n",
|
||||
"You can chose of **Direct methods** (mainly Single Side Band ptychography) or **Iterative reconstruction** which takes probe defocus into account. With this tool, you can check for probe CTF, scanning step size, probe overlap, detector camera length a proper angular range collection, reconstructed probe size and many more.\n",
|
||||
"\n",
|
||||
"For more info go to https://gitlab.psi.ch/em-and-diffraction/low-dose-electron-ptychography/ptychoscopy/-/wikis/ptychoScopy\n",
|
||||
"\n",
|
||||
"### Controls\n",
|
||||
"List of controls consists of all parameters needed for proper dataset acquisition design:\n",
|
||||
"\n",
|
||||
"| Beam | | Scanning | | Camera length | | Detection | |\n",
|
||||
"|------ | ------| ------| ------| ------| ------| ------| ------|\n",
|
||||
"| **Aperture**| probe forming aperture gives probe semi-angle (α) | **Magnification**| controls image field of view | **Nominal CL** | sample to detector distance gives maximal detected angle as well as angular sampling | **Detector** | detector used for data collection | \n",
|
||||
"| **Energy** | energy of primary electron beam in keV ... gives final pixel size | **Matrix** | gives beam position to position distance + beam defocus = beam overlap | **Use PAAR** | Pumping Aperture Anglar Restriction, build-in aperture may limit maximal scattering angles for shortest camera lengths |**Binning** | reduction in pixel array size usually increas maximum frame rate |\n",
|
||||
"| **Probe** | probe setting together with chosen probe forming aperture give probe current| | | | | **Dwell time**|single position beam time ... check your detector characteristics |\n",
|
||||
"| **Defocus** | moves focus out of the sample plane - enlarges beam diameter | | | | | | |\n",
|
||||
"\n",
|
||||
"### Start the interactive gui by running the field\n",
|
||||
"```python\n",
|
||||
"display(HBox([controls, VBox([small_controls, gui])]))\n",
|
||||
"```"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 380,
|
||||
"id": "7937f054-fcd0-4e67-a20f-7696f5903a94",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"application/vnd.jupyter.widget-view+json": {
|
||||
"model_id": "0b1b53b08a164896893f0f563fa29206",
|
||||
"version_major": 2,
|
||||
"version_minor": 0
|
||||
},
|
||||
"text/plain": [
|
||||
"VBox(children=(Button(disabled=True, layout=Layout(grid_area='scanning_set', width='99%'), style=ButtonStyle(b…"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"display(VBox([top_set, HBox([controls, VBox([top_set,small_controls1, gui])])]))"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "a007a116-5d9d-4dd9-9352-b719f3deb8bb",
|
||||
"id": "9414daad-2958-4c26-8f29-8f6fe92fe992",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
@ -28,8 +81,8 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 1,
|
||||
"id": "7425242d-3c91-4c1e-a424-08625a38ee7a",
|
||||
"execution_count": 379,
|
||||
"id": "3ca2e3fd-4e61-4d4c-9d58-4b72f16999dc",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
@ -299,16 +352,8 @@
|
||||
" cl_det_res.value = f'Detector CL (cm) {\"{:.1f}\".format(pty.get_cl_detector(caller.new))}' \n",
|
||||
" return cl_det_res.value\n",
|
||||
"\n",
|
||||
"inte = interaction() "
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 60,
|
||||
"id": "8055b802-cf83-4250-aea9-54e3e6b73db0",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"inte = interaction() \n",
|
||||
"\n",
|
||||
"### CONTROLS ##########################################\n",
|
||||
"ali = dict(style = {'description_width': '110px','button_width': '55px', 'font_weight': 'bold'}, button_style='', disabled = False)\n",
|
||||
"ali2 = dict(style = {'description_width': '60px','button_width': '90px', 'font_weight': 'bold'}, button_style='',disabled = False)\n",
|
||||
@ -338,7 +383,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)], 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",
|
||||
@ -354,11 +399,11 @@
|
||||
"\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"file = open(\"./logo.png\", \"rb\")\n",
|
||||
"file = open(\"./logo_psi.png\", \"rb\")\n",
|
||||
"image = file.read()\n",
|
||||
"logo1 = widgets.Image(value=image, format='png', width=200, height=100,layout=Layout(grid_area='logo1'))\n",
|
||||
"\n",
|
||||
"file = open(\"./logo3.png\", \"rb\")\n",
|
||||
"file = open(\"./logo.png\", \"rb\")\n",
|
||||
"image = file.read()\n",
|
||||
"logo2 = widgets.Image(value=image,format='png',width=200, height=100,layout=Layout(grid_area='logo2'))\n",
|
||||
"\n",
|
||||
@ -489,7 +534,7 @@
|
||||
" 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))+' Å')) \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",
|
||||
@ -501,25 +546,23 @@
|
||||
" \n",
|
||||
" ### DETECTOR PLANE ##########################################\n",
|
||||
" fig6 = make_subplots(specs=[[{\"secondary_y\": True}]])\n",
|
||||
" for x in np.linspace(1,int(np.round(covered_alfas)),int(np.round(covered_alfas))):\n",
|
||||
" fig6.add_shape(type=\"circle\",xref=\"x\", yref=\"y\", x0=num_pixels/2-x*beam_diameter_pix, y0=num_pixels/2-x*beam_diameter_pix, x1=num_pixels/2+x*beam_diameter_pix, y1=num_pixels/2+x*beam_diameter_pix, line=dict(color=\"gray\",width=1,dash=\"dot\",),secondary_y=False)\n",
|
||||
" fig6.add_trace(go.Scatter(showlegend=False,x=[num_pixels/2],y=[num_pixels/2+x*beam_diameter_pix],mode=\"lines+text\", text=str(int(2*x))+\"α\",textposition=\"top center\"),secondary_y=False)\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/2-beam_diameter_pix/2, y0=num_pixels/2-beam_diameter_pix/2, x1=num_pixels/2+beam_diameter_pix/2, y1=num_pixels/2+beam_diameter_pix/2,line_color=\"#FF7F7F\",secondary_y=False)\n",
|
||||
" fig6.add_annotation(x=num_pixels/2-beam_diameter_pix/2, y=num_pixels/2, ax=num_pixels/2+beam_diameter_pix/2, ay=num_pixels/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/2+beam_diameter_pix/2,y=num_pixels/2, ax=num_pixels/2-beam_diameter_pix/2, ay=num_pixels/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/2, y=num_pixels/2, text=str(np.round(beam_diameter_pix,1))+\" pix\", showarrow=False, yshift=10)\n",
|
||||
" fig6.add_annotation(x=num_pixels/2, y=num_pixels/2, text=\"1 pix = \"+str(np.round(pixel_angle,2))+\" mrad\", showarrow=False, yshift=-10)\n",
|
||||
" fig6.add_annotation(x=num_pixels/2, y=num_pixels/10, text=\"Real pixel size = \"+str(np.round(size_pixel,2))+\" μm\", showarrow=False, yshift=0)\n",
|
||||
" fig6.add_trace(go.Scatter(showlegend=True,x=[-1], y=[-1], marker_color='red', name = \"BF disk\"),secondary_y=False)\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_layout(legend=dict(orientation=\"h\",yanchor=\"bottom\",y=0.85,xanchor=\"right\",x=0.9))\n",
|
||||
" # fig6.update_layout(title={'text': \"Detector\",'y':0.975, 'x':0.11,'xanchor': 'left','yanchor': 'top'})\n",
|
||||
" fig6.update_xaxes(title_text=\"Pixels\", range=[1, num_pixels], zeroline=False, tickvals = [1, num_pixels/4, num_pixels/2, 3*num_pixels/4, num_pixels]) \n",
|
||||
" fig6.update_yaxes(range=[1, num_pixels], showticklabels=False, showgrid=False, secondary_y=False)\n",
|
||||
" fig6.update_yaxes(title_text=\"Angular cover (mrad)\", range=[1, num_pixels], showticklabels=True, tickvals = [1, num_pixels/4, num_pixels/2, 3*num_pixels/4, num_pixels],\n",
|
||||
" ticktext = ['', np.round(detector_cover/4,1), np.round(detector_cover/2,1), np.round(3*detector_cover/4,1), np.round(detector_cover,1)], secondary_y=True) \n",
|
||||
" fig6.update_layout(width=3.85*graph_size, height=2.8*graph_size, margin = dict(l=0.6*graph_size, r=0.48*graph_size, t=0*graph_size, b=0))\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",
|
||||
" focusdepth = wavelength/(semi_angle_corr/1000)**2/1000\n",
|
||||
@ -535,6 +578,9 @@
|
||||
" 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",
|
||||
@ -546,7 +592,8 @@
|
||||
" defo = np.log(defocus)/100\n",
|
||||
" else:\n",
|
||||
" defo = 0 \n",
|
||||
" \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",
|
||||
@ -595,11 +642,18 @@
|
||||
" for x in opt.cameralengths():\n",
|
||||
" fig8.add_trace(go.Scatter(showlegend=False, x=[-width, width], y=[-np.log(x), -np.log(x)], opacity=0.3, line=dict(color='gray',width=1)))\n",
|
||||
" fig8.add_annotation(x=0.9*width, y=-np.log(x),text=str(x), showarrow=False, yshift=8)\n",
|
||||
" \n",
|
||||
"\n",
|
||||
" fig8.update_xaxes(title_text=\"\")\n",
|
||||
" # fig8.update_layout(title={'text': \"Microscope\" ,'y':1, 'x':0.10,'xanchor': 'left','yanchor': 'top'})\n",
|
||||
" fig8.update_layout(width=3.5*graph_size, height=7.2*graph_size, margin = dict(l=0.3*graph_size, r=0, t=0.0*graph_size, b=0))\n",
|
||||
" fig8.update_layout(plot_bgcolor='white')\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"\n",
|
||||
" \n",
|
||||
" \n",
|
||||
" ### FINAL CHECKS ########################################## \n",
|
||||
" align_check = dict(layout=Layout(width='200px') , style = {'description_width': '150px','button_width': \"50px\"}, disabled=True,) \n",
|
||||
@ -616,7 +670,8 @@
|
||||
" ### PROBE ##########################################\n",
|
||||
" fig = go.Figure() \n",
|
||||
" fig.update_yaxes(title_text=\"Contrast transfer func.\")\n",
|
||||
" xx = 2*wavelength/(np.sin(semi_angle_corr*omega/1000))/100\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",
|
||||
" 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",
|
||||
@ -631,15 +686,24 @@
|
||||
"\n",
|
||||
" elif ctf_xaxis == 'A':\n",
|
||||
" for x in apertury:\n",
|
||||
" d = 2*wavelength/(np.sin(pty.get_angle_corr(x)*omega/1000))/100\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",
|
||||
"\n",
|
||||
" fig.add_trace(go.Scatter(x=xx, y=pctf, marker_color='red', name=str(np.round(semi_angle_corr,2))+ ' mrad',))\n",
|
||||
" fig.update_xaxes(title_text=\"Real space distance (Å)\", range=[-0.2, 2.5], type=\"log\", zeroline=False)\n",
|
||||
" # fig.add_trace(go.Scatter(x=xx, y=pctf, marker_color='red', name=str(np.round(semi_angle_corr,2))+ ' mrad',))\n",
|
||||
"\n",
|
||||
" fig.update_layout(legend=dict(orientation=\"h\",yanchor=\"bottom\",y=0.75,xanchor=\"right\",x=1))\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",
|
||||
"\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",
|
||||
"\n",
|
||||
" \n",
|
||||
" fig.update_xaxes(title_text=\"Real space distance (Å)\", range=[-0.5, 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=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=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",
|
||||
" ### CAMERA LENGTH GRAPH ##########################################\n",
|
||||
" fig4 = make_subplots(specs=[[{\"secondary_y\": True}]])\n",
|
||||
@ -736,11 +800,23 @@
|
||||
"\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_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))\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_shape(type=\"circle\",xref=\"x\", yref=\"y\", opacity=0.9, 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=\"Probe window (nm)\", range=[0, probe_window], tickvals = [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)-0.01])\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",
|
||||
" 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",
|
||||
"\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_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(title={'text': \"Probe\",'y':0.975, 'x':0.10,'xanchor': 'left','yanchor': 'top'})\n",
|
||||
@ -824,59 +900,6 @@
|
||||
"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": "markdown",
|
||||
"id": "1e474cb7-5fd4-4113-a3fa-ddf5ca152ce5",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"\n",
|
||||
"\n",
|
||||
"Jupyter based interactive data acquisition tool designed for appropriate ptychographic data collection. It computes nessesary characteristics which play crutial role in final data reconstruction. \n",
|
||||
"You can chose of **Direct methods** (mainly Single Side Band ptychography) or **Iterative reconstruction** which takes probe defocus into account. With this tool, you can check for probe CTF, scanning step size, probe overlap, detector camera length a proper angular range collection, reconstructed probe size and many more.\n",
|
||||
"\n",
|
||||
"For more info go to https://gitlab.psi.ch/em-and-diffraction/low-dose-electron-ptychography/ptychoscopy/-/wikis/ptychoScopy\n",
|
||||
"\n",
|
||||
"### Controls\n",
|
||||
"List of controls consists of all parameters needed for proper dataset acquisition design:\n",
|
||||
"\n",
|
||||
"| Beam | | Scanning | | Camera length | | Detection | |\n",
|
||||
"|------ | ------| ------| ------| ------| ------| ------| ------|\n",
|
||||
"| **Aperture**| probe forming aperture gives probe semi-angle (α) | **Magnification**| controls image field of view | **Nominal CL** | sample to detector distance gives maximal detected angle as well as angular sampling | **Detector** | detector used for data collection | \n",
|
||||
"| **Energy** | energy of primary electron beam in keV ... gives final pixel size | **Matrix** | gives beam position to position distance + beam defocus = beam overlap | **Use PAAR** | Pumping Aperture Anglar Restriction, build-in aperture may limit maximal scattering angles for shortest camera lengths |**Binning** | reduction in pixel array size usually increas maximum frame rate |\n",
|
||||
"| **Probe** | probe setting together with chosen probe forming aperture give probe current| | | | | **Dwell time**|single position beam time ... check your detector characteristics |\n",
|
||||
"| **Defocus** | moves focus out of the sample plane - enlarges beam diameter | | | | | | |\n",
|
||||
"\n",
|
||||
"### Start the interactive gui by running the field\n",
|
||||
"```python\n",
|
||||
"display(HBox([controls, VBox([small_controls, gui])]))\n",
|
||||
"```"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 61,
|
||||
"id": "7937f054-fcd0-4e67-a20f-7696f5903a94",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"application/vnd.jupyter.widget-view+json": {
|
||||
"model_id": "6cbafcca9b904589bc6e7b05cc937013",
|
||||
"version_major": 2,
|
||||
"version_minor": 0
|
||||
},
|
||||
"text/plain": [
|
||||
"VBox(children=(Button(disabled=True, layout=Layout(grid_area='scanning_set', width='99%'), style=ButtonStyle(b…"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"display(VBox([top_set, HBox([controls, VBox([top_set,small_controls1, gui])])]))"
|
||||
]
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
|
Binary file not shown.
BIN
logo.png
BIN
logo.png
Binary file not shown.
Before Width: | Height: | Size: 2.4 KiB After Width: | Height: | Size: 165 KiB |
BIN
logo_psi.png
Normal file
BIN
logo_psi.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 17 KiB |
BIN
logo_ptychoscopy.png
Normal file
BIN
logo_ptychoscopy.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 166 KiB |
@ -1,9 +1,62 @@
|
||||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "1e474cb7-5fd4-4113-a3fa-ddf5ca152ce5",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"# ptychoScopy\n",
|
||||
"\n",
|
||||
"Jupyter based interactive data acquisition tool designed for appropriate ptychographic data collection. It computes nessesary characteristics which play crutial role in final data reconstruction. \n",
|
||||
"You can chose of **Direct methods** (mainly Single Side Band ptychography) or **Iterative reconstruction** which takes probe defocus into account. With this tool, you can check for probe CTF, scanning step size, probe overlap, detector camera length a proper angular range collection, reconstructed probe size and many more.\n",
|
||||
"\n",
|
||||
"For more info go to https://gitlab.psi.ch/em-and-diffraction/low-dose-electron-ptychography/ptychoscopy/-/wikis/ptychoScopy\n",
|
||||
"\n",
|
||||
"### Controls\n",
|
||||
"List of controls consists of all parameters needed for proper dataset acquisition design:\n",
|
||||
"\n",
|
||||
"| Beam | | Scanning | | Camera length | | Detection | |\n",
|
||||
"|------ | ------| ------| ------| ------| ------| ------| ------|\n",
|
||||
"| **Aperture**| probe forming aperture gives probe semi-angle (α) | **Magnification**| controls image field of view | **Nominal CL** | sample to detector distance gives maximal detected angle as well as angular sampling | **Detector** | detector used for data collection | \n",
|
||||
"| **Energy** | energy of primary electron beam in keV ... gives final pixel size | **Matrix** | gives beam position to position distance + beam defocus = beam overlap | **Use PAAR** | Pumping Aperture Anglar Restriction, build-in aperture may limit maximal scattering angles for shortest camera lengths |**Binning** | reduction in pixel array size usually increas maximum frame rate |\n",
|
||||
"| **Probe** | probe setting together with chosen probe forming aperture give probe current| | | | | **Dwell time**|single position beam time ... check your detector characteristics |\n",
|
||||
"| **Defocus** | moves focus out of the sample plane - enlarges beam diameter | | | | | | |\n",
|
||||
"\n",
|
||||
"### Start the interactive gui by running the field\n",
|
||||
"```python\n",
|
||||
"display(HBox([controls, VBox([small_controls, gui])]))\n",
|
||||
"```"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 2,
|
||||
"id": "7937f054-fcd0-4e67-a20f-7696f5903a94",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"application/vnd.jupyter.widget-view+json": {
|
||||
"model_id": "f5d3146d31ae4954b265e5d673e86d12",
|
||||
"version_major": 2,
|
||||
"version_minor": 0
|
||||
},
|
||||
"text/plain": [
|
||||
"VBox(children=(Button(disabled=True, layout=Layout(grid_area='scanning_set', width='99%'), style=ButtonStyle(b…"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"display(VBox([top_set, HBox([controls, VBox([top_set,small_controls1, gui])])]))"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "a007a116-5d9d-4dd9-9352-b719f3deb8bb",
|
||||
"id": "9414daad-2958-4c26-8f29-8f6fe92fe992",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
@ -29,7 +82,7 @@
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 1,
|
||||
"id": "7425242d-3c91-4c1e-a424-08625a38ee7a",
|
||||
"id": "3ca2e3fd-4e61-4d4c-9d58-4b72f16999dc",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
@ -299,16 +352,8 @@
|
||||
" cl_det_res.value = f'Detector CL (cm) {\"{:.1f}\".format(pty.get_cl_detector(caller.new))}' \n",
|
||||
" return cl_det_res.value\n",
|
||||
"\n",
|
||||
"inte = interaction() "
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 2,
|
||||
"id": "8055b802-cf83-4250-aea9-54e3e6b73db0",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"inte = interaction() \n",
|
||||
"\n",
|
||||
"### CONTROLS ##########################################\n",
|
||||
"ali = dict(style = {'description_width': '110px','button_width': '55px', 'font_weight': 'bold'}, button_style='', disabled = False)\n",
|
||||
"ali2 = dict(style = {'description_width': '60px','button_width': '90px', 'font_weight': 'bold'}, button_style='',disabled = False)\n",
|
||||
@ -338,7 +383,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)], 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",
|
||||
@ -354,11 +399,11 @@
|
||||
"\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"file = open(\"./logo.png\", \"rb\")\n",
|
||||
"file = open(\"./logo_psi.png\", \"rb\")\n",
|
||||
"image = file.read()\n",
|
||||
"logo1 = widgets.Image(value=image, format='png', width=200, height=100,layout=Layout(grid_area='logo1'))\n",
|
||||
"\n",
|
||||
"file = open(\"./logo3.png\", \"rb\")\n",
|
||||
"file = open(\"./logo.png\", \"rb\")\n",
|
||||
"image = file.read()\n",
|
||||
"logo2 = widgets.Image(value=image,format='png',width=200, height=100,layout=Layout(grid_area='logo2'))\n",
|
||||
"\n",
|
||||
@ -489,7 +534,7 @@
|
||||
" 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))+' Å')) \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",
|
||||
@ -501,25 +546,23 @@
|
||||
" \n",
|
||||
" ### DETECTOR PLANE ##########################################\n",
|
||||
" fig6 = make_subplots(specs=[[{\"secondary_y\": True}]])\n",
|
||||
" for x in np.linspace(1,int(np.round(covered_alfas)),int(np.round(covered_alfas))):\n",
|
||||
" fig6.add_shape(type=\"circle\",xref=\"x\", yref=\"y\", x0=num_pixels/2-x*beam_diameter_pix, y0=num_pixels/2-x*beam_diameter_pix, x1=num_pixels/2+x*beam_diameter_pix, y1=num_pixels/2+x*beam_diameter_pix, line=dict(color=\"gray\",width=1,dash=\"dot\",),secondary_y=False)\n",
|
||||
" fig6.add_trace(go.Scatter(showlegend=False,x=[num_pixels/2],y=[num_pixels/2+x*beam_diameter_pix],mode=\"lines+text\", text=str(int(2*x))+\"α\",textposition=\"top center\"),secondary_y=False)\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/2-beam_diameter_pix/2, y0=num_pixels/2-beam_diameter_pix/2, x1=num_pixels/2+beam_diameter_pix/2, y1=num_pixels/2+beam_diameter_pix/2,line_color=\"#FF7F7F\",secondary_y=False)\n",
|
||||
" fig6.add_annotation(x=num_pixels/2-beam_diameter_pix/2, y=num_pixels/2, ax=num_pixels/2+beam_diameter_pix/2, ay=num_pixels/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/2+beam_diameter_pix/2,y=num_pixels/2, ax=num_pixels/2-beam_diameter_pix/2, ay=num_pixels/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/2, y=num_pixels/2, text=str(np.round(beam_diameter_pix,1))+\" pix\", showarrow=False, yshift=10)\n",
|
||||
" fig6.add_annotation(x=num_pixels/2, y=num_pixels/2, text=\"1 pix = \"+str(np.round(pixel_angle,2))+\" mrad\", showarrow=False, yshift=-10)\n",
|
||||
" fig6.add_annotation(x=num_pixels/2, y=num_pixels/10, text=\"Real pixel size = \"+str(np.round(size_pixel,2))+\" μm\", showarrow=False, yshift=0)\n",
|
||||
" fig6.add_trace(go.Scatter(showlegend=True,x=[-1], y=[-1], marker_color='red', name = \"BF disk\"),secondary_y=False)\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_layout(legend=dict(orientation=\"h\",yanchor=\"bottom\",y=0.85,xanchor=\"right\",x=0.9))\n",
|
||||
" # fig6.update_layout(title={'text': \"Detector\",'y':0.975, 'x':0.11,'xanchor': 'left','yanchor': 'top'})\n",
|
||||
" fig6.update_xaxes(title_text=\"Pixels\", range=[1, num_pixels], zeroline=False, tickvals = [1, num_pixels/4, num_pixels/2, 3*num_pixels/4, num_pixels]) \n",
|
||||
" fig6.update_yaxes(range=[1, num_pixels], showticklabels=False, showgrid=False, secondary_y=False)\n",
|
||||
" fig6.update_yaxes(title_text=\"Angular cover (mrad)\", range=[1, num_pixels], showticklabels=True, tickvals = [1, num_pixels/4, num_pixels/2, 3*num_pixels/4, num_pixels],\n",
|
||||
" ticktext = ['', np.round(detector_cover/4,1), np.round(detector_cover/2,1), np.round(3*detector_cover/4,1), np.round(detector_cover,1)], secondary_y=True) \n",
|
||||
" fig6.update_layout(width=3.85*graph_size, height=2.8*graph_size, margin = dict(l=0.6*graph_size, r=0.48*graph_size, t=0*graph_size, b=0))\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",
|
||||
" focusdepth = wavelength/(semi_angle_corr/1000)**2/1000\n",
|
||||
@ -535,6 +578,9 @@
|
||||
" 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",
|
||||
@ -546,7 +592,8 @@
|
||||
" defo = np.log(defocus)/100\n",
|
||||
" else:\n",
|
||||
" defo = 0 \n",
|
||||
" \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",
|
||||
@ -595,11 +642,18 @@
|
||||
" for x in opt.cameralengths():\n",
|
||||
" fig8.add_trace(go.Scatter(showlegend=False, x=[-width, width], y=[-np.log(x), -np.log(x)], opacity=0.3, line=dict(color='gray',width=1)))\n",
|
||||
" fig8.add_annotation(x=0.9*width, y=-np.log(x),text=str(x), showarrow=False, yshift=8)\n",
|
||||
" \n",
|
||||
"\n",
|
||||
" fig8.update_xaxes(title_text=\"\")\n",
|
||||
" # fig8.update_layout(title={'text': \"Microscope\" ,'y':1, 'x':0.10,'xanchor': 'left','yanchor': 'top'})\n",
|
||||
" fig8.update_layout(width=3.5*graph_size, height=7.2*graph_size, margin = dict(l=0.3*graph_size, r=0, t=0.0*graph_size, b=0))\n",
|
||||
" fig8.update_layout(plot_bgcolor='white')\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"\n",
|
||||
" \n",
|
||||
" \n",
|
||||
" ### FINAL CHECKS ########################################## \n",
|
||||
" align_check = dict(layout=Layout(width='200px') , style = {'description_width': '150px','button_width': \"50px\"}, disabled=True,) \n",
|
||||
@ -616,7 +670,8 @@
|
||||
" ### PROBE ##########################################\n",
|
||||
" fig = go.Figure() \n",
|
||||
" fig.update_yaxes(title_text=\"Contrast transfer func.\")\n",
|
||||
" xx = 2*wavelength/(np.sin(semi_angle_corr*omega/1000))/100\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",
|
||||
" 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",
|
||||
@ -631,15 +686,24 @@
|
||||
"\n",
|
||||
" elif ctf_xaxis == 'A':\n",
|
||||
" for x in apertury:\n",
|
||||
" d = 2*wavelength/(np.sin(pty.get_angle_corr(x)*omega/1000))/100\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",
|
||||
"\n",
|
||||
" fig.add_trace(go.Scatter(x=xx, y=pctf, marker_color='red', name=str(np.round(semi_angle_corr,2))+ ' mrad',))\n",
|
||||
" fig.update_xaxes(title_text=\"Real space distance (Å)\", range=[-0.2, 2.5], type=\"log\", zeroline=False)\n",
|
||||
" # fig.add_trace(go.Scatter(x=xx, y=pctf, marker_color='red', name=str(np.round(semi_angle_corr,2))+ ' mrad',))\n",
|
||||
"\n",
|
||||
" fig.update_layout(legend=dict(orientation=\"h\",yanchor=\"bottom\",y=0.75,xanchor=\"right\",x=1))\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",
|
||||
"\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",
|
||||
"\n",
|
||||
" \n",
|
||||
" fig.update_xaxes(title_text=\"Real space distance (Å)\", range=[-0.5, 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=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=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",
|
||||
" ### CAMERA LENGTH GRAPH ##########################################\n",
|
||||
" fig4 = make_subplots(specs=[[{\"secondary_y\": True}]])\n",
|
||||
@ -736,11 +800,23 @@
|
||||
"\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_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))\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_shape(type=\"circle\",xref=\"x\", yref=\"y\", opacity=0.9, 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=\"Probe window (nm)\", range=[0, probe_window], tickvals = [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)-0.01])\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",
|
||||
" 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",
|
||||
"\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_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(title={'text': \"Probe\",'y':0.975, 'x':0.10,'xanchor': 'left','yanchor': 'top'})\n",
|
||||
@ -824,59 +900,6 @@
|
||||
"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": "markdown",
|
||||
"id": "1e474cb7-5fd4-4113-a3fa-ddf5ca152ce5",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"\n",
|
||||
"\n",
|
||||
"Jupyter based interactive data acquisition tool designed for appropriate ptychographic data collection. It computes nessesary characteristics which play crutial role in final data reconstruction. \n",
|
||||
"You can chose of **Direct methods** (mainly Single Side Band ptychography) or **Iterative reconstruction** which takes probe defocus into account. With this tool, you can check for probe CTF, scanning step size, probe overlap, detector camera length a proper angular range collection, reconstructed probe size and many more.\n",
|
||||
"\n",
|
||||
"For more info go to https://gitlab.psi.ch/em-and-diffraction/low-dose-electron-ptychography/ptychoscopy/-/wikis/ptychoScopy\n",
|
||||
"\n",
|
||||
"### Controls\n",
|
||||
"List of controls consists of all parameters needed for proper dataset acquisition design:\n",
|
||||
"\n",
|
||||
"| Beam | | Scanning | | Camera length | | Detection | |\n",
|
||||
"|------ | ------| ------| ------| ------| ------| ------| ------|\n",
|
||||
"| **Aperture**| probe forming aperture gives probe semi-angle (α) | **Magnification**| controls image field of view | **Nominal CL** | sample to detector distance gives maximal detected angle as well as angular sampling | **Detector** | detector used for data collection | \n",
|
||||
"| **Energy** | energy of primary electron beam in keV ... gives final pixel size | **Matrix** | gives beam position to position distance + beam defocus = beam overlap | **Use PAAR** | Pumping Aperture Anglar Restriction, build-in aperture may limit maximal scattering angles for shortest camera lengths |**Binning** | reduction in pixel array size usually increas maximum frame rate |\n",
|
||||
"| **Probe** | probe setting together with chosen probe forming aperture give probe current| | | | | **Dwell time**|single position beam time ... check your detector characteristics |\n",
|
||||
"| **Defocus** | moves focus out of the sample plane - enlarges beam diameter | | | | | | |\n",
|
||||
"\n",
|
||||
"### Start the interactive gui by running the field\n",
|
||||
"```python\n",
|
||||
"display(HBox([controls, VBox([small_controls, gui])]))\n",
|
||||
"```"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 3,
|
||||
"id": "7937f054-fcd0-4e67-a20f-7696f5903a94",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"application/vnd.jupyter.widget-view+json": {
|
||||
"model_id": "a62e254754ef4b12b7434bdd4a3f7b23",
|
||||
"version_major": 2,
|
||||
"version_minor": 0
|
||||
},
|
||||
"text/plain": [
|
||||
"VBox(children=(Button(disabled=True, layout=Layout(grid_area='scanning_set', width='99%'), style=ButtonStyle(b…"
|
||||
]
|
||||
},
|
||||
"metadata": {},
|
||||
"output_type": "display_data"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"display(VBox([top_set, HBox([controls, VBox([top_set,small_controls1, gui])])]))"
|
||||
]
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
|
Reference in New Issue
Block a user