diff --git a/.ipynb_checkpoints/ptychoScopy-checkpoint.ipynb b/.ipynb_checkpoints/ptychoScopy-checkpoint.ipynb index 1b4f582..f46d062 100644 --- a/.ipynb_checkpoints/ptychoScopy-checkpoint.ipynb +++ b/.ipynb_checkpoints/ptychoScopy-checkpoint.ipynb @@ -28,7 +28,7 @@ }, { "cell_type": "code", - "execution_count": 15, + "execution_count": 137, "id": "7425242d-3c91-4c1e-a424-08625a38ee7a", "metadata": {}, "outputs": [], @@ -277,7 +277,7 @@ " return beam_res.value\n", " \n", " def show_probe_angle(self,caller):\n", - " aperture_res.value = f'Probe semi-angle (mrad) {\"{:.1f}\".format(pty.get_angle(caller.new))}' \n", + " aperture_res.value = f'Semi-angle (mrad) {\"{:.1f}\".format(pty.get_angle(caller.new))}' \n", " return aperture_res.value\n", " \n", " def show_corrprobe_angle(self,caller):\n", @@ -301,7 +301,23 @@ }, { "cell_type": "code", - "execution_count": 22, + "execution_count": null, + "id": "66e552e4-5954-4f3f-a59f-66c5affb69b6", + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "125969b5-b128-4869-ae27-4aa7d8949d48", + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": 213, "id": "8055b802-cf83-4250-aea9-54e3e6b73db0", "metadata": {}, "outputs": [ @@ -315,34 +331,42 @@ ], "source": [ "### CONTROLS ##########################################\n", - "ali = dict(style = {'description_width': '80px','button_width': '55px', 'font_weight': 'bold'}, button_style='',disabled = False)\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", - "\n", + "ali3 = dict(style = {'description_width': '110px','button_width': '45px', 'font_weight': 'bold'}, button_style='',disabled = False)\n", "# header = Button(description='Control panel',layout=Layout(width='auto', grid_area='header'), style=ButtonStyle(button_color='navy', font_weight= 'bold',font_size= '20px',font_variant='small-caps',text_color='white'),disabled = False)\n", "\n", - "beam_set = Button(description='Electron beam settings',layout=Layout(width='auto', grid_area='beam_set'), style=ButtonStyle(button_color='navy', font_weight= 'bold',font_size= '16px',font_variant='small-caps',text_color='white'),disabled = False) \n", - "beam = ToggleButtons(options=opt.energies(), value=200,description='Beam energy (keV)', layout=Layout(width='auto', grid_area='beam_set1'), **ali )\n", - "aperture = ToggleButtons(options=opt.apertures(), value='30um', description='Aperture', layout=Layout(width='auto', grid_area='beam_set2'), **ali)\n", - "probe = ToggleButtons(options=opt.probes(), value='8C', description='Probe', layout=Layout(width='auto', grid_area='beam_set3'), **ali)\n", - "defocus = IntSlider(description='Defocus (nm)', value=0, min=0, max=1000, step=1, continuous_update=False, layout=Layout(width='auto', grid_area='beam_set4'), **ali)\n", + "beam_set = Button(description='Electron beam settings',layout=Layout(width='95%', grid_area='beam_set'), style=ButtonStyle(button_color='#0d48a1', font_weight= 'bold',font_size= '16px',font_variant='small-caps',text_color='white'),disabled = False) \n", + "beam = Dropdown(options=opt.energies(), value=200,description='Beam energy (keV)', layout=Layout(width='95%', grid_area='beam_set1'), **ali )\n", + "aperture_name = Label(value = 'Aperture',layout=Layout(width='95%', grid_area='aperture_name'),)\n", + "if len(opt.apertures())>5:\n", + " aperture = Dropdown(options=opt.apertures(), description='', layout=Layout(width='95%', grid_area='beam_set2'), **ali)\n", + "else:\n", + " aperture = ToggleButtons(options=opt.apertures(), description='', layout=Layout(width='95%', grid_area='beam_set2'), **ali3)\n", "\n", - "scanning_set = Button(description='Scanning parameters',layout=Layout(width='auto', grid_area='scanning_set'),style=ButtonStyle(button_color='navy', font_weight= 'bold',font_size= '16px',font_variant='small-caps',text_color='white'),disabled = False)\n", - "mag = ToggleButtons(options=opt.magnifications(),value=3,description='Magnification Mx', layout=Layout(width='auto', grid_area='scanning_set1'), **ali)\n", - "matrix = ToggleButtons(options=opt.mappings(), value=2048, description='Matrix', layout=Layout(width='auto', grid_area='scanning_set2'), **ali)\n", - "dwell_time = ToggleButtons(options=opt.dwelltimes(), value=10, description='Dwell time (μs)', layout=Layout(width='auto', grid_area='scanning_set3'), **ali)\n", + "probe = Dropdown(options=opt.probes(), value='8C', description='Probe', layout=Layout(width='95%', grid_area='beam_set3'), **ali)\n", + "defocus = IntSlider(description='Defocus (nm)', value=0, min=0, max=1000, step=1, continuous_update=False, layout=Layout(width='95%', grid_area='beam_set4'), **ali)\n", + "\n", + "scanning_set = Button(description='Scanning parameters',layout=Layout(width='95%', grid_area='scanning_set'),style=ButtonStyle(button_color='#0d48a1', font_weight= 'bold',font_size= '16px',font_variant='small-caps',text_color='white'),disabled = False)\n", + "mag = Dropdown(options=opt.magnifications(),value=3,description='Magnification Mx', layout=Layout(width='95%', grid_area='scanning_set1'), **ali)\n", + "matrix = Dropdown(options=opt.mappings(), value=2048, description='Matrix', layout=Layout(width='95%', grid_area='scanning_set2'), **ali)\n", + "dwell_time = Dropdown(options=opt.dwelltimes(), value=10, description='Dwell time (μs)', layout=Layout(width='95%', grid_area='scanning_set3'), **ali)\n", "print(len(opt.detectors()))\n", "\n", "\n", "\n", - "camera_set = Button(description='Detection',layout=Layout(width='auto', grid_area='camera_set'),style=ButtonStyle(button_color='navy', font_weight= 'bold',font_size= '16px',font_variant='small-caps',text_color='white'),disabled = False)\n", - "cl = ToggleButtons(options=opt.cameralengths(), value=12, description='Nominal camera length (cm)', layout=Layout(width='auto', grid_area='cl_set1'), **ali)\n", - "camera = ToggleButtons(options=opt.detectors(), description='Detector', layout=Layout(width='auto', grid_area='camera_set1'), style = {'description_width': '60px','button_width': str(100/len(opt.detectors())-len(opt.detectors()))+'%', 'font_weight': 'bold'})\n", - "restriction = ToggleButtons(options=[('.',False), ('..',True)], value = False, description='PAAR',icons = ['times','check'], layout=Layout(width='auto', grid_area='camera_set2'),style = {'description_width': '80px','button_width': '48%', 'font_weight': 'bold'})\n", - "binning = ToggleButtons(options=[('.',1), ('2×2',2), ('4×4',4), ('3×3',3), ('6×6',6), ('8×8',8), ('12×12',12), ('16×16',16), ('24×24',24), ('32×32',32), ('48×48',48)], value=1, description='Binning', icons = ['times','',''], layout=Layout(width='auto', grid_area='camera_set3'), **ali)\n", + "camera_set = Button(description='Detection',layout=Layout(width='95%', grid_area='camera_set'),style=ButtonStyle(button_color='#0d48a1', font_weight= 'bold',font_size= '16px',font_variant='small-caps',text_color='white'),disabled = False)\n", + "cl = Dropdown(options=opt.cameralengths(), value=12, description='Nominal CL (cm)', layout=Layout(width='95%', grid_area='cl_set1'), **ali3)\n", + "camera_name = Label(value = 'Detector',layout=Layout(width='95%', grid_area='camera_name'),)\n", + "camera = ToggleButtons(options=opt.detectors(), description='', layout=Layout(width='95%', grid_area='camera_set1'), style = {'description_width': '60px','button_width': str(100/len(opt.detectors())-len(opt.detectors()))+'%', 'font_weight': 'bold'}, button_style='')\n", + "restriction_name = Label(value = 'PAAR',layout=Layout(width='95%', grid_area='restriction_name'),)\n", + "restriction = ToggleButtons(options=[('.',False), ('..',True)], value = False, description='',icons = ['times','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 = ['times','',''], layout=Layout(width='auto', 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", - "aperture_res = Label(value = f'Probe semi-angle (mrad) '+ str(\"{:.1f}\".format(pty.get_angle(aperture.value))), layout=Layout(width='auto', grid_area='sidebar2'),)\n", + "aperture_res = Label(value = f'Semi-angle (mrad) '+ str(\"{:.1f}\".format(pty.get_angle(aperture.value))), layout=Layout(width='auto', grid_area='sidebar2'),)\n", "aperture.observe(inte.show_probe_angle, names='value') \n", "aperture_res2 = Label(value = f'corr. '+ str(\"{:.2f}\".format(pty.get_angle_corr(aperture.value))),layout=Layout(width='auto', grid_area='sidebar5'),)\n", "aperture.observe(inte.show_corrprobe_angle, names='value') \n", @@ -353,38 +377,37 @@ "\n", "footer = Button(description='',layout=Layout(width='auto', grid_area='footer'),style=ButtonStyle(button_color='navy', font_weight= 'bold',font_size= '16px',font_variant='small-caps',text_color='white'))\n", "\n", - "controls = GridBox(children=[beam_set, beam, aperture, probe, defocus, scanning_set, mag,matrix,dwell_time, cl,camera_set, camera, restriction, binning, beam_res, aperture_res,aperture_res2,fov_res, dwell_time_res,footer],\n", - " layout=Layout(width='15%', grid_template_rows='auto auto auto', grid_template_columns='30% 30% 20% 20%', grid_template_areas='''\n", + "\n", + "\n", + "controls = GridBox(children=[beam_set, beam,aperture_name, aperture, probe, defocus, scanning_set, mag,matrix,dwell_time, cl,camera_set, camera,camera_name, restriction_name, restriction, binning_name, binning, beam_res, aperture_res,aperture_res2,fov_res, dwell_time_res],\n", + " layout=Layout(width='325px', grid_template_rows='35px 35px 35px 35px 30px 30px 35px 35px 35px 35px 35px 35px 35px 35px 35px 35px', grid_template_columns='20% 40% 15% 25%', grid_template_areas='''\n", " \"beam_set beam_set beam_set beam_set \" \n", " \"beam_set1 beam_set1 beam_set1 beam_set1 \"\n", - " \"beam_set2 beam_set2 beam_set2 beam_set2 \"\n", - " \"sidebar2 sidebar2 sidebar5 sidebar5 \"\n", " \"beam_set3 beam_set3 beam_set3 beam_set3 \"\n", " \"beam_set4 beam_set4 beam_set4 beam_set4 \"\n", + " \"aperture_name beam_set2 beam_set2 beam_set2 \"\n", + " \". sidebar2 sidebar2 sidebar5 \"\n", " \"scanning_set scanning_set scanning_set scanning_set \" \n", " \"scanning_set1 scanning_set1 scanning_set1 scanning_set1 \"\n", " \"scanning_set2 scanning_set2 scanning_set2 scanning_set2 \"\n", " \"scanning_set3 scanning_set3 scanning_set3 scanning_set3 \"\n", " \"camera_set camera_set camera_set camera_set \"\n", " \"cl_set1 cl_set1 cl_set1 cl_set1 \"\n", - " \"camera_set1 camera_set1 camera_set1 camera_set1 \"\n", - " \"camera_set3 camera_set3 camera_set3 camera_set3 \"\n", - " \"camera_set2 camera_set2 camera_set2 camera_set2 \"\n", - " \"footer footer footer footer \"\n", + " \"camera_name camera_set1 camera_set1 camera_set1 \"\n", + " \"restriction_name camera_set2 camera_set2 camera_set2 \"\n", + " \"binning_name camera_set3 camera_set3 camera_set3 \"\n", " '''))\n", "\n", "# SMALL CONTROLS\n", - "descr = '100px'\n", + "descr = '75px'\n", "butt = '100px'\n", "butt2 = '150px'\n", "\n", - "header1 = Button(description='Graph selection',layout=Layout(width='auto', grid_area='header1'),style=ButtonStyle(button_color='lightgray', font_weight= 'bold',text_color='black'), disabled = False)\n", - "header2 = Button(description='CTF graph',layout=Layout(width='auto', grid_area='header2'),style=ButtonStyle(button_color='lightgray', font_weight= 'bold',text_color='black'),disabled = False)\n", - "header3 = Button(description='CL limitations',layout=Layout(width='auto', grid_area='header3'),style=ButtonStyle(button_color='lightgray', font_weight= 'bold',text_color='black'),disabled = False)\n", + "header3 = Button(description='CL limitations',layout=Layout(width='auto', grid_area='header3'),style=ButtonStyle(button_color='white', font_weight= 'bold',text_color='black'),disabled = False)\n", "method = ToggleButtons(options=[('SSB','direct'), ('Reconstruction ','iterative')], description='', icons = ['','refresh'], tooltips=['Single side band ptychography', 'Iterative reconstruction methods (PIE, ML, DM)'],\n", " layout=Layout(width='auto', grid_area='methods'), style = {'description_width': descr, 'button_width': '48.5%', 'font_weight': 'bold'}, button_style='',disabled=False,)\n", - "graph_size = IntSlider(value=100,min=50,max=150,step=5, description='Graphs size', layout=Layout(width='auto', grid_area='gr_size'), style = {'description_width': descr,'button_width': butt}, button_style='',disabled=False,)\n", - "ctf_xaxis = RadioButtons(options=['α','mrad', 'A'], description='x-axis:', layout=Layout(width='auto', grid_area='ctxaxis'), style = {'description_width': descr,'button_width': butt}, disabled=False)\n", + "\n", + "ctf_xaxis = RadioButtons(options=['α','mrad', 'A'], description='CTF graph x-axis:', layout=Layout(width='auto', grid_area='ctxaxis'), style = {'description_width': descr,'button_width': butt}, disabled=False)\n", "\n", "cl_check_laa = Checkbox(value=True, description='Low anlge approximation', indent=False, layout=Layout(width='auto', grid_area='check1'), disabled=False,) # Low angle approximation check - scattering angle < 10 deg\n", "cl_check_pix = Checkbox(value=True, description='Ptycho pixel < step size',indent=False, layout=Layout(width='auto', grid_area='check2'), disabled=False,) # Reconstructed pixel size < scanning step size \n", @@ -392,23 +415,36 @@ "cl_check_1bf = Checkbox(value=True, description='Detector cover < 1α', indent=False, layout=Layout(width='auto', grid_area='check4'), disabled=False,) # Detector cover is lower than 1 α\n", "cl_check_nbf = Checkbox(value=True, description='Detector cover > 6α', indent=False, layout=Layout(width='auto', grid_area='check5'), disabled=False,) # Detector cover is higher than 6 α\n", "\n", + "\n", + "\n", + "\n", + "small_controls1 = GridBox(children=[header3, method, ctf_xaxis, cl_check_laa,cl_check_pix,cl_check_def, cl_check_1bf, cl_check_nbf],\n", + " layout=Layout(width='100%',\n", + " grid_template_rows='auto auto auto auto',\n", + " grid_template_columns='2.5% 25% 2.5% 10% 20% 20% 20%',\n", + " grid_template_areas='''\n", + " \". methods . ctxaxis header3 header3 header3 \"\n", + " \". . . ctxaxis check1 check2 check3\"\n", + " \". . . ctxaxis check4 check5 . \"\n", + " '''))\n", + "header1 = Button(description='Graph selection',layout=Layout(width='auto', grid_area='header1'),style=ButtonStyle(button_color='white', font_weight= 'bold',text_color='black'), disabled = False)\n", "chart = ToggleButtons(options=[('Scheme ','micr'), ('Charts ','dedic'),('Both ','both')],value = 'both',icons = ['eye','eye','eye'], description='',\n", " layout=Layout(width='auto', grid_area='charts'), style = {'description_width': descr,'button_width': '32%', 'font_weight': 'bold'}, button_style='',disabled=False,)\n", - "footer = Button(description='Interactive results',layout=Layout(width='auto', grid_area='footer'),style=ButtonStyle(button_color='lightgray', font_weight= 'bold',text_color='black'),disabled = False)\n", "\n", - "small_controls = GridBox(children=[header1,header2,header3, method, chart, graph_size, ctf_xaxis, cl_check_laa,cl_check_pix,cl_check_def, cl_check_1bf, cl_check_nbf, footer],\n", + "name1 = Button(description='Graphs size (%)',layout=Layout(width='auto', grid_area='name1'),style=ButtonStyle(button_color='white', font_weight= 'bold',text_color='black'), disabled = False)\n", + "\n", + "graph_size = IntSlider(value=100,min=50,max=150,step=5, description='', layout=Layout(width='auto', grid_area='gr_size'), style = {'description_width': descr,'button_width': butt}, button_style='primary',disabled=False,)\n", + "\n", + "\n", + "\n", + "small_controls2 = GridBox(children=[header1, chart, name1, graph_size],\n", " layout=Layout(width='100%',\n", - " grid_template_rows='auto auto auto auto auto',\n", - " grid_template_columns='2% 38% 10% 25% 25%',\n", + " grid_template_rows='auto auto auto auto',\n", + " grid_template_columns='15% 30% 15% 30%',\n", " grid_template_areas='''\n", - " \". header1 header2 header3 header3 \"\n", - " \". methods ctxaxis check1 check4\"\n", - " \". charts ctxaxis check2 check5\"\n", - " \". gr_size ctxaxis check3 .\"\n", - " \". footer footer footer footer\"\n", + " \"header1 charts name1 gr_size \"\n", " '''))\n", "\n", - "\n", "def ptycho_interact(beam, aperture, aperture_res, aperture_res2, probe, cl, matrix, defocus, mag, camera, binning, dwell_time, restriction, method, ctf_xaxis, cl_check_laa, cl_check_pix, cl_check_def, cl_check_1bf, cl_check_nbf, graph_size, chart):\n", " \n", " ### SINGLE SETTING PARAMETERS ###\n", @@ -664,7 +700,7 @@ " left_column = VBox([go.FigureWidget(fig8)])\n", " total = HBox([left_column, right_column])\n", " \n", - " total.layout = Layout(border='solid 0px gray',margin='10px 10px 10px 40px', padding='10px 10px 10px 10px') \n", + " total.layout = Layout(border='solid 0px gray',margin='0px 0px 0px 20px', padding='0px 0px 0px 0px') \n", " display(total)\n", "\n", " \n", @@ -794,7 +830,7 @@ " left_column = go.FigureWidget(fig8)\n", " total = HBox([left_column, right_column]) \n", " \n", - " total.layout = Layout(border='solid 0px gray',margin='10px 10px 10px 40px', padding='10px 10px 10px 10px') \n", + " total.layout = Layout(border='solid 0px gray',margin='0px 0px 0px 10px', padding='0px 0px 0px 10px') \n", " display(total)\n", "\n", " \n", @@ -835,14 +871,14 @@ }, { "cell_type": "code", - "execution_count": 23, + "execution_count": 214, "id": "7937f054-fcd0-4e67-a20f-7696f5903a94", "metadata": {}, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { - "model_id": "0a48e2bb85fd41a5931e183508ad4aa4", + "model_id": "59e5c62c96044e0c8cc325a6e1686415", "version_major": 2, "version_minor": 0 }, @@ -855,7 +891,7 @@ } ], "source": [ - "display(HBox([controls, VBox([small_controls, gui])]))" + "display(HBox([controls, VBox([small_controls1, gui, small_controls2])]))" ] } ], diff --git a/calibrations.xlsx b/calibrations.xlsx index 60ed35e..34848f8 100644 Binary files a/calibrations.xlsx and b/calibrations.xlsx differ diff --git a/ptychoScopy.ipynb b/ptychoScopy.ipynb index 1b4f582..f46d062 100644 --- a/ptychoScopy.ipynb +++ b/ptychoScopy.ipynb @@ -28,7 +28,7 @@ }, { "cell_type": "code", - "execution_count": 15, + "execution_count": 137, "id": "7425242d-3c91-4c1e-a424-08625a38ee7a", "metadata": {}, "outputs": [], @@ -277,7 +277,7 @@ " return beam_res.value\n", " \n", " def show_probe_angle(self,caller):\n", - " aperture_res.value = f'Probe semi-angle (mrad) {\"{:.1f}\".format(pty.get_angle(caller.new))}' \n", + " aperture_res.value = f'Semi-angle (mrad) {\"{:.1f}\".format(pty.get_angle(caller.new))}' \n", " return aperture_res.value\n", " \n", " def show_corrprobe_angle(self,caller):\n", @@ -301,7 +301,23 @@ }, { "cell_type": "code", - "execution_count": 22, + "execution_count": null, + "id": "66e552e4-5954-4f3f-a59f-66c5affb69b6", + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "125969b5-b128-4869-ae27-4aa7d8949d48", + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": 213, "id": "8055b802-cf83-4250-aea9-54e3e6b73db0", "metadata": {}, "outputs": [ @@ -315,34 +331,42 @@ ], "source": [ "### CONTROLS ##########################################\n", - "ali = dict(style = {'description_width': '80px','button_width': '55px', 'font_weight': 'bold'}, button_style='',disabled = False)\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", - "\n", + "ali3 = dict(style = {'description_width': '110px','button_width': '45px', 'font_weight': 'bold'}, button_style='',disabled = False)\n", "# header = Button(description='Control panel',layout=Layout(width='auto', grid_area='header'), style=ButtonStyle(button_color='navy', font_weight= 'bold',font_size= '20px',font_variant='small-caps',text_color='white'),disabled = False)\n", "\n", - "beam_set = Button(description='Electron beam settings',layout=Layout(width='auto', grid_area='beam_set'), style=ButtonStyle(button_color='navy', font_weight= 'bold',font_size= '16px',font_variant='small-caps',text_color='white'),disabled = False) \n", - "beam = ToggleButtons(options=opt.energies(), value=200,description='Beam energy (keV)', layout=Layout(width='auto', grid_area='beam_set1'), **ali )\n", - "aperture = ToggleButtons(options=opt.apertures(), value='30um', description='Aperture', layout=Layout(width='auto', grid_area='beam_set2'), **ali)\n", - "probe = ToggleButtons(options=opt.probes(), value='8C', description='Probe', layout=Layout(width='auto', grid_area='beam_set3'), **ali)\n", - "defocus = IntSlider(description='Defocus (nm)', value=0, min=0, max=1000, step=1, continuous_update=False, layout=Layout(width='auto', grid_area='beam_set4'), **ali)\n", + "beam_set = Button(description='Electron beam settings',layout=Layout(width='95%', grid_area='beam_set'), style=ButtonStyle(button_color='#0d48a1', font_weight= 'bold',font_size= '16px',font_variant='small-caps',text_color='white'),disabled = False) \n", + "beam = Dropdown(options=opt.energies(), value=200,description='Beam energy (keV)', layout=Layout(width='95%', grid_area='beam_set1'), **ali )\n", + "aperture_name = Label(value = 'Aperture',layout=Layout(width='95%', grid_area='aperture_name'),)\n", + "if len(opt.apertures())>5:\n", + " aperture = Dropdown(options=opt.apertures(), description='', layout=Layout(width='95%', grid_area='beam_set2'), **ali)\n", + "else:\n", + " aperture = ToggleButtons(options=opt.apertures(), description='', layout=Layout(width='95%', grid_area='beam_set2'), **ali3)\n", "\n", - "scanning_set = Button(description='Scanning parameters',layout=Layout(width='auto', grid_area='scanning_set'),style=ButtonStyle(button_color='navy', font_weight= 'bold',font_size= '16px',font_variant='small-caps',text_color='white'),disabled = False)\n", - "mag = ToggleButtons(options=opt.magnifications(),value=3,description='Magnification Mx', layout=Layout(width='auto', grid_area='scanning_set1'), **ali)\n", - "matrix = ToggleButtons(options=opt.mappings(), value=2048, description='Matrix', layout=Layout(width='auto', grid_area='scanning_set2'), **ali)\n", - "dwell_time = ToggleButtons(options=opt.dwelltimes(), value=10, description='Dwell time (μs)', layout=Layout(width='auto', grid_area='scanning_set3'), **ali)\n", + "probe = Dropdown(options=opt.probes(), value='8C', description='Probe', layout=Layout(width='95%', grid_area='beam_set3'), **ali)\n", + "defocus = IntSlider(description='Defocus (nm)', value=0, min=0, max=1000, step=1, continuous_update=False, layout=Layout(width='95%', grid_area='beam_set4'), **ali)\n", + "\n", + "scanning_set = Button(description='Scanning parameters',layout=Layout(width='95%', grid_area='scanning_set'),style=ButtonStyle(button_color='#0d48a1', font_weight= 'bold',font_size= '16px',font_variant='small-caps',text_color='white'),disabled = False)\n", + "mag = Dropdown(options=opt.magnifications(),value=3,description='Magnification Mx', layout=Layout(width='95%', grid_area='scanning_set1'), **ali)\n", + "matrix = Dropdown(options=opt.mappings(), value=2048, description='Matrix', layout=Layout(width='95%', grid_area='scanning_set2'), **ali)\n", + "dwell_time = Dropdown(options=opt.dwelltimes(), value=10, description='Dwell time (μs)', layout=Layout(width='95%', grid_area='scanning_set3'), **ali)\n", "print(len(opt.detectors()))\n", "\n", "\n", "\n", - "camera_set = Button(description='Detection',layout=Layout(width='auto', grid_area='camera_set'),style=ButtonStyle(button_color='navy', font_weight= 'bold',font_size= '16px',font_variant='small-caps',text_color='white'),disabled = False)\n", - "cl = ToggleButtons(options=opt.cameralengths(), value=12, description='Nominal camera length (cm)', layout=Layout(width='auto', grid_area='cl_set1'), **ali)\n", - "camera = ToggleButtons(options=opt.detectors(), description='Detector', layout=Layout(width='auto', grid_area='camera_set1'), style = {'description_width': '60px','button_width': str(100/len(opt.detectors())-len(opt.detectors()))+'%', 'font_weight': 'bold'})\n", - "restriction = ToggleButtons(options=[('.',False), ('..',True)], value = False, description='PAAR',icons = ['times','check'], layout=Layout(width='auto', grid_area='camera_set2'),style = {'description_width': '80px','button_width': '48%', 'font_weight': 'bold'})\n", - "binning = ToggleButtons(options=[('.',1), ('2×2',2), ('4×4',4), ('3×3',3), ('6×6',6), ('8×8',8), ('12×12',12), ('16×16',16), ('24×24',24), ('32×32',32), ('48×48',48)], value=1, description='Binning', icons = ['times','',''], layout=Layout(width='auto', grid_area='camera_set3'), **ali)\n", + "camera_set = Button(description='Detection',layout=Layout(width='95%', grid_area='camera_set'),style=ButtonStyle(button_color='#0d48a1', font_weight= 'bold',font_size= '16px',font_variant='small-caps',text_color='white'),disabled = False)\n", + "cl = Dropdown(options=opt.cameralengths(), value=12, description='Nominal CL (cm)', layout=Layout(width='95%', grid_area='cl_set1'), **ali3)\n", + "camera_name = Label(value = 'Detector',layout=Layout(width='95%', grid_area='camera_name'),)\n", + "camera = ToggleButtons(options=opt.detectors(), description='', layout=Layout(width='95%', grid_area='camera_set1'), style = {'description_width': '60px','button_width': str(100/len(opt.detectors())-len(opt.detectors()))+'%', 'font_weight': 'bold'}, button_style='')\n", + "restriction_name = Label(value = 'PAAR',layout=Layout(width='95%', grid_area='restriction_name'),)\n", + "restriction = ToggleButtons(options=[('.',False), ('..',True)], value = False, description='',icons = ['times','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 = ['times','',''], layout=Layout(width='auto', 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", - "aperture_res = Label(value = f'Probe semi-angle (mrad) '+ str(\"{:.1f}\".format(pty.get_angle(aperture.value))), layout=Layout(width='auto', grid_area='sidebar2'),)\n", + "aperture_res = Label(value = f'Semi-angle (mrad) '+ str(\"{:.1f}\".format(pty.get_angle(aperture.value))), layout=Layout(width='auto', grid_area='sidebar2'),)\n", "aperture.observe(inte.show_probe_angle, names='value') \n", "aperture_res2 = Label(value = f'corr. '+ str(\"{:.2f}\".format(pty.get_angle_corr(aperture.value))),layout=Layout(width='auto', grid_area='sidebar5'),)\n", "aperture.observe(inte.show_corrprobe_angle, names='value') \n", @@ -353,38 +377,37 @@ "\n", "footer = Button(description='',layout=Layout(width='auto', grid_area='footer'),style=ButtonStyle(button_color='navy', font_weight= 'bold',font_size= '16px',font_variant='small-caps',text_color='white'))\n", "\n", - "controls = GridBox(children=[beam_set, beam, aperture, probe, defocus, scanning_set, mag,matrix,dwell_time, cl,camera_set, camera, restriction, binning, beam_res, aperture_res,aperture_res2,fov_res, dwell_time_res,footer],\n", - " layout=Layout(width='15%', grid_template_rows='auto auto auto', grid_template_columns='30% 30% 20% 20%', grid_template_areas='''\n", + "\n", + "\n", + "controls = GridBox(children=[beam_set, beam,aperture_name, aperture, probe, defocus, scanning_set, mag,matrix,dwell_time, cl,camera_set, camera,camera_name, restriction_name, restriction, binning_name, binning, beam_res, aperture_res,aperture_res2,fov_res, dwell_time_res],\n", + " layout=Layout(width='325px', grid_template_rows='35px 35px 35px 35px 30px 30px 35px 35px 35px 35px 35px 35px 35px 35px 35px 35px', grid_template_columns='20% 40% 15% 25%', grid_template_areas='''\n", " \"beam_set beam_set beam_set beam_set \" \n", " \"beam_set1 beam_set1 beam_set1 beam_set1 \"\n", - " \"beam_set2 beam_set2 beam_set2 beam_set2 \"\n", - " \"sidebar2 sidebar2 sidebar5 sidebar5 \"\n", " \"beam_set3 beam_set3 beam_set3 beam_set3 \"\n", " \"beam_set4 beam_set4 beam_set4 beam_set4 \"\n", + " \"aperture_name beam_set2 beam_set2 beam_set2 \"\n", + " \". sidebar2 sidebar2 sidebar5 \"\n", " \"scanning_set scanning_set scanning_set scanning_set \" \n", " \"scanning_set1 scanning_set1 scanning_set1 scanning_set1 \"\n", " \"scanning_set2 scanning_set2 scanning_set2 scanning_set2 \"\n", " \"scanning_set3 scanning_set3 scanning_set3 scanning_set3 \"\n", " \"camera_set camera_set camera_set camera_set \"\n", " \"cl_set1 cl_set1 cl_set1 cl_set1 \"\n", - " \"camera_set1 camera_set1 camera_set1 camera_set1 \"\n", - " \"camera_set3 camera_set3 camera_set3 camera_set3 \"\n", - " \"camera_set2 camera_set2 camera_set2 camera_set2 \"\n", - " \"footer footer footer footer \"\n", + " \"camera_name camera_set1 camera_set1 camera_set1 \"\n", + " \"restriction_name camera_set2 camera_set2 camera_set2 \"\n", + " \"binning_name camera_set3 camera_set3 camera_set3 \"\n", " '''))\n", "\n", "# SMALL CONTROLS\n", - "descr = '100px'\n", + "descr = '75px'\n", "butt = '100px'\n", "butt2 = '150px'\n", "\n", - "header1 = Button(description='Graph selection',layout=Layout(width='auto', grid_area='header1'),style=ButtonStyle(button_color='lightgray', font_weight= 'bold',text_color='black'), disabled = False)\n", - "header2 = Button(description='CTF graph',layout=Layout(width='auto', grid_area='header2'),style=ButtonStyle(button_color='lightgray', font_weight= 'bold',text_color='black'),disabled = False)\n", - "header3 = Button(description='CL limitations',layout=Layout(width='auto', grid_area='header3'),style=ButtonStyle(button_color='lightgray', font_weight= 'bold',text_color='black'),disabled = False)\n", + "header3 = Button(description='CL limitations',layout=Layout(width='auto', grid_area='header3'),style=ButtonStyle(button_color='white', font_weight= 'bold',text_color='black'),disabled = False)\n", "method = ToggleButtons(options=[('SSB','direct'), ('Reconstruction ','iterative')], description='', icons = ['','refresh'], tooltips=['Single side band ptychography', 'Iterative reconstruction methods (PIE, ML, DM)'],\n", " layout=Layout(width='auto', grid_area='methods'), style = {'description_width': descr, 'button_width': '48.5%', 'font_weight': 'bold'}, button_style='',disabled=False,)\n", - "graph_size = IntSlider(value=100,min=50,max=150,step=5, description='Graphs size', layout=Layout(width='auto', grid_area='gr_size'), style = {'description_width': descr,'button_width': butt}, button_style='',disabled=False,)\n", - "ctf_xaxis = RadioButtons(options=['α','mrad', 'A'], description='x-axis:', layout=Layout(width='auto', grid_area='ctxaxis'), style = {'description_width': descr,'button_width': butt}, disabled=False)\n", + "\n", + "ctf_xaxis = RadioButtons(options=['α','mrad', 'A'], description='CTF graph x-axis:', layout=Layout(width='auto', grid_area='ctxaxis'), style = {'description_width': descr,'button_width': butt}, disabled=False)\n", "\n", "cl_check_laa = Checkbox(value=True, description='Low anlge approximation', indent=False, layout=Layout(width='auto', grid_area='check1'), disabled=False,) # Low angle approximation check - scattering angle < 10 deg\n", "cl_check_pix = Checkbox(value=True, description='Ptycho pixel < step size',indent=False, layout=Layout(width='auto', grid_area='check2'), disabled=False,) # Reconstructed pixel size < scanning step size \n", @@ -392,23 +415,36 @@ "cl_check_1bf = Checkbox(value=True, description='Detector cover < 1α', indent=False, layout=Layout(width='auto', grid_area='check4'), disabled=False,) # Detector cover is lower than 1 α\n", "cl_check_nbf = Checkbox(value=True, description='Detector cover > 6α', indent=False, layout=Layout(width='auto', grid_area='check5'), disabled=False,) # Detector cover is higher than 6 α\n", "\n", + "\n", + "\n", + "\n", + "small_controls1 = GridBox(children=[header3, method, ctf_xaxis, cl_check_laa,cl_check_pix,cl_check_def, cl_check_1bf, cl_check_nbf],\n", + " layout=Layout(width='100%',\n", + " grid_template_rows='auto auto auto auto',\n", + " grid_template_columns='2.5% 25% 2.5% 10% 20% 20% 20%',\n", + " grid_template_areas='''\n", + " \". methods . ctxaxis header3 header3 header3 \"\n", + " \". . . ctxaxis check1 check2 check3\"\n", + " \". . . ctxaxis check4 check5 . \"\n", + " '''))\n", + "header1 = Button(description='Graph selection',layout=Layout(width='auto', grid_area='header1'),style=ButtonStyle(button_color='white', font_weight= 'bold',text_color='black'), disabled = False)\n", "chart = ToggleButtons(options=[('Scheme ','micr'), ('Charts ','dedic'),('Both ','both')],value = 'both',icons = ['eye','eye','eye'], description='',\n", " layout=Layout(width='auto', grid_area='charts'), style = {'description_width': descr,'button_width': '32%', 'font_weight': 'bold'}, button_style='',disabled=False,)\n", - "footer = Button(description='Interactive results',layout=Layout(width='auto', grid_area='footer'),style=ButtonStyle(button_color='lightgray', font_weight= 'bold',text_color='black'),disabled = False)\n", "\n", - "small_controls = GridBox(children=[header1,header2,header3, method, chart, graph_size, ctf_xaxis, cl_check_laa,cl_check_pix,cl_check_def, cl_check_1bf, cl_check_nbf, footer],\n", + "name1 = Button(description='Graphs size (%)',layout=Layout(width='auto', grid_area='name1'),style=ButtonStyle(button_color='white', font_weight= 'bold',text_color='black'), disabled = False)\n", + "\n", + "graph_size = IntSlider(value=100,min=50,max=150,step=5, description='', layout=Layout(width='auto', grid_area='gr_size'), style = {'description_width': descr,'button_width': butt}, button_style='primary',disabled=False,)\n", + "\n", + "\n", + "\n", + "small_controls2 = GridBox(children=[header1, chart, name1, graph_size],\n", " layout=Layout(width='100%',\n", - " grid_template_rows='auto auto auto auto auto',\n", - " grid_template_columns='2% 38% 10% 25% 25%',\n", + " grid_template_rows='auto auto auto auto',\n", + " grid_template_columns='15% 30% 15% 30%',\n", " grid_template_areas='''\n", - " \". header1 header2 header3 header3 \"\n", - " \". methods ctxaxis check1 check4\"\n", - " \". charts ctxaxis check2 check5\"\n", - " \". gr_size ctxaxis check3 .\"\n", - " \". footer footer footer footer\"\n", + " \"header1 charts name1 gr_size \"\n", " '''))\n", "\n", - "\n", "def ptycho_interact(beam, aperture, aperture_res, aperture_res2, probe, cl, matrix, defocus, mag, camera, binning, dwell_time, restriction, method, ctf_xaxis, cl_check_laa, cl_check_pix, cl_check_def, cl_check_1bf, cl_check_nbf, graph_size, chart):\n", " \n", " ### SINGLE SETTING PARAMETERS ###\n", @@ -664,7 +700,7 @@ " left_column = VBox([go.FigureWidget(fig8)])\n", " total = HBox([left_column, right_column])\n", " \n", - " total.layout = Layout(border='solid 0px gray',margin='10px 10px 10px 40px', padding='10px 10px 10px 10px') \n", + " total.layout = Layout(border='solid 0px gray',margin='0px 0px 0px 20px', padding='0px 0px 0px 0px') \n", " display(total)\n", "\n", " \n", @@ -794,7 +830,7 @@ " left_column = go.FigureWidget(fig8)\n", " total = HBox([left_column, right_column]) \n", " \n", - " total.layout = Layout(border='solid 0px gray',margin='10px 10px 10px 40px', padding='10px 10px 10px 10px') \n", + " total.layout = Layout(border='solid 0px gray',margin='0px 0px 0px 10px', padding='0px 0px 0px 10px') \n", " display(total)\n", "\n", " \n", @@ -835,14 +871,14 @@ }, { "cell_type": "code", - "execution_count": 23, + "execution_count": 214, "id": "7937f054-fcd0-4e67-a20f-7696f5903a94", "metadata": {}, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { - "model_id": "0a48e2bb85fd41a5931e183508ad4aa4", + "model_id": "59e5c62c96044e0c8cc325a6e1686415", "version_major": 2, "version_minor": 0 }, @@ -855,7 +891,7 @@ } ], "source": [ - "display(HBox([controls, VBox([small_controls, gui])]))" + "display(HBox([controls, VBox([small_controls1, gui, small_controls2])]))" ] } ],