Version 0.11

This commit is contained in:
rskoupy
2023-11-30 18:09:59 +01:00
parent c5e672746f
commit 5641f0adbd
3 changed files with 106 additions and 62 deletions

View File

@ -2,19 +2,10 @@
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"execution_count": 41,
"id": "7425242d-3c91-4c1e-a424-08625a38ee7a",
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"C:\\Users\\skoupy_r\\Anaconda3\\lib\\site-packages\\scipy\\__init__.py:155: UserWarning: A NumPy version >=1.18.5 and <1.25.0 is required for this version of SciPy (detected version 1.26.1\n",
" warnings.warn(f\"A NumPy version >={np_minversion} and <{np_maxversion}\"\n"
]
}
],
"outputs": [],
"source": [
"### Initial packages import ###################################################\n",
"import numpy as np\n",
@ -24,7 +15,7 @@
"from pandas import read_excel\n",
"from IPython.display import display\n",
"from plotly.subplots import make_subplots\n",
"from ipywidgets import interactive_output, HBox, VBox, Layout, Label, Valid, ToggleButtons, RadioButtons, Dropdown, IntSlider\n",
"from ipywidgets import interactive_output, HBox, VBox, Layout, Label, Valid, ToggleButtons, RadioButtons, Dropdown, IntSlider, Checkbox\n",
"\n",
"# print(\"Numpy version \", np.__version__)\n",
"# print(\"Pandas version \", pd.__version__)\n",
@ -307,7 +298,7 @@
},
{
"cell_type": "code",
"execution_count": 17,
"execution_count": 68,
"id": "8055b802-cf83-4250-aea9-54e3e6b73db0",
"metadata": {},
"outputs": [],
@ -333,10 +324,23 @@
"dwell_time = ToggleButtons(options=opt.dwelltimes(), value=10, description='Dwell time (μs)', **align, tooltips=['', ''])\n",
"\n",
"### Small controls ###\n",
"align2 = dict(layout=Layout(width='200px') , style = {'description_width': '100px','button_width': '50px'}, disabled=False,)\n",
"method = ToggleButtons(options=[('Direct','direct'), ('Iterative','iterative')], description='Methods', **align2, button_style='', tooltips=['SSB', 'PIE, MLc, DM'])\n",
"align2 = dict(layout=Layout(width='200px') , style = {'description_width': '100px','button_width': '100px'}, disabled=False,)\n",
"method = ToggleButtons(options=[('Direct methods','direct'), ('Iterative methods','iterative')], description='', **align2, button_style='', tooltips=['SSB', 'PIE, MLc, DM'])\n",
"ctf_xaxis = RadioButtons(options=['mrad', 'A'], description='CTF-SSB x-axis:', **align2) \n",
"scans = RadioButtons(options=[4,6,8,10],description='Scan points:',continuous_update=False, **align2)\n",
"scans = RadioButtons(options=[4,6,8,10],description='Beam positions:',continuous_update=False, **align2)\n",
"\n",
"\n",
"cl_check_laa = Checkbox(value=True, description='Low angle approximation', disabled=False, indent=False,) # Low angle approximation check - scattering angle < 10 deg\n",
"cl_check_pix = Checkbox(value=True, description='Ptycho pixel < step size', disabled=False, indent=False,) # Reconstructed pixel size < scanning step size \n",
"cl_check_def = Checkbox(value=True, description='Beam fits in probe window', disabled=False, indent=False,) # Is probe window big enough to accomodate defocused probe?\n",
"cl_check_nbf = Checkbox(value=True, description='Detector cover < 1α', disabled=False, indent=False,) # Detector cover is lower than 1 α; orange\n",
"\n",
"\n",
" \n",
"\n",
"\n",
"\n",
"\n",
"\n",
"### Live update ### \n",
"beam_res = Label(value = f'Wavelength (pm) '+ str(\"{:.2f}\".format(pty.get_wavelength(beam.value)*1e12)), **to_right2)\n",
@ -363,10 +367,10 @@
"col3 = VBox([Label('Camera length'), cl, HBox([restriction, cl_det_res])], layout=box_layout)\n",
"col4 = VBox([Label('Detection'), HBox([camera, camera_res]), pixel_size_res, binning, dwell_time, dwell_time_res], layout=box_layout)\n",
"\n",
"small_control = VBox([Label('Graph controls'),method, ctf_xaxis, scans], layout = Layout(border='dashed 0px gray',margin='32px 30px 00px 10px', padding='5px 5px 5px 5px'))\n",
"small_control = VBox([Label('Graph controls'),method, ctf_xaxis, scans, VBox([Label('Camera length check list'), cl_check_laa, cl_check_pix, cl_check_def, cl_check_nbf])], layout = Layout(border='dashed 0px gray',margin='32px 30px 00px 10px', padding='5px 5px 5px 5px'))\n",
"controls = HBox([VBox([Label(''), col1, col2, col3, col4]), small_control])\n",
"\n",
"def ptycho_interact(beam, aperture, probe, cl, matrix, defocus, mag, camera, binning, dwell_time, restriction, method, ctf_xaxis, scans):\n",
"def ptycho_interact(beam, aperture, probe, cl, matrix, defocus, mag, camera, binning, dwell_time, restriction, method, ctf_xaxis, scans, cl_check_laa, cl_check_pix, cl_check_def, cl_check_nbf):\n",
" \n",
" ### SINGLE SETTING PARAMETERS ###\n",
" wavelength = pty.get_wavelength(beam)*1e12\n",
@ -639,19 +643,36 @@
" for i in range(0,12):\n",
" button_style = 'success'\n",
" data = tab[:,int(i)] # 0. ptycho pix, 1.det cov 2.det cov a, 3.max def, 4.cl\n",
" \n",
"\n",
" if cl_check_laa == True:\n",
" if data[1] > 1000*np.radians(10):\n",
" button_style = 'danger' \n",
" \n",
" if cl_check_pix == True: \n",
" if data[0] > step_size_corr*10:\n",
" button_style = 'warning'\n",
" button_style = 'danger'\n",
" \n",
" if cl_check_def == True: \n",
" if data[3] < defocus:\n",
" button_style = 'danger'\n",
" \n",
" if cl_check_nbf == True: \n",
" if data[2] < 1:\n",
" button_style = 'warning' \n",
" button_style = 'danger' \n",
" \n",
" dictionary[i] = ToggleButtons(options=data, description='',button_style=button_style, **align6)\n",
" \n",
" legend = ToggleButtons(options=['Ptycho pix. (Å)','Det. cover (mrad)','Det. cover (α)', 'Max. defocus (nm)','Nominal CL (cm)'], description='',button_style='', **align7) \n",
" legend = ToggleButtons(options=['Ptycho pix. (Å)','Det. cover (mrad)','Det. cover (α)', 'Max. defocus (nm)','Nominal CL (cm)'], \n",
" tooltips=['Dependent on: detector, beam energy, camera length',\n",
" 'Dependent on: detector, camera length',\n",
" 'Dependent on: detector, camera length, probe semi-angle',\n",
" 'Dependent on: detector, binning, beam energy, camera length, zero defocus beam diameter, probe semi-angle',\n",
" 'Just nominal camera length',\n",
" ],button_style='', **align7) \n",
" \n",
" \n",
" \n",
" \n",
" cltab = 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",
" cltab = VBox([Label('Chose your reconstructed ptychographic pixe size, check needed defocus and set CL'), cltab])\n",
" cltab.layout = Layout(border='solid 0px gray',margin='10px 10px 10px 10px', padding='10px 10px 10px 10px')\n",
@ -668,7 +689,8 @@
" return \n",
" \n",
"gui = interactive_output(ptycho_interact, {\"beam\": beam, \"aperture\": aperture, \"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, \"scans\": scans}) "
" \"binning\": binning, \"dwell_time\": dwell_time, \"restriction\": restriction, \"method\": method, \"ctf_xaxis\": ctf_xaxis, \"scans\": scans,\n",
" \"cl_check_laa\":cl_check_laa, \"cl_check_pix\": cl_check_pix, \"cl_check_def\": cl_check_def, \"cl_check_nbf\": cl_check_nbf}) "
]
},
{
@ -701,14 +723,14 @@
},
{
"cell_type": "code",
"execution_count": 18,
"execution_count": 69,
"id": "7937f054-fcd0-4e67-a20f-7696f5903a94",
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "7cc0fdb91d0d4d51a8e99fcbc45fe1ee",
"model_id": "0d132191d4f0427aaa01278a955425f0",
"version_major": 2,
"version_minor": 0
},

