This commit is contained in:
rskoupy
2024-11-25 16:43:12 +01:00
parent 86f3885c3c
commit b47464ef62
5 changed files with 136 additions and 170 deletions

View File

@ -40,7 +40,7 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": 168,
"id": "5c5feaae-861c-4277-9dd5-aee373b3c174",
"metadata": {
"editable": true,
@ -53,7 +53,7 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "b125450f3b5147c692b7d32f30844c8e",
"model_id": "62ad0e0212ce422b9bacb692b014942a",
"version_major": 2,
"version_minor": 0
},
@ -79,7 +79,7 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 167,
"id": "fecbecdb-0fac-4ac8-a2b3-1ccb3f869a77",
"metadata": {},
"outputs": [],
@ -102,100 +102,86 @@
"except:\n",
" abtem = False\n",
"\n",
"def show_wavelength(caller):\n",
" beam_res.value = f'λ (pm) {str(\"{:.1f}\".format(pty.get_wavelength(caller.new)*1e12))}'\n",
" return beam_res.value\n",
"def show_probe_angle(caller):\n",
" aperture_res.value = f'Semi-angle (mrad) {\"{:.1f}\".format(pty.get_angle(caller.new))}' \n",
" return aperture_res.value\n",
"def show_corrprobe_angle(caller):\n",
" aperture_res2.value = f'corr. {\"{:.2f}\".format(pty.get_angle_corr(caller.new))}'\n",
" return aperture_res2.value\n",
"def show_fov(caller):\n",
" fov_res.value = f'FoV (nm) {\"{:.1f}\".format(pty.get_fov(caller.new))}'\n",
" return fov_res.value\n",
"def show_frame_rate(caller):\n",
" dwell_time_res.value = f'Rate (kHz) {\"{:.1f}\".format(pty.get_aq_frec(caller.new))}' \n",
" return dwell_time_res.value\n",
"def show_cd_det(caller):\n",
" cl_det_res.value = f'Detector CL (cm) {\"{:.1f}\".format(pty.get_cl_detector(caller.new))}' \n",
" return cl_det_res.value\n",
"\n",
"### MICROSCOPE CONTROL PANEL\n",
"image = open(\"ptychoscopy/logo.png\", \"rb\").read()\n",
"logo = widg.Image(value=image, format='png', layout=widg.Layout(grid_area='logo',width='95%',))\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",
"ali3 = dict(style = {'description_width': '110px','button_width': '45px', 'font_weight': 'bold'}, button_style='', disabled = False)\n",
"ali3 = dict(style = {'description_width': '110px','button_width': '49.2px', 'font_weight': 'bold'}, button_style='', disabled = False)\n",
"method = widg.ToggleButtons(options=[('SSB ','ssb'),('ITR ','iterative')],description='',icons=['opera','refresh'], tooltips=['Single side band ptychography', 'Iterative reconstruction methods (e.g. PIE, ML, DM)'],\n",
" layout=widg.Layout(width='95%', grid_area='methods'), style = {'button_width': '48%','font_weight': 'bold'}, button_style='', disabled = False)\n",
" layout=widg.Layout(width='97.5%', grid_area='methods'), style = {'button_width': '48%','font_weight': 'bold'}, button_style='', disabled = False)\n",
"\n",
"### Electron beam settings\n",
"beam_set = widg.Button(description='Electron beam settings',layout=widg.Layout(width='95%',grid_area='beam_set'),style=widg.ButtonStyle(button_color='#3b446b',font_weight='bold',font_size='16px',text_color='white'),disabled=False) \n",
"beam_energy = widg.Dropdown(options=pty.load_energies(), value=200, description='Beam energy (keV)', layout=widg.Layout(width='95%', grid_area='beam_set1'), **ali)\n",
"probe_size = widg.Dropdown(options=pty.load_probes(), value='8C', description='Probe', layout=widg.Layout(width='95%', grid_area='beam_set3'), **ali)\n",
"beam_energy = widg.SelectionSlider(options=pty.load_energies(), value=200, description='Beam energy (keV)', layout=widg.Layout(width='95%', grid_area='beam_set1'), **ali)\n",
"probe_size_list = pty.load_probes()\n",
"probe_size = widg.Dropdown(options=probe_size_list, value=probe_size_list[1], description='Probe', layout=widg.Layout(width='95%', grid_area='beam_set3'), **ali)\n",
"probe_size_ma = widg.BoundedFloatText(value=0, description='', min=0, disabled=False, layout=widg.Layout(width='80%', grid_area='beam_set5'))\n",
"defocus = widg.FloatSlider(description='Defocus (nm)', value=0, min=0, max=2500, step=5, readout_format='d',continuous_update=False, layout=widg.Layout(width='95%', grid_area='beam_set4'), **ali)\n",
"aperture_name = widg.Label(value = 'Aperture', layout=widg.Layout(width='95%', grid_area='aperture_name'),)\n",
"aperture = widg.ToggleButtons(options=pty.load_apertures(), description='', layout=widg.Layout(width='95%', grid_area='beam_set2'), **ali3)\n",
"aperture_list = pty.load_apertures()\n",
"aperture = widg.Dropdown(options=aperture_list, description='Aperture', value=aperture_list[1], layout=widg.Layout(width='95%', grid_area='beam_set2'), **ali)\n",
"aperture_ma = widg.BoundedFloatText(value=0, description='', min=0, disabled=False, layout=widg.Layout(width='80%', grid_area='beam_set6'))\n",
"\n",
"### Scanning parameters\n",
"scanning_set = widg.Button(description='Scanning parameters', layout=widg.Layout(width='95%', grid_area='scanning_set'),style=widg.ButtonStyle(button_color='#3b446b', font_weight= 'bold',font_size= '16px',text_color='white'),disabled = False)\n",
"mag = widg.Dropdown(options=pty.load_magnifications(), value=20, description='Magnification Mx', layout=widg.Layout(width='95%', grid_area='scanning_set1'), **ali)\n",
"matrix = widg.Dropdown(options=pty.load_mappings(), value=256, description='Matrix', layout=widg.Layout(width='95%', grid_area='scanning_set2'), **ali)\n",
"dwell_time = widg.Dropdown(options=pty.load_dwelltimes(), value=10, description='Dwell time (μs)', layout=widg.Layout(width='95%', grid_area='scanning_set3'), **ali)\n",
"step_ma = widg.BoundedFloatText(value=0, step = 0.01, description='', min=0, disabled=False, layout=widg.Layout(width='80%', grid_area='beam_set7'))\n",
"\n",
"matrix_list = pty.load_mappings()\n",
"matrix = widg.Dropdown(options=matrix_list, value=matrix_list[4], description='Scanning matrix', layout=widg.Layout(width='95%', grid_area='scanning_set2'), **ali)\n",
"dwell_time = widg.SelectionSlider(options=pty.load_dwelltimes(), value=10, description='Dwell time (μs)', layout=widg.Layout(width='95%', grid_area='scanning_set3'), **ali)\n",
"\n",
"### Detection\n",
"camera_set = widg.Button(description='Detection',layout=widg.Layout(width='95%', grid_area='camera_set'),style=widg.ButtonStyle(button_color='#3b446b', font_weight= 'bold',font_size= '16px',text_color='white'),disabled = False)\n",
"cl = widg.Dropdown(options=pty.load_cameralengths(aperture, \"nominal\"), value=8, description='Nominal CL (cm)', layout=widg.Layout(width='95%', grid_area='cl_set1'), **ali3)\n",
"cl_name = widg.Label(value = 'Nominal CL (cm)',layout=widg.Layout(width='95%', grid_area='cl_name'),)\n",
"cl = widg.ToggleButtons(options=pty.load_cameralengths(aperture, \"nominal\"), value=8, description='', layout=widg.Layout(width='95%', grid_area='cl_set1'), **ali3)\n",
"camera_name = widg.Label(value = 'Detector',layout=widg.Layout(width='95%', grid_area='camera_name'),)\n",
"camera = widg.ToggleButtons(options=pty.load_detectors(), description='', layout=widg.Layout(width='95%', grid_area='camera_set1'), style = {'description_width': '60px','button_width': str(100/len(pty.load_detectors())-len(pty.load_detectors()))+'%', 'font_weight': 'bold'}, button_style='')\n",
"restr_name = widg.Label(value = 'PAAR',layout=widg.Layout(width='95%', grid_area='restr_name'))\n",
"restr_name = widg.Label(value = 'PAAR',layout=widg.Layout(width='350px', grid_area='restr_name'))\n",
"restr = widg.ToggleButtons(options=[('.',False), ('',True)], value = False, description='',icons = ['ban','check'], layout=widg.Layout(width='95%', grid_area='camera_set2'),style = {'description_width': '80px','button_width': '48%', 'font_weight': 'bold'}, button_style='')\n",
"binning_name = widg.Label(value = 'Binning',layout=widg.Layout(width='95%', grid_area='binning_name'))\n",
"binning = widg.ToggleButtons(options=[('',1), ('2',2), ('4',4), ('8',8), ('16',16)], value=1, description='', icons = ['ban','','','',''], layout=widg.Layout(width='95%', grid_area='camera_set3'), **ali3)\n",
"camera_set6 = widg.Button(description='Post-acquisition treatments (ITR)',layout=widg.Layout(width='95%', grid_area='camera_set6'),style=widg.ButtonStyle(button_color='white', font_size= '16px',text_color='black'),disabled = False)\n",
"\n",
"\n",
"\n",
"padding = widg.SelectionSlider(options=[('none',1), ('double',2), ('triple',3), ('quadruple',4), ('quintuple',5)], value=1, description='Padding', continuous_update=False, orientation='horizontal', readout=True, layout=widg.Layout(width='95%', grid_area='camera_set4'), **ali)\n",
"pattern_resto = widg.SelectionSlider(options=[('none',1), ('double',2), ('triple',3), ('quadruple',4), ('quintuple',5)], value=1, description='Pattern recovery', continuous_update=False, orientation='horizontal', readout=True, layout=widg.Layout(width='95%', grid_area='camera_set5'), **ali)\n",
"\n",
"\n",
"\n",
"\n",
"beam_res = widg.Label(value = f'λ (pm) ' + str(\"{:.1f}\".format(pty.get_wavelength(beam_energy.value)*1e12)),layout=widg.Layout(width='auto', grid_area='sidebar1'))\n",
"aperture_res = widg.Label(value = f'Semi-angle (mrad) '+ str(\"{:.1f}\".format(pty.get_angle(aperture.value))), layout=widg.Layout(width='auto', grid_area='sidebar2'))\n",
"aperture_res2 = widg.Label(value = f'corr. ' + str(\"{:.2f}\".format(pty.get_angle_corr(aperture.value))), layout=widg.Layout(width='auto', grid_area='sidebar5'))\n",
"fov_res = widg.Label(value = f'FoV (nm) ' + str(\"{:.1f}\".format(pty.get_fov(mag.value))), layout=widg.Layout(width='auto', grid_area='sidebar3')) \n",
"dwell_time_res= widg.Label(value = f'Rate (kHz) ' + str(\"{:.1f}\".format(pty.get_aq_frec(dwell_time.value))), layout=widg.Layout(width='auto', grid_area='sidebar4')) \n",
"mag.observe(show_fov, names='value') \n",
"beam_energy.observe(show_wavelength, names='value') \n",
"aperture.observe(show_probe_angle, names='value') \n",
"dwell_time.observe(show_frame_rate, names='value') \n",
"aperture.observe(show_corrprobe_angle, names='value') \n",
"\n",
"### Visualisation\n",
"visual_set = widg.Button(description='Visualisation',layout=widg.Layout(width='95%', grid_area='visual_set'),style=widg.ButtonStyle(button_color='white', font_weight= 'bold',font_size= '16px',text_color='black'),disabled = False)\n",
"visual_set = widg.Button(description='Visualisation',layout=widg.Layout(width=perc95, grid_area='visual_set'),style=widg.ButtonStyle(button_color='white', font_weight= 'bold',font_size= '16px',text_color='black'),disabled = False)\n",
"name1 = widg.Button(description='Scale (%)',layout=widg.Layout(width='95%', grid_area='name1'),style=widg.ButtonStyle(button_color='white', font_weight= 'bold',text_color='black'), disabled = False)\n",
"graph_size = widg.IntSlider(value=100,min=75,max=125,step=5, description='', layout=widg.Layout(width='95%', grid_area='gr_size2'), button_style='primary',disabled=False,)\n",
"\n",
"### Layout\n",
"controls = widg.GridBox(children=[logo, method, beam_energy, beam_set, aperture_name, aperture, probe_size, defocus, scanning_set, mag, matrix, dwell_time, cl,camera_set, camera, camera_name, restr_name, restr, binning_name,\n",
" binning, beam_res, aperture_res, aperture_res2, fov_res, dwell_time_res, graph_size, name1, visual_set, padding, pattern_resto, camera_set6],\n",
" layout=widg.Layout(width='325px', grid_template_rows='90px 40px 35px 35px 35px 35px 35px 30px 30px 35px 35px 35px 35px 35px 35px 35px 35px 35px 35px 95px 35px 35px 35px', grid_template_columns='20% 10% 30% 15% 25%', grid_template_areas='''\n",
"controls = widg.GridBox(children=[logo, method, beam_energy, beam_set, aperture, probe_size, defocus, scanning_set, mag, matrix, dwell_time, cl, camera_set, camera, camera_name, restr_name, restr, binning_name,\n",
" binning, aperture_res, aperture_res2, graph_size, name1, visual_set, padding, pattern_resto, camera_set6, probe_size_ma, aperture_ma, step_ma,cl_name],\n",
" layout=widg.Layout(width='355px', grid_template_rows='90px 40px 35px 35px 35px 35px 35px 30px 30px 35px 35px 35px 35px 62px 35px 35px 35px 35px 35px 95px 35px 35px 35px', grid_template_columns='20% 10% 30% 15% 25%', grid_template_areas='''\n",
" \"logo logo logo logo logo \" \n",
" \"methods methods methods methods methods \"\n",
" \"beam_set beam_set beam_set beam_set beam_set \" \n",
" \"beam_set1 beam_set1 beam_set1 beam_set1 beam_set1 \"\n",
" \"beam_set3 beam_set3 beam_set3 beam_set3 beam_set3 \"\n",
" \"beam_set4 beam_set4 beam_set4 beam_set4 beam_set4 \"\n",
" \"aperture_name beam_set2 beam_set2 beam_set2 beam_set2 \"\n",
" \"beam_set4 beam_set4 beam_set4 beam_set4 beam_set4 \"\n",
" \"beam_set3 beam_set3 beam_set3 beam_set3 beam_set5 \"\n",
" \"beam_set2 beam_set2 beam_set2 beam_set2 beam_set6 \"\n",
" \". sidebar2 sidebar2 sidebar2 sidebar5 \"\n",
"\n",
" \"scanning_set scanning_set scanning_set scanning_set scanning_set \" \n",
" \"scanning_set1 scanning_set1 scanning_set1 scanning_set1 scanning_set1\"\n",
" \"scanning_set1 scanning_set1 scanning_set1 scanning_set1 beam_set7\"\n",
" \"scanning_set2 scanning_set2 scanning_set2 scanning_set2 scanning_set2\"\n",
" \"scanning_set3 scanning_set3 scanning_set3 scanning_set3 scanning_set3\"\n",
" \"camera_set camera_set camera_set camera_set camera_set \"\n",
" \"cl_set1 cl_set1 cl_set1 cl_set1 cl_set1 \"\n",
" \"cl_name cl_set1 cl_set1 cl_set1 cl_set1 \"\n",
" \"camera_name camera_set1 camera_set1 camera_set1 camera_set1 \"\n",
" \"restr_name camera_set2 camera_set2 camera_set2 camera_set2 \"\n",
" \"binning_name camera_set3 camera_set3 camera_set3 camera_set3 \"\n",
@ -210,16 +196,16 @@
"style = {'description_width': 'initial'}\n",
"style2 = {'description_width': '200px'}\n",
"top_set = widg.Button(description='',layout=widg.Layout(width='%', grid_area='scanning_set'), style=widg.ButtonStyle(button_color='white', font_weight= 'bold',font_size= '16px',text_color='#0d48a1'),disabled = True)\n",
"style_graph = widg.ButtonStyle(button_color='#F5F5F5', font_weight= 'bold',font_size= '16px',text_color='black')\n",
"style_graph = widg.ButtonStyle(button_color='#3b446b', font_weight= 'bold',font_size= '16px', text_color='white')\n",
"\n",
"### PCTF\n",
"ctf_set = widg.Button(description='Phase CTF',layout=widg.Layout(width='100%', grid_area='ctf_set'), style=style_graph,disabled = True)\n",
"ctf_set = widg.Button(description='Phase CTF',layout=widg.Layout(width='100%', grid_area='ctf_set'), style=style_graph, disabled = False)\n",
"ctf_xaxis_name = widg.Label(value = 'x-axis',layout=widg.Layout(width='95%', grid_area='ctf_xaxis_name'),)\n",
"ctf_xaxis = widg.ToggleButtons(options=['ω','mrad', 'Å'], layout=widg.Layout(grid_area='ctxaxis'), style = {'button_width': '30%'}, disabled=False)\n",
"element = widg.Dropdown(options=pty.load_elements(), description='Element (ITR)', layout=widg.Layout(width='95%', grid_area='ctf_element'))\n",
"\n",
"### Sample\n",
"sample_set = widg.Button(description='Sample',layout=widg.Layout(width='100%', grid_area='sample_set'), style=style_graph, disabled = True)\n",
"sample_set = widg.Button(description='Sample',layout=widg.Layout(width='100%', grid_area='sample_set'), style=style_graph, disabled = False)\n",
"overlap_fig = widg.ToggleButtons(options=[('Geometrical', 'geom'),('Simulated: A', 'simA'),('Simulated: I', 'simI')], layout=widg.Layout(grid_area='overlap_fig'), style = {'button_width': '30%'}, disabled=False)\n",
"fov_show = widg.BoundedFloatText(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=widg.Layout(grid_area='fov_show', width = '115px'),style={'description_width': '55px'})\n",
"beam_pos = widg.BoundedIntText(value=4,min=4,max=100,step=2,description='Add beams:', disabled=False,continuous_update=False,orientation='horizontal',readout=True,readout_format='d',layout=widg.Layout(grid_area='beam_pos', width = '120px'),style={'description_width': '70px'})\n",
@ -229,7 +215,7 @@
"rs_sampling = widg.Dropdown(options=[('Overlap', 'overlap'), ('Linear sampling', 'linear'), ('Areal sampling', 'areal')], description='',layout=widg.Layout(grid_area='rs_sampling', width = '115px'),style={'description_width': '0px'})\n",
"\n",
"### Camera length based limitations and checks\n",
"cl_set = widg.Button(description='Camera length based limitations and checks for ITR', layout=widg.Layout(width='100%', grid_area='cl_set'), style=style_graph, disabled = True)\n",
"cl_set = widg.Button(description='Camera length based limitations and checks for ITR', layout=widg.Layout(width='100%', grid_area='cl_set'), style=style_graph, disabled = False)\n",
"check0name = widg.IntRangeSlider(value=[1,6],min=0, max=10,step=1, description='Detector coverage (α):', disabled=False, continuous_update=False, orientation='horizontal',readout=True, readout_format='d',layout=widg.Layout(grid_area='check0name', width = '100%'),style=style)\n",
"check1name = widg.BoundedIntText(value=10,min=0,max=50,step=1,description='Small angle approx. (°):', disabled=False,continuous_update=False,orientation='horizontal',readout=True,readout_format='d',layout=widg.Layout(grid_area='check1name', width = '200px'),style={'description_width': '140px'})\n",
"check2name = widg.BoundedFloatText(value=1,min=0.5,max=5,step=0.5, description='Resolution gain:', disabled=False,continuous_update=False,orientation='horizontal',readout=True, readout_format='.1f', layout=widg.Layout(grid_area='check2name', width = '200px'), style={'description_width': '140px'})\n",
@ -246,22 +232,36 @@
" \". . . . . . . . . . . \"''')) \n",
"\n",
"def ptycho_interact(beam_energy, aperture, aperture_res, aperture_res2, probe_size, cl, matrix, defocus, mag, camera, binning, dwell_time, restr, method,\n",
" ctf_xaxis, element, graph_size, beam_pos, fov_show, overlap_fig, red_box, box_col, check0name, check1name, check2name, check4name, check6name, prof_show, padding, pattern_resto, rs_sampling):\n",
" ctf_xaxis, element, graph_size, beam_pos, fov_show, overlap_fig, red_box, box_col, check0name, check1name, check2name, check4name, check6name, prof_show, padding, pattern_resto, rs_sampling, probe_size_ma, aperture_ma, step_ma):\n",
"\n",
" fov = pty.get_fov(mag) \n",
" if probe_size == \"user def. (pA)\":\n",
" current = probe_size_ma\n",
" else:\n",
" current = pty.get_current(probe_size,aperture) \n",
" \n",
" if aperture == \"user def. (mrad)\":\n",
" semi_angle = aperture_ma\n",
" semi_angle_corr = aperture_ma\n",
" else:\n",
" semi_angle = pty.get_angle(aperture)\n",
" semi_angle_corr = pty.get_angle_corr(aperture)\n",
"\n",
" if mag == \"user def. step (A)\":\n",
" step_size_corr = step_ma/10\n",
" fov = (matrix)*step_size_corr\n",
" else:\n",
" fov = pty.get_fov(mag) \n",
" step_size = pty.get_step_size(fov,matrix) # in nm\n",
" step_size_corr = np.array(pty.get_step_correction())*pty.get_step_size(fov, matrix) # in nm\n",
"\n",
" beam_diameter = pty.get_beam_diameter(aperture, defocus, semi_angle_corr)\n",
" pctf_itr = pty.get_ctf(element)\n",
" cl_det = pty.get_cl_detector(cl, camera)\n",
" step_size = pty.get_step_size(fov, matrix) # in nm\n",
" semi_angle = pty.get_angle(aperture)\n",
" omega_itr = np.array(pty.get_omegas())\n",
" frame_rate = pty.get_aq_frec(dwell_time)\n",
" current = pty.get_current(probe_size,aperture) \n",
" wavelength = pty.get_wavelength(beam_energy)*1e12 # in pm\n",
" semi_angle_corr = pty.get_angle_corr(aperture) \n",
" wavelength = pty.get_wavelength(beam_energy)*1e12 # in pm \n",
" pixel_angle = pty.get_pixel_angle(cl, camera, binning)\n",
" beam_diameter = pty.get_beam_diameter(aperture, defocus, semi_angle_corr)\n",
" num_pixels, size_pixel = pty.get_detector(camera, binning)\n",
" step_size_corr = np.array(pty.get_step_correction())*pty.get_step_size(fov, matrix) # in nm\n",
" beam_diameter_pix = 2*semi_angle_corr/pixel_angle\n",
" detector_cover = num_pixels/2*pixel_angle\n",
" covered_alfas = detector_cover/semi_angle_corr\n",
@ -425,24 +425,6 @@
"\n",
" fig1.update_layout(width=2.9*graph_size, height=3.7*graph_size, plot_bgcolor='white', margin =dict(l=0.2*graph_size, r=0.1*graph_size, t=0.8*graph_size, b=0),\n",
" legend=dict(orientation=\"v\",yanchor=\"bottom\",y=1.01,xanchor=\"right\",x=1), title={'text': \"Sample\",'y': 0.87, 'x': 0.1,'xanchor': 'left','yanchor': 'top'})\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
" \n",
" case overlap_fig if overlap_fig in ['simI', 'simA']:\n",
" if abtem == True:\n",
@ -731,7 +713,11 @@
" cltab = widg.HBox([legend, dictionary[0], dictionary[1], dictionary[2], dictionary[3], dictionary[4], dictionary[5], dictionary[6], dictionary[7], dictionary[8], dictionary[9]])\n",
" case 11: \n",
" cltab = widg.HBox([legend, dictionary[0], dictionary[1], dictionary[2], dictionary[3], dictionary[4], dictionary[5], dictionary[6], dictionary[7], dictionary[8], dictionary[9], dictionary[10]])\n",
"\n",
" case 12: \n",
" cltab = widg.HBox([legend, dictionary[0], dictionary[1], dictionary[2], dictionary[3], dictionary[4], dictionary[5], dictionary[6], dictionary[7], dictionary[8], dictionary[9], dictionary[10], dictionary[11]])\n",
" case 13: \n",
" cltab = widg.HBox([legend, dictionary[0], dictionary[1], dictionary[2], dictionary[3], dictionary[4], dictionary[5], dictionary[6], dictionary[7], dictionary[8], dictionary[9], dictionary[10], dictionary[11], dictionary[12]])\n",
" \n",
" cltab = widg.VBox([widg.Label('CAMERA LENGTH GUIDE'), cltab])\n",
" cltab.layout = widg.Layout(border='solid 0px gray',margin='0px 0px 0px 15px', padding='5px 5px 5px 5px')\n",
"\n",
@ -746,8 +732,6 @@
" check3_ssb = widg.Valid(value= bool(3 < beam_diameter_pix) , description='Minimal BF size', layout=widg.Layout(width=check_width), style = {'description_width': check_descr_width}, disabled=True)\n",
" checks_ssb = widg.VBox([check1_ssb, check2_ssb,check3_ssb]) # Label('Final checks')\n",
" checks_ssb.layout = widg.Layout(margin='100px 0px 0px 30px', padding='0px 0px 0px 0px', border='solid 0px gray') # border='dashed 1px gray'\n",
"\n",
"\n",
" right = widg.VBox([go.FigureWidget(fig1), widg.HBox([go.FigureWidget(fig4), checks_ssb]) ])\n",
" \n",
" case 'iterative':\n",
@ -760,7 +744,6 @@
" check5_itr = widg.Valid(value= bool(oversampling > pattern_resto), description='Pattern recovery', layout=widg.Layout(width=check_width), style = {'description_width': check_descr_width}, disabled=True) \n",
" checks_itr = widg.HBox([widg.VBox([check1_itr, check2_itr]), widg.VBox([check3_itr, check4_itr]), widg.VBox([check5_itr])]) # Label('Final checks')\n",
" checks_itr.layout = widg.Layout(margin='0px 0px 0px 5px', padding='0px 0px 0px 0px', border='solid 0px gray') # border='dashed 1px gray'\n",
"\n",
" right = widg.VBox([widg.HBox([go.FigureWidget(fig1),go.FigureWidget(fig3)]), cltab, checks_itr])\n",
" \n",
" total = widg.HBox([left, go.FigureWidget(fig), right]) \n",
@ -768,10 +751,10 @@
" display(total)\n",
" return \n",
" \n",
"gui = widg.interactive_output(ptycho_interact, {\"beam_energy\" : beam_energy, \"aperture\": aperture, \"aperture_res\": aperture_res, \"aperture_res2\": aperture_res2, \"probe_size\": probe_size, \"cl\": cl, \"matrix\": matrix,\n",
" \"defocus\": defocus, \"mag\": mag, \"camera\": camera, \"binning\": binning, \"dwell_time\" : dwell_time, \"restr\": restr, \"method\": method, \"ctf_xaxis\": ctf_xaxis, \"element\": element,\n",
" \"graph_size\": graph_size, \"beam_pos\": beam_pos, \"fov_show\": fov_show, \"overlap_fig\" :overlap_fig, \"red_box\": red_box, \"box_col\":box_col, \"check0name\":check0name, \n",
" \"check1name\": check1name, \"check2name\": check2name, \"check4name\": check4name, \"check6name\": check6name, \"prof_show\":prof_show, \"padding\":padding, \"pattern_resto\":pattern_resto, \"rs_sampling\": rs_sampling}) \n",
"gui = widg.interactive_output(ptycho_interact, {\"beam_energy\" : beam_energy, \"aperture\": aperture, \"aperture_res\": aperture_res, \"aperture_res2\": aperture_res2, \"probe_size\": probe_size, \"cl\": cl, \"matrix\": matrix, \"defocus\": defocus, \"mag\": mag,\n",
" \"camera\": camera, \"binning\": binning, \"dwell_time\" : dwell_time, \"restr\": restr, \"method\": method, \"ctf_xaxis\": ctf_xaxis, \"element\": element, \"graph_size\": graph_size, \"beam_pos\": beam_pos,\n",
" \"fov_show\": fov_show, \"overlap_fig\" :overlap_fig, \"red_box\": red_box, \"box_col\":box_col, \"check0name\":check0name, \"check1name\": check1name, \"check2name\": check2name, \"check4name\": check4name,\n",
" \"check6name\": check6name, \"prof_show\":prof_show, \"padding\":padding, \"pattern_resto\":pattern_resto, \"rs_sampling\": rs_sampling, \"probe_size_ma\": probe_size_ma, \"aperture_ma\": aperture_ma, \"step_ma\": step_ma }) \n",
"\n",
"ptychoscopy = widg.VBox([top_set, widg.HBox([controls, widg.VBox([graph_controls, gui])])])"
]

View File

@ -40,7 +40,7 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": 168,
"id": "5c5feaae-861c-4277-9dd5-aee373b3c174",
"metadata": {
"editable": true,
@ -53,7 +53,7 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "b125450f3b5147c692b7d32f30844c8e",
"model_id": "62ad0e0212ce422b9bacb692b014942a",
"version_major": 2,
"version_minor": 0
},
@ -79,7 +79,7 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 167,
"id": "fecbecdb-0fac-4ac8-a2b3-1ccb3f869a77",
"metadata": {},
"outputs": [],
@ -102,100 +102,86 @@
"except:\n",
" abtem = False\n",
"\n",
"def show_wavelength(caller):\n",
" beam_res.value = f'λ (pm) {str(\"{:.1f}\".format(pty.get_wavelength(caller.new)*1e12))}'\n",
" return beam_res.value\n",
"def show_probe_angle(caller):\n",
" aperture_res.value = f'Semi-angle (mrad) {\"{:.1f}\".format(pty.get_angle(caller.new))}' \n",
" return aperture_res.value\n",
"def show_corrprobe_angle(caller):\n",
" aperture_res2.value = f'corr. {\"{:.2f}\".format(pty.get_angle_corr(caller.new))}'\n",
" return aperture_res2.value\n",
"def show_fov(caller):\n",
" fov_res.value = f'FoV (nm) {\"{:.1f}\".format(pty.get_fov(caller.new))}'\n",
" return fov_res.value\n",
"def show_frame_rate(caller):\n",
" dwell_time_res.value = f'Rate (kHz) {\"{:.1f}\".format(pty.get_aq_frec(caller.new))}' \n",
" return dwell_time_res.value\n",
"def show_cd_det(caller):\n",
" cl_det_res.value = f'Detector CL (cm) {\"{:.1f}\".format(pty.get_cl_detector(caller.new))}' \n",
" return cl_det_res.value\n",
"\n",
"### MICROSCOPE CONTROL PANEL\n",
"image = open(\"ptychoscopy/logo.png\", \"rb\").read()\n",
"logo = widg.Image(value=image, format='png', layout=widg.Layout(grid_area='logo',width='95%',))\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",
"ali3 = dict(style = {'description_width': '110px','button_width': '45px', 'font_weight': 'bold'}, button_style='', disabled = False)\n",
"ali3 = dict(style = {'description_width': '110px','button_width': '49.2px', 'font_weight': 'bold'}, button_style='', disabled = False)\n",
"method = widg.ToggleButtons(options=[('SSB ','ssb'),('ITR ','iterative')],description='',icons=['opera','refresh'], tooltips=['Single side band ptychography', 'Iterative reconstruction methods (e.g. PIE, ML, DM)'],\n",
" layout=widg.Layout(width='95%', grid_area='methods'), style = {'button_width': '48%','font_weight': 'bold'}, button_style='', disabled = False)\n",
" layout=widg.Layout(width='97.5%', grid_area='methods'), style = {'button_width': '48%','font_weight': 'bold'}, button_style='', disabled = False)\n",
"\n",
"### Electron beam settings\n",
"beam_set = widg.Button(description='Electron beam settings',layout=widg.Layout(width='95%',grid_area='beam_set'),style=widg.ButtonStyle(button_color='#3b446b',font_weight='bold',font_size='16px',text_color='white'),disabled=False) \n",
"beam_energy = widg.Dropdown(options=pty.load_energies(), value=200, description='Beam energy (keV)', layout=widg.Layout(width='95%', grid_area='beam_set1'), **ali)\n",
"probe_size = widg.Dropdown(options=pty.load_probes(), value='8C', description='Probe', layout=widg.Layout(width='95%', grid_area='beam_set3'), **ali)\n",
"beam_energy = widg.SelectionSlider(options=pty.load_energies(), value=200, description='Beam energy (keV)', layout=widg.Layout(width='95%', grid_area='beam_set1'), **ali)\n",
"probe_size_list = pty.load_probes()\n",
"probe_size = widg.Dropdown(options=probe_size_list, value=probe_size_list[1], description='Probe', layout=widg.Layout(width='95%', grid_area='beam_set3'), **ali)\n",
"probe_size_ma = widg.BoundedFloatText(value=0, description='', min=0, disabled=False, layout=widg.Layout(width='80%', grid_area='beam_set5'))\n",
"defocus = widg.FloatSlider(description='Defocus (nm)', value=0, min=0, max=2500, step=5, readout_format='d',continuous_update=False, layout=widg.Layout(width='95%', grid_area='beam_set4'), **ali)\n",
"aperture_name = widg.Label(value = 'Aperture', layout=widg.Layout(width='95%', grid_area='aperture_name'),)\n",
"aperture = widg.ToggleButtons(options=pty.load_apertures(), description='', layout=widg.Layout(width='95%', grid_area='beam_set2'), **ali3)\n",
"aperture_list = pty.load_apertures()\n",
"aperture = widg.Dropdown(options=aperture_list, description='Aperture', value=aperture_list[1], layout=widg.Layout(width='95%', grid_area='beam_set2'), **ali)\n",
"aperture_ma = widg.BoundedFloatText(value=0, description='', min=0, disabled=False, layout=widg.Layout(width='80%', grid_area='beam_set6'))\n",
"\n",
"### Scanning parameters\n",
"scanning_set = widg.Button(description='Scanning parameters', layout=widg.Layout(width='95%', grid_area='scanning_set'),style=widg.ButtonStyle(button_color='#3b446b', font_weight= 'bold',font_size= '16px',text_color='white'),disabled = False)\n",
"mag = widg.Dropdown(options=pty.load_magnifications(), value=20, description='Magnification Mx', layout=widg.Layout(width='95%', grid_area='scanning_set1'), **ali)\n",
"matrix = widg.Dropdown(options=pty.load_mappings(), value=256, description='Matrix', layout=widg.Layout(width='95%', grid_area='scanning_set2'), **ali)\n",
"dwell_time = widg.Dropdown(options=pty.load_dwelltimes(), value=10, description='Dwell time (μs)', layout=widg.Layout(width='95%', grid_area='scanning_set3'), **ali)\n",
"step_ma = widg.BoundedFloatText(value=0, step = 0.01, description='', min=0, disabled=False, layout=widg.Layout(width='80%', grid_area='beam_set7'))\n",
"\n",
"matrix_list = pty.load_mappings()\n",
"matrix = widg.Dropdown(options=matrix_list, value=matrix_list[4], description='Scanning matrix', layout=widg.Layout(width='95%', grid_area='scanning_set2'), **ali)\n",
"dwell_time = widg.SelectionSlider(options=pty.load_dwelltimes(), value=10, description='Dwell time (μs)', layout=widg.Layout(width='95%', grid_area='scanning_set3'), **ali)\n",
"\n",
"### Detection\n",
"camera_set = widg.Button(description='Detection',layout=widg.Layout(width='95%', grid_area='camera_set'),style=widg.ButtonStyle(button_color='#3b446b', font_weight= 'bold',font_size= '16px',text_color='white'),disabled = False)\n",
"cl = widg.Dropdown(options=pty.load_cameralengths(aperture, \"nominal\"), value=8, description='Nominal CL (cm)', layout=widg.Layout(width='95%', grid_area='cl_set1'), **ali3)\n",
"cl_name = widg.Label(value = 'Nominal CL (cm)',layout=widg.Layout(width='95%', grid_area='cl_name'),)\n",
"cl = widg.ToggleButtons(options=pty.load_cameralengths(aperture, \"nominal\"), value=8, description='', layout=widg.Layout(width='95%', grid_area='cl_set1'), **ali3)\n",
"camera_name = widg.Label(value = 'Detector',layout=widg.Layout(width='95%', grid_area='camera_name'),)\n",
"camera = widg.ToggleButtons(options=pty.load_detectors(), description='', layout=widg.Layout(width='95%', grid_area='camera_set1'), style = {'description_width': '60px','button_width': str(100/len(pty.load_detectors())-len(pty.load_detectors()))+'%', 'font_weight': 'bold'}, button_style='')\n",
"restr_name = widg.Label(value = 'PAAR',layout=widg.Layout(width='95%', grid_area='restr_name'))\n",
"restr_name = widg.Label(value = 'PAAR',layout=widg.Layout(width='350px', grid_area='restr_name'))\n",
"restr = widg.ToggleButtons(options=[('.',False), ('',True)], value = False, description='',icons = ['ban','check'], layout=widg.Layout(width='95%', grid_area='camera_set2'),style = {'description_width': '80px','button_width': '48%', 'font_weight': 'bold'}, button_style='')\n",
"binning_name = widg.Label(value = 'Binning',layout=widg.Layout(width='95%', grid_area='binning_name'))\n",
"binning = widg.ToggleButtons(options=[('',1), ('2',2), ('4',4), ('8',8), ('16',16)], value=1, description='', icons = ['ban','','','',''], layout=widg.Layout(width='95%', grid_area='camera_set3'), **ali3)\n",
"camera_set6 = widg.Button(description='Post-acquisition treatments (ITR)',layout=widg.Layout(width='95%', grid_area='camera_set6'),style=widg.ButtonStyle(button_color='white', font_size= '16px',text_color='black'),disabled = False)\n",
"\n",
"\n",
"\n",
"padding = widg.SelectionSlider(options=[('none',1), ('double',2), ('triple',3), ('quadruple',4), ('quintuple',5)], value=1, description='Padding', continuous_update=False, orientation='horizontal', readout=True, layout=widg.Layout(width='95%', grid_area='camera_set4'), **ali)\n",
"pattern_resto = widg.SelectionSlider(options=[('none',1), ('double',2), ('triple',3), ('quadruple',4), ('quintuple',5)], value=1, description='Pattern recovery', continuous_update=False, orientation='horizontal', readout=True, layout=widg.Layout(width='95%', grid_area='camera_set5'), **ali)\n",
"\n",
"\n",
"\n",
"\n",
"beam_res = widg.Label(value = f'λ (pm) ' + str(\"{:.1f}\".format(pty.get_wavelength(beam_energy.value)*1e12)),layout=widg.Layout(width='auto', grid_area='sidebar1'))\n",
"aperture_res = widg.Label(value = f'Semi-angle (mrad) '+ str(\"{:.1f}\".format(pty.get_angle(aperture.value))), layout=widg.Layout(width='auto', grid_area='sidebar2'))\n",
"aperture_res2 = widg.Label(value = f'corr. ' + str(\"{:.2f}\".format(pty.get_angle_corr(aperture.value))), layout=widg.Layout(width='auto', grid_area='sidebar5'))\n",
"fov_res = widg.Label(value = f'FoV (nm) ' + str(\"{:.1f}\".format(pty.get_fov(mag.value))), layout=widg.Layout(width='auto', grid_area='sidebar3')) \n",
"dwell_time_res= widg.Label(value = f'Rate (kHz) ' + str(\"{:.1f}\".format(pty.get_aq_frec(dwell_time.value))), layout=widg.Layout(width='auto', grid_area='sidebar4')) \n",
"mag.observe(show_fov, names='value') \n",
"beam_energy.observe(show_wavelength, names='value') \n",
"aperture.observe(show_probe_angle, names='value') \n",
"dwell_time.observe(show_frame_rate, names='value') \n",
"aperture.observe(show_corrprobe_angle, names='value') \n",
"\n",
"### Visualisation\n",
"visual_set = widg.Button(description='Visualisation',layout=widg.Layout(width='95%', grid_area='visual_set'),style=widg.ButtonStyle(button_color='white', font_weight= 'bold',font_size= '16px',text_color='black'),disabled = False)\n",
"visual_set = widg.Button(description='Visualisation',layout=widg.Layout(width=perc95, grid_area='visual_set'),style=widg.ButtonStyle(button_color='white', font_weight= 'bold',font_size= '16px',text_color='black'),disabled = False)\n",
"name1 = widg.Button(description='Scale (%)',layout=widg.Layout(width='95%', grid_area='name1'),style=widg.ButtonStyle(button_color='white', font_weight= 'bold',text_color='black'), disabled = False)\n",
"graph_size = widg.IntSlider(value=100,min=75,max=125,step=5, description='', layout=widg.Layout(width='95%', grid_area='gr_size2'), button_style='primary',disabled=False,)\n",
"\n",
"### Layout\n",
"controls = widg.GridBox(children=[logo, method, beam_energy, beam_set, aperture_name, aperture, probe_size, defocus, scanning_set, mag, matrix, dwell_time, cl,camera_set, camera, camera_name, restr_name, restr, binning_name,\n",
" binning, beam_res, aperture_res, aperture_res2, fov_res, dwell_time_res, graph_size, name1, visual_set, padding, pattern_resto, camera_set6],\n",
" layout=widg.Layout(width='325px', grid_template_rows='90px 40px 35px 35px 35px 35px 35px 30px 30px 35px 35px 35px 35px 35px 35px 35px 35px 35px 35px 95px 35px 35px 35px', grid_template_columns='20% 10% 30% 15% 25%', grid_template_areas='''\n",
"controls = widg.GridBox(children=[logo, method, beam_energy, beam_set, aperture, probe_size, defocus, scanning_set, mag, matrix, dwell_time, cl, camera_set, camera, camera_name, restr_name, restr, binning_name,\n",
" binning, aperture_res, aperture_res2, graph_size, name1, visual_set, padding, pattern_resto, camera_set6, probe_size_ma, aperture_ma, step_ma,cl_name],\n",
" layout=widg.Layout(width='355px', grid_template_rows='90px 40px 35px 35px 35px 35px 35px 30px 30px 35px 35px 35px 35px 62px 35px 35px 35px 35px 35px 95px 35px 35px 35px', grid_template_columns='20% 10% 30% 15% 25%', grid_template_areas='''\n",
" \"logo logo logo logo logo \" \n",
" \"methods methods methods methods methods \"\n",
" \"beam_set beam_set beam_set beam_set beam_set \" \n",
" \"beam_set1 beam_set1 beam_set1 beam_set1 beam_set1 \"\n",
" \"beam_set3 beam_set3 beam_set3 beam_set3 beam_set3 \"\n",
" \"beam_set4 beam_set4 beam_set4 beam_set4 beam_set4 \"\n",
" \"aperture_name beam_set2 beam_set2 beam_set2 beam_set2 \"\n",
" \"beam_set4 beam_set4 beam_set4 beam_set4 beam_set4 \"\n",
" \"beam_set3 beam_set3 beam_set3 beam_set3 beam_set5 \"\n",
" \"beam_set2 beam_set2 beam_set2 beam_set2 beam_set6 \"\n",
" \". sidebar2 sidebar2 sidebar2 sidebar5 \"\n",
"\n",
" \"scanning_set scanning_set scanning_set scanning_set scanning_set \" \n",
" \"scanning_set1 scanning_set1 scanning_set1 scanning_set1 scanning_set1\"\n",
" \"scanning_set1 scanning_set1 scanning_set1 scanning_set1 beam_set7\"\n",
" \"scanning_set2 scanning_set2 scanning_set2 scanning_set2 scanning_set2\"\n",
" \"scanning_set3 scanning_set3 scanning_set3 scanning_set3 scanning_set3\"\n",
" \"camera_set camera_set camera_set camera_set camera_set \"\n",
" \"cl_set1 cl_set1 cl_set1 cl_set1 cl_set1 \"\n",
" \"cl_name cl_set1 cl_set1 cl_set1 cl_set1 \"\n",
" \"camera_name camera_set1 camera_set1 camera_set1 camera_set1 \"\n",
" \"restr_name camera_set2 camera_set2 camera_set2 camera_set2 \"\n",
" \"binning_name camera_set3 camera_set3 camera_set3 camera_set3 \"\n",
@ -210,16 +196,16 @@
"style = {'description_width': 'initial'}\n",
"style2 = {'description_width': '200px'}\n",
"top_set = widg.Button(description='',layout=widg.Layout(width='%', grid_area='scanning_set'), style=widg.ButtonStyle(button_color='white', font_weight= 'bold',font_size= '16px',text_color='#0d48a1'),disabled = True)\n",
"style_graph = widg.ButtonStyle(button_color='#F5F5F5', font_weight= 'bold',font_size= '16px',text_color='black')\n",
"style_graph = widg.ButtonStyle(button_color='#3b446b', font_weight= 'bold',font_size= '16px', text_color='white')\n",
"\n",
"### PCTF\n",
"ctf_set = widg.Button(description='Phase CTF',layout=widg.Layout(width='100%', grid_area='ctf_set'), style=style_graph,disabled = True)\n",
"ctf_set = widg.Button(description='Phase CTF',layout=widg.Layout(width='100%', grid_area='ctf_set'), style=style_graph, disabled = False)\n",
"ctf_xaxis_name = widg.Label(value = 'x-axis',layout=widg.Layout(width='95%', grid_area='ctf_xaxis_name'),)\n",
"ctf_xaxis = widg.ToggleButtons(options=['ω','mrad', 'Å'], layout=widg.Layout(grid_area='ctxaxis'), style = {'button_width': '30%'}, disabled=False)\n",
"element = widg.Dropdown(options=pty.load_elements(), description='Element (ITR)', layout=widg.Layout(width='95%', grid_area='ctf_element'))\n",
"\n",
"### Sample\n",
"sample_set = widg.Button(description='Sample',layout=widg.Layout(width='100%', grid_area='sample_set'), style=style_graph, disabled = True)\n",
"sample_set = widg.Button(description='Sample',layout=widg.Layout(width='100%', grid_area='sample_set'), style=style_graph, disabled = False)\n",
"overlap_fig = widg.ToggleButtons(options=[('Geometrical', 'geom'),('Simulated: A', 'simA'),('Simulated: I', 'simI')], layout=widg.Layout(grid_area='overlap_fig'), style = {'button_width': '30%'}, disabled=False)\n",
"fov_show = widg.BoundedFloatText(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=widg.Layout(grid_area='fov_show', width = '115px'),style={'description_width': '55px'})\n",
"beam_pos = widg.BoundedIntText(value=4,min=4,max=100,step=2,description='Add beams:', disabled=False,continuous_update=False,orientation='horizontal',readout=True,readout_format='d',layout=widg.Layout(grid_area='beam_pos', width = '120px'),style={'description_width': '70px'})\n",
@ -229,7 +215,7 @@
"rs_sampling = widg.Dropdown(options=[('Overlap', 'overlap'), ('Linear sampling', 'linear'), ('Areal sampling', 'areal')], description='',layout=widg.Layout(grid_area='rs_sampling', width = '115px'),style={'description_width': '0px'})\n",
"\n",
"### Camera length based limitations and checks\n",
"cl_set = widg.Button(description='Camera length based limitations and checks for ITR', layout=widg.Layout(width='100%', grid_area='cl_set'), style=style_graph, disabled = True)\n",
"cl_set = widg.Button(description='Camera length based limitations and checks for ITR', layout=widg.Layout(width='100%', grid_area='cl_set'), style=style_graph, disabled = False)\n",
"check0name = widg.IntRangeSlider(value=[1,6],min=0, max=10,step=1, description='Detector coverage (α):', disabled=False, continuous_update=False, orientation='horizontal',readout=True, readout_format='d',layout=widg.Layout(grid_area='check0name', width = '100%'),style=style)\n",
"check1name = widg.BoundedIntText(value=10,min=0,max=50,step=1,description='Small angle approx. (°):', disabled=False,continuous_update=False,orientation='horizontal',readout=True,readout_format='d',layout=widg.Layout(grid_area='check1name', width = '200px'),style={'description_width': '140px'})\n",
"check2name = widg.BoundedFloatText(value=1,min=0.5,max=5,step=0.5, description='Resolution gain:', disabled=False,continuous_update=False,orientation='horizontal',readout=True, readout_format='.1f', layout=widg.Layout(grid_area='check2name', width = '200px'), style={'description_width': '140px'})\n",
@ -246,22 +232,36 @@
" \". . . . . . . . . . . \"''')) \n",
"\n",
"def ptycho_interact(beam_energy, aperture, aperture_res, aperture_res2, probe_size, cl, matrix, defocus, mag, camera, binning, dwell_time, restr, method,\n",
" ctf_xaxis, element, graph_size, beam_pos, fov_show, overlap_fig, red_box, box_col, check0name, check1name, check2name, check4name, check6name, prof_show, padding, pattern_resto, rs_sampling):\n",
" ctf_xaxis, element, graph_size, beam_pos, fov_show, overlap_fig, red_box, box_col, check0name, check1name, check2name, check4name, check6name, prof_show, padding, pattern_resto, rs_sampling, probe_size_ma, aperture_ma, step_ma):\n",
"\n",
" fov = pty.get_fov(mag) \n",
" if probe_size == \"user def. (pA)\":\n",
" current = probe_size_ma\n",
" else:\n",
" current = pty.get_current(probe_size,aperture) \n",
" \n",
" if aperture == \"user def. (mrad)\":\n",
" semi_angle = aperture_ma\n",
" semi_angle_corr = aperture_ma\n",
" else:\n",
" semi_angle = pty.get_angle(aperture)\n",
" semi_angle_corr = pty.get_angle_corr(aperture)\n",
"\n",
" if mag == \"user def. step (A)\":\n",
" step_size_corr = step_ma/10\n",
" fov = (matrix)*step_size_corr\n",
" else:\n",
" fov = pty.get_fov(mag) \n",
" step_size = pty.get_step_size(fov,matrix) # in nm\n",
" step_size_corr = np.array(pty.get_step_correction())*pty.get_step_size(fov, matrix) # in nm\n",
"\n",
" beam_diameter = pty.get_beam_diameter(aperture, defocus, semi_angle_corr)\n",
" pctf_itr = pty.get_ctf(element)\n",
" cl_det = pty.get_cl_detector(cl, camera)\n",
" step_size = pty.get_step_size(fov, matrix) # in nm\n",
" semi_angle = pty.get_angle(aperture)\n",
" omega_itr = np.array(pty.get_omegas())\n",
" frame_rate = pty.get_aq_frec(dwell_time)\n",
" current = pty.get_current(probe_size,aperture) \n",
" wavelength = pty.get_wavelength(beam_energy)*1e12 # in pm\n",
" semi_angle_corr = pty.get_angle_corr(aperture) \n",
" wavelength = pty.get_wavelength(beam_energy)*1e12 # in pm \n",
" pixel_angle = pty.get_pixel_angle(cl, camera, binning)\n",
" beam_diameter = pty.get_beam_diameter(aperture, defocus, semi_angle_corr)\n",
" num_pixels, size_pixel = pty.get_detector(camera, binning)\n",
" step_size_corr = np.array(pty.get_step_correction())*pty.get_step_size(fov, matrix) # in nm\n",
" beam_diameter_pix = 2*semi_angle_corr/pixel_angle\n",
" detector_cover = num_pixels/2*pixel_angle\n",
" covered_alfas = detector_cover/semi_angle_corr\n",
@ -425,24 +425,6 @@
"\n",
" fig1.update_layout(width=2.9*graph_size, height=3.7*graph_size, plot_bgcolor='white', margin =dict(l=0.2*graph_size, r=0.1*graph_size, t=0.8*graph_size, b=0),\n",
" legend=dict(orientation=\"v\",yanchor=\"bottom\",y=1.01,xanchor=\"right\",x=1), title={'text': \"Sample\",'y': 0.87, 'x': 0.1,'xanchor': 'left','yanchor': 'top'})\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"\n",
" \n",
" case overlap_fig if overlap_fig in ['simI', 'simA']:\n",
" if abtem == True:\n",
@ -731,7 +713,11 @@
" cltab = widg.HBox([legend, dictionary[0], dictionary[1], dictionary[2], dictionary[3], dictionary[4], dictionary[5], dictionary[6], dictionary[7], dictionary[8], dictionary[9]])\n",
" case 11: \n",
" cltab = widg.HBox([legend, dictionary[0], dictionary[1], dictionary[2], dictionary[3], dictionary[4], dictionary[5], dictionary[6], dictionary[7], dictionary[8], dictionary[9], dictionary[10]])\n",
"\n",
" case 12: \n",
" cltab = widg.HBox([legend, dictionary[0], dictionary[1], dictionary[2], dictionary[3], dictionary[4], dictionary[5], dictionary[6], dictionary[7], dictionary[8], dictionary[9], dictionary[10], dictionary[11]])\n",
" case 13: \n",
" cltab = widg.HBox([legend, dictionary[0], dictionary[1], dictionary[2], dictionary[3], dictionary[4], dictionary[5], dictionary[6], dictionary[7], dictionary[8], dictionary[9], dictionary[10], dictionary[11], dictionary[12]])\n",
" \n",
" cltab = widg.VBox([widg.Label('CAMERA LENGTH GUIDE'), cltab])\n",
" cltab.layout = widg.Layout(border='solid 0px gray',margin='0px 0px 0px 15px', padding='5px 5px 5px 5px')\n",
"\n",
@ -746,8 +732,6 @@
" check3_ssb = widg.Valid(value= bool(3 < beam_diameter_pix) , description='Minimal BF size', layout=widg.Layout(width=check_width), style = {'description_width': check_descr_width}, disabled=True)\n",
" checks_ssb = widg.VBox([check1_ssb, check2_ssb,check3_ssb]) # Label('Final checks')\n",
" checks_ssb.layout = widg.Layout(margin='100px 0px 0px 30px', padding='0px 0px 0px 0px', border='solid 0px gray') # border='dashed 1px gray'\n",
"\n",
"\n",
" right = widg.VBox([go.FigureWidget(fig1), widg.HBox([go.FigureWidget(fig4), checks_ssb]) ])\n",
" \n",
" case 'iterative':\n",
@ -760,7 +744,6 @@
" check5_itr = widg.Valid(value= bool(oversampling > pattern_resto), description='Pattern recovery', layout=widg.Layout(width=check_width), style = {'description_width': check_descr_width}, disabled=True) \n",
" checks_itr = widg.HBox([widg.VBox([check1_itr, check2_itr]), widg.VBox([check3_itr, check4_itr]), widg.VBox([check5_itr])]) # Label('Final checks')\n",
" checks_itr.layout = widg.Layout(margin='0px 0px 0px 5px', padding='0px 0px 0px 0px', border='solid 0px gray') # border='dashed 1px gray'\n",
"\n",
" right = widg.VBox([widg.HBox([go.FigureWidget(fig1),go.FigureWidget(fig3)]), cltab, checks_itr])\n",
" \n",
" total = widg.HBox([left, go.FigureWidget(fig), right]) \n",
@ -768,10 +751,10 @@
" display(total)\n",
" return \n",
" \n",
"gui = widg.interactive_output(ptycho_interact, {\"beam_energy\" : beam_energy, \"aperture\": aperture, \"aperture_res\": aperture_res, \"aperture_res2\": aperture_res2, \"probe_size\": probe_size, \"cl\": cl, \"matrix\": matrix,\n",
" \"defocus\": defocus, \"mag\": mag, \"camera\": camera, \"binning\": binning, \"dwell_time\" : dwell_time, \"restr\": restr, \"method\": method, \"ctf_xaxis\": ctf_xaxis, \"element\": element,\n",
" \"graph_size\": graph_size, \"beam_pos\": beam_pos, \"fov_show\": fov_show, \"overlap_fig\" :overlap_fig, \"red_box\": red_box, \"box_col\":box_col, \"check0name\":check0name, \n",
" \"check1name\": check1name, \"check2name\": check2name, \"check4name\": check4name, \"check6name\": check6name, \"prof_show\":prof_show, \"padding\":padding, \"pattern_resto\":pattern_resto, \"rs_sampling\": rs_sampling}) \n",
"gui = widg.interactive_output(ptycho_interact, {\"beam_energy\" : beam_energy, \"aperture\": aperture, \"aperture_res\": aperture_res, \"aperture_res2\": aperture_res2, \"probe_size\": probe_size, \"cl\": cl, \"matrix\": matrix, \"defocus\": defocus, \"mag\": mag,\n",
" \"camera\": camera, \"binning\": binning, \"dwell_time\" : dwell_time, \"restr\": restr, \"method\": method, \"ctf_xaxis\": ctf_xaxis, \"element\": element, \"graph_size\": graph_size, \"beam_pos\": beam_pos,\n",
" \"fov_show\": fov_show, \"overlap_fig\" :overlap_fig, \"red_box\": red_box, \"box_col\":box_col, \"check0name\":check0name, \"check1name\": check1name, \"check2name\": check2name, \"check4name\": check4name,\n",
" \"check6name\": check6name, \"prof_show\":prof_show, \"padding\":padding, \"pattern_resto\":pattern_resto, \"rs_sampling\": rs_sampling, \"probe_size_ma\": probe_size_ma, \"aperture_ma\": aperture_ma, \"step_ma\": step_ma }) \n",
"\n",
"ptychoscopy = widg.VBox([top_set, widg.HBox([controls, widg.VBox([graph_controls, gui])])])"
]

Binary file not shown.

View File

@ -481,8 +481,8 @@ def load_dwelltimes():
"""
excel_data = read_excel(r'ptychoscopy/calibrations.xlsx',sheet_name='Ranges')
dwelltimes = [str(e) for e in list(excel_data.DwellTime)]
dwelltimes = [x for x in dwelltimes if x != 'nan']
dwelltimes = [int(float(e)) for e in dwelltimes]
dwelltimes = [x for x in dwelltimes if x != 'nan']
dwelltimes = [int(float(e)) for e in dwelltimes]
return dwelltimes
def load_cameralengths(camera, which):