Binary file not shown.

View File

@ -2,19 +2,10 @@
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"execution_count": 41,
"id": "7425242d-3c91-4c1e-a424-08625a38ee7a",
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"C:\\Users\\skoupy_r\\Anaconda3\\lib\\site-packages\\scipy\\__init__.py:155: UserWarning: A NumPy version >=1.18.5 and <1.25.0 is required for this version of SciPy (detected version 1.26.1\n",
" warnings.warn(f\"A NumPy version >={np_minversion} and <{np_maxversion}\"\n"
]
}
],
"outputs": [],
"source": [
"### Initial packages import ###################################################\n",
"import numpy as np\n",
@ -24,7 +15,7 @@
"from pandas import read_excel\n",
"from IPython.display import display\n",
"from plotly.subplots import make_subplots\n",
"from ipywidgets import interactive_output, HBox, VBox, Layout, Label, Valid, ToggleButtons, RadioButtons, Dropdown, IntSlider\n",
"from ipywidgets import interactive_output, HBox, VBox, Layout, Label, Valid, ToggleButtons, RadioButtons, Dropdown, IntSlider, Checkbox\n",
"\n",
"# print(\"Numpy version \", np.__version__)\n",
"# print(\"Pandas version \", pd.__version__)\n",
@ -307,7 +298,7 @@
},
{
"cell_type": "code",
"execution_count": 17,
"execution_count": 68,
"id": "8055b802-cf83-4250-aea9-54e3e6b73db0",
"metadata": {},
"outputs": [],
@ -333,10 +324,23 @@
"dwell_time = ToggleButtons(options=opt.dwelltimes(), value=10, description='Dwell time (μs)', **align, tooltips=['', ''])\n",
"\n",
"### Small controls ###\n",
"align2 = dict(layout=Layout(width='200px') , style = {'description_width': '100px','button_width': '50px'}, disabled=False,)\n",
"method = ToggleButtons(options=[('Direct','direct'), ('Iterative','iterative')], description='Methods', **align2, button_style='', tooltips=['SSB', 'PIE, MLc, DM'])\n",
"align2 = dict(layout=Layout(width='200px') , style = {'description_width': '100px','button_width': '100px'}, disabled=False,)\n",
"method = ToggleButtons(options=[('Direct methods','direct'), ('Iterative methods','iterative')], description='', **align2, button_style='', tooltips=['SSB', 'PIE, MLc, DM'])\n",
"ctf_xaxis = RadioButtons(options=['mrad', 'A'], description='CTF-SSB x-axis:', **align2) \n",
"scans = RadioButtons(options=[4,6,8,10],description='Scan points:',continuous_update=False, **align2)\n",
"scans = RadioButtons(options=[4,6,8,10],description='Beam positions:',continuous_update=False, **align2)\n",
"\n",
"\n",
"cl_check_laa = Checkbox(value=True, description='Low angle approximation', disabled=False, indent=False,) # Low angle approximation check - scattering angle < 10 deg\n",
"cl_check_pix = Checkbox(value=True, description='Ptycho pixel < step size', disabled=False, indent=False,) # Reconstructed pixel size < scanning step size \n",
"cl_check_def = Checkbox(value=True, description='Beam fits in probe window', disabled=False, indent=False,) # Is probe window big enough to accomodate defocused probe?\n",
"cl_check_nbf = Checkbox(value=True, description='Detector cover < 1α', disabled=False, indent=False,) # Detector cover is lower than 1 α; orange\n",
"\n",
"\n",
" \n",
"\n",
"\n",
"\n",
"\n",
"\n",
"### Live update ### \n",
"beam_res = Label(value = f'Wavelength (pm) '+ str(\"{:.2f}\".format(pty.get_wavelength(beam.value)*1e12)), **to_right2)\n",
@ -363,10 +367,10 @@
"col3 = VBox([Label('Camera length'), cl, HBox([restriction, cl_det_res])], layout=box_layout)\n",
"col4 = VBox([Label('Detection'), HBox([camera, camera_res]), pixel_size_res, binning, dwell_time, dwell_time_res], layout=box_layout)\n",
"\n",
"small_control = VBox([Label('Graph controls'),method, ctf_xaxis, scans], layout = Layout(border='dashed 0px gray',margin='32px 30px 00px 10px', padding='5px 5px 5px 5px'))\n",
"small_control = VBox([Label('Graph controls'),method, ctf_xaxis, scans, VBox([Label('Camera length check list'), cl_check_laa, cl_check_pix, cl_check_def, cl_check_nbf])], layout = Layout(border='dashed 0px gray',margin='32px 30px 00px 10px', padding='5px 5px 5px 5px'))\n",
"controls = HBox([VBox([Label(''), col1, col2, col3, col4]), small_control])\n",
"\n",
"def ptycho_interact(beam, aperture, probe, cl, matrix, defocus, mag, camera, binning, dwell_time, restriction, method, ctf_xaxis, scans):\n",
"def ptycho_interact(beam, aperture, probe, cl, matrix, defocus, mag, camera, binning, dwell_time, restriction, method, ctf_xaxis, scans, cl_check_laa, cl_check_pix, cl_check_def, cl_check_nbf):\n",
" \n",
" ### SINGLE SETTING PARAMETERS ###\n",
" wavelength = pty.get_wavelength(beam)*1e12\n",
@ -639,19 +643,36 @@
" for i in range(0,12):\n",
" button_style = 'success'\n",
" data = tab[:,int(i)] # 0. ptycho pix, 1.det cov 2.det cov a, 3.max def, 4.cl\n",
" \n",
"\n",
" if cl_check_laa == True:\n",
" if data[1] > 1000*np.radians(10):\n",
" button_style = 'danger' \n",
" \n",
" if cl_check_pix == True: \n",
" if data[0] > step_size_corr*10:\n",
" button_style = 'warning'\n",
" button_style = 'danger'\n",
" \n",
" if cl_check_def == True: \n",
" if data[3] < defocus:\n",
" button_style = 'danger'\n",
" \n",
" if cl_check_nbf == True: \n",
" if data[2] < 1:\n",
" button_style = 'warning' \n",
" button_style = 'danger' \n",
" \n",
" dictionary[i] = ToggleButtons(options=data, description='',button_style=button_style, **align6)\n",
" \n",
" legend = ToggleButtons(options=['Ptycho pix. (Å)','Det. cover (mrad)','Det. cover (α)', 'Max. defocus (nm)','Nominal CL (cm)'], description='',button_style='', **align7) \n",
" legend = ToggleButtons(options=['Ptycho pix. (Å)','Det. cover (mrad)','Det. cover (α)', 'Max. defocus (nm)','Nominal CL (cm)'], \n",
" tooltips=['Dependent on: detector, beam energy, camera length',\n",
" 'Dependent on: detector, camera length',\n",
" 'Dependent on: detector, camera length, probe semi-angle',\n",
" 'Dependent on: detector, binning, beam energy, camera length, zero defocus beam diameter, probe semi-angle',\n",
" 'Just nominal camera length',\n",
" ],button_style='', **align7) \n",
" \n",
" \n",
" \n",
" \n",
" cltab = 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",
" cltab = VBox([Label('Chose your reconstructed ptychographic pixe size, check needed defocus and set CL'), cltab])\n",
" cltab.layout = Layout(border='solid 0px gray',margin='10px 10px 10px 10px', padding='10px 10px 10px 10px')\n",
@ -668,7 +689,8 @@
" return \n",
" \n",
"gui = interactive_output(ptycho_interact, {\"beam\": beam, \"aperture\": aperture, \"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, \"scans\": scans}) "
" \"binning\": binning, \"dwell_time\": dwell_time, \"restriction\": restriction, \"method\": method, \"ctf_xaxis\": ctf_xaxis, \"scans\": scans,\n",
" \"cl_check_laa\":cl_check_laa, \"cl_check_pix\": cl_check_pix, \"cl_check_def\": cl_check_def, \"cl_check_nbf\": cl_check_nbf}) "
]
},
{
@ -701,14 +723,14 @@
},
{
"cell_type": "code",
"execution_count": 18,
"execution_count": 69,
"id": "7937f054-fcd0-4e67-a20f-7696f5903a94",
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "7cc0fdb91d0d4d51a8e99fcbc45fe1ee",
"model_id": "0d132191d4f0427aaa01278a955425f0",
"version_major": 2,
"version_minor": 0
},