Version 0.10
This commit is contained in:
@ -3,7 +3,7 @@
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 1,
|
||||
"id": "8f22e3c3",
|
||||
"id": "7425242d-3c91-4c1e-a424-08625a38ee7a",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
@ -13,68 +13,27 @@
|
||||
"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"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"Numpy version 1.26.1\n",
|
||||
"Matplotlib version 3.8.1\n",
|
||||
"Pandas version 2.1.2\n",
|
||||
"Ipywidgets version 7.6.5\n",
|
||||
"Plotly version 5.9.0\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"### Initial packages import ###\n",
|
||||
"import ipywidgets as widgets\n",
|
||||
"import scipy.constants as cons\n",
|
||||
"import math\n",
|
||||
"### Initial packages import ###################################################\n",
|
||||
"import numpy as np\n",
|
||||
"import pandas as pd\n",
|
||||
"import matplotlib\n",
|
||||
"import plotly.graph_objects as go\n",
|
||||
"from ipywidgets import interactive, interactive_output, interact, HBox, Layout, VBox, Label\n",
|
||||
"import copy\n",
|
||||
"import seaborn as sns\n",
|
||||
"import matplotlib.pyplot as plt\n",
|
||||
"from IPython.display import display, HTML, Markdown\n",
|
||||
"\n",
|
||||
"import plotly\n",
|
||||
"import scipy.constants as cons\n",
|
||||
"import plotly.graph_objects as go\n",
|
||||
"from copy import deepcopy\n",
|
||||
"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",
|
||||
"\n",
|
||||
"print(\"Numpy version \", np.__version__)\n",
|
||||
"print(\"Matplotlib version \", matplotlib.__version__)\n",
|
||||
"print(\"Pandas version \", pd.__version__)\n",
|
||||
"print(\"Ipywidgets version \", widgets.__version__)\n",
|
||||
"print(\"Plotly version \", plotly.__version__)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "7671c652-c4e7-4f1f-a87e-e4c67bafed51",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"Tested with packages: \\\n",
|
||||
"Numpy version 1.26.1 \\\n",
|
||||
"Matplotlib version 3.8.1 \\\n",
|
||||
"Pandas version 2.1.2 \\\n",
|
||||
"Ipywidgets version 7.6.5 \\\n",
|
||||
"Plotly version 5.9.0 "
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 170,
|
||||
"id": "7425242d-3c91-4c1e-a424-08625a38ee7a",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"### Function definitions ###\n",
|
||||
"# print(\"Numpy version \", np.__version__)\n",
|
||||
"# print(\"Pandas version \", pd.__version__)\n",
|
||||
"# print(\"Ipywidgets version \", widgets.__version__)\n",
|
||||
"# print(\"Plotly version \", plotly.__version__)\n",
|
||||
"\n",
|
||||
"calib = r'calibrations.xlsx' # Full path to the calibration file\n",
|
||||
"### Function definitions ###################################################\n",
|
||||
"\n",
|
||||
"calib = r'calibrations.xlsx' # Path to the calibration file\n",
|
||||
"\n",
|
||||
"class interaction: \n",
|
||||
" \"\"\"Loads calibration settings and ranges from .xlsx file.\n",
|
||||
@ -85,52 +44,52 @@
|
||||
" self.calib = calib\n",
|
||||
"\n",
|
||||
" def apertures(self):\n",
|
||||
" excel_data = pd.read_excel(self.calib,sheet_name='Probes')\n",
|
||||
" excel_data = read_excel(self.calib,sheet_name='Probes')\n",
|
||||
" excel_lin = list((excel_data[excel_data.Probe.isin([\"Probe\"])]))\n",
|
||||
" apertures = excel_lin[1::]\n",
|
||||
" return apertures\n",
|
||||
" \n",
|
||||
" def detectors(self):\n",
|
||||
" excel_data = pd.read_excel(self.calib,sheet_name='Detector')\n",
|
||||
" excel_data = read_excel(self.calib,sheet_name='Detector')\n",
|
||||
" excel_lin = list((excel_data[excel_data.Type.isin([\"Type\"])]))\n",
|
||||
" detectors = excel_lin[1::]\n",
|
||||
" return detectors\n",
|
||||
" \n",
|
||||
" def probes(self):\n",
|
||||
" probes = list(pd.read_excel(self.calib,sheet_name='Probes').Probe)\n",
|
||||
" probes = list(read_excel(self.calib,sheet_name='Probes').Probe)\n",
|
||||
" probes = probes[3::]\n",
|
||||
" return probes\n",
|
||||
" \n",
|
||||
" def magnifications(self):\n",
|
||||
" excel_data = pd.read_excel(self.calib,sheet_name='Ranges')\n",
|
||||
" excel_data = read_excel(self.calib,sheet_name='Ranges')\n",
|
||||
" magnifications = list(excel_data.Magnification)\n",
|
||||
" return magnifications\n",
|
||||
" \n",
|
||||
" def energies(self): \n",
|
||||
" excel_data = pd.read_excel(self.calib,sheet_name='Ranges')\n",
|
||||
" energies = [str(e) for e in list(excel_data.BeamEnergy_keV)]\n",
|
||||
" excel_data = read_excel(self.calib,sheet_name='Ranges')\n",
|
||||
" energies = [str(e) for e in list(excel_data.BeamEnergy)]\n",
|
||||
" energies = [x for x in energies if x != 'nan']\n",
|
||||
" energies = [int(float(e)) for e in energies]\n",
|
||||
" return energies\n",
|
||||
" \n",
|
||||
" def mappings(self): \n",
|
||||
" excel_data = pd.read_excel(self.calib,sheet_name='Ranges')\n",
|
||||
" excel_data = read_excel(self.calib,sheet_name='Ranges')\n",
|
||||
" mappings = [str(e) for e in list(excel_data.Mapping)]\n",
|
||||
" mappings = [x for x in mappings if x != 'nan']\n",
|
||||
" mappings = [int(float(e)) for e in mappings]\n",
|
||||
" return mappings\n",
|
||||
" \n",
|
||||
" def cameralengths(self): \n",
|
||||
" cameralengths = list(pd.read_excel(self.calib,sheet_name='Pixel').NominalCL)\n",
|
||||
" cameralengths = list(read_excel(self.calib,sheet_name='Pixel').NominalCL)\n",
|
||||
" return cameralengths\n",
|
||||
" \n",
|
||||
" def cameralengths_eff(self): \n",
|
||||
" cameralengths_eff = list(pd.read_excel(self.calib,sheet_name='Pixel').DetectorCL_cm)\n",
|
||||
" cameralengths_eff = list(read_excel(self.calib,sheet_name='Pixel').DetectorCL)\n",
|
||||
" return cameralengths_eff\n",
|
||||
"\n",
|
||||
" def dwelltimes(self): \n",
|
||||
" excel_data = pd.read_excel(self.calib,sheet_name='Ranges')\n",
|
||||
" dwelltimes = [str(e) for e in list(excel_data.DwellTime_us)]\n",
|
||||
" excel_data = read_excel(self.calib,sheet_name='Ranges')\n",
|
||||
" dwelltimes = [str(e) for e in list(excel_data.DwellTime)]\n",
|
||||
" dwelltimes = [x for x in dwelltimes if x != 'nan']\n",
|
||||
" dwelltimes = [int(float(e)) for e in dwelltimes] \n",
|
||||
" return dwelltimes \n",
|
||||
@ -158,40 +117,40 @@
|
||||
" return self.fov\n",
|
||||
" \n",
|
||||
" def get_angle(self, aperture):\n",
|
||||
" excel_data = pd.read_excel(calib, sheet_name='Probes',header=0)\n",
|
||||
" excel_line = excel_data[excel_data.Probe.isin(['ProbeSemi_angle_mrad'])]\n",
|
||||
" excel_data = read_excel(calib, sheet_name='Probes',header=0)\n",
|
||||
" excel_line = excel_data[excel_data.Probe.isin(['SemiAngle'])]\n",
|
||||
" angle = excel_line[aperture]\n",
|
||||
" self.angle = np.array(angle).item()\n",
|
||||
" return self.angle\n",
|
||||
" \n",
|
||||
" def get_angle_corr(self, aperture):\n",
|
||||
" excel_data = pd.read_excel(calib, sheet_name='Probes',header=0)\n",
|
||||
" excel_line = excel_data[excel_data.Probe.isin(['CorrectedProbeSemi_angle_mrad'])]\n",
|
||||
" excel_data = read_excel(calib, sheet_name='Probes',header=0)\n",
|
||||
" excel_line = excel_data[excel_data.Probe.isin(['SemiAngleCorr'])]\n",
|
||||
" angle_corr = excel_line[aperture]\n",
|
||||
" self.angle_corr = np.array(angle_corr).item()\n",
|
||||
" return self.angle_corr\n",
|
||||
" \n",
|
||||
" def get_current(self, probe,aperture):\n",
|
||||
" excel_data = pd.read_excel(calib, sheet_name='Probes',header=0)\n",
|
||||
" excel_data = read_excel(calib, sheet_name='Probes',header=0)\n",
|
||||
" excel_line = excel_data[excel_data.Probe.isin([probe])]\n",
|
||||
" current = excel_line[aperture]\n",
|
||||
" self.current = np.array(current).item()\n",
|
||||
" return self.current\n",
|
||||
" \n",
|
||||
" def get_currents_over_probes(self, probe):\n",
|
||||
" excel_data = pd.read_excel(calib, sheet_name='Probes',header=0)\n",
|
||||
" excel_data = read_excel(calib, sheet_name='Probes',header=0)\n",
|
||||
" currents_probes = np.array(excel_data[excel_data.Probe.isin([probe])])\n",
|
||||
" currents_probes = currents_probes[0]\n",
|
||||
" currents_probes = currents_probes[1::]\n",
|
||||
" return currents_probes\n",
|
||||
"\n",
|
||||
" def get_currents_over_apertures(self, aperture):\n",
|
||||
" excel_data = pd.read_excel(calib, sheet_name='Probes',header=0)\n",
|
||||
" excel_data = read_excel(calib, sheet_name='Probes',header=0)\n",
|
||||
" currents_apertures = np.array(list(excel_data[aperture]))\n",
|
||||
" return currents_apertures\n",
|
||||
"\n",
|
||||
" def get_pixel_angle(self, cl, camera, binning):\n",
|
||||
" excel_data = pd.read_excel(calib,sheet_name='Pixel',header=0)\n",
|
||||
" excel_data = read_excel(calib,sheet_name='Pixel',header=0)\n",
|
||||
" excel_line = excel_data[excel_data.NominalCL.isin([cl])]\n",
|
||||
" pixel_angle = excel_line[camera]\n",
|
||||
" pixel_angle = np.array(pixel_angle).item()\n",
|
||||
@ -199,9 +158,9 @@
|
||||
" return self.pixel_angle\n",
|
||||
" \n",
|
||||
" def get_cl_detector(self,cl):\n",
|
||||
" excel_data = pd.read_excel(calib,sheet_name='Pixel')\n",
|
||||
" excel_data = read_excel(calib,sheet_name='Pixel')\n",
|
||||
" excel_line = excel_data[excel_data.NominalCL.isin([cl])]\n",
|
||||
" self.cl_detector = excel_line['DetectorCL_cm']\n",
|
||||
" self.cl_detector = excel_line['DetectorCL']\n",
|
||||
" self.cl_detector = self.cl_detector.item()\n",
|
||||
" return self.cl_detector\n",
|
||||
" \n",
|
||||
@ -214,54 +173,54 @@
|
||||
" return self.step_size \n",
|
||||
" \n",
|
||||
" def get_step_correction(self): \n",
|
||||
" step_correction = [str(e) for e in list(pd.read_excel(calib,sheet_name='Ranges').Step_size_correction)]\n",
|
||||
" step_correction = [str(e) for e in list(read_excel(calib,sheet_name='Ranges').StepSizeCorr)]\n",
|
||||
" step_correction = np.array([x for x in step_correction if x != 'nan']).astype(float)\n",
|
||||
" self.step_correction = step_correction.item()\n",
|
||||
" return self.step_correction\n",
|
||||
" \n",
|
||||
" def get_beam_diameter(self, aperture, defocus):\n",
|
||||
" excel_data = pd.read_excel(calib, sheet_name='Probes')\n",
|
||||
" excel_line = excel_data[excel_data.Probe.isin(['0_defocus_beam_diameter_nm'])]\n",
|
||||
" excel_data = read_excel(calib, sheet_name='Probes')\n",
|
||||
" excel_line = excel_data[excel_data.Probe.isin(['Def0Diameter'])]\n",
|
||||
" beam_0_diameter = np.array([excel_line[aperture]]).astype(float)\n",
|
||||
" beam_0_diameter = beam_0_diameter.item()\n",
|
||||
" self.beam_diameter = defocus*2*np.tan(self.angle_corr/1000)+beam_0_diameter\n",
|
||||
" return self.beam_diameter\n",
|
||||
" \n",
|
||||
" def get_0beam_diameter(self, aperture):\n",
|
||||
" excel_data = pd.read_excel(calib, sheet_name='Probes')\n",
|
||||
" excel_line = excel_data[excel_data.Probe.isin(['0_defocus_beam_diameter_nm'])]\n",
|
||||
" excel_data = read_excel(calib, sheet_name='Probes')\n",
|
||||
" excel_line = excel_data[excel_data.Probe.isin(['Def0Diameter'])]\n",
|
||||
" beam_0_diameter = np.array([excel_line[aperture]]).astype(float)\n",
|
||||
" self.beam_0_diameter = beam_0_diameter.item()\n",
|
||||
" return self.beam_0_diameter\n",
|
||||
" \n",
|
||||
" def get_detector(self, camera, binning):\n",
|
||||
" excel_data = pd.read_excel(calib, sheet_name='Detector')\n",
|
||||
" excel_line = excel_data[excel_data.Type.isin(['Pixels'])]\n",
|
||||
" excel_data = read_excel(calib, sheet_name='Detector')\n",
|
||||
" excel_line = excel_data[excel_data.Type.isin(['Array'])]\n",
|
||||
" num_pixels = np.array([excel_line[camera]]).astype(float)\n",
|
||||
" num_pixels = num_pixels.item()\n",
|
||||
" self.num_pixels = num_pixels/binning\n",
|
||||
" excel_line = excel_data[excel_data.Type.isin(['Real_size'])]\n",
|
||||
" excel_line = excel_data[excel_data.Type.isin(['RealSize'])]\n",
|
||||
" size_pixel = excel_line[camera]\n",
|
||||
" size_pixel = size_pixel.item()\n",
|
||||
" self.size_pixel = size_pixel*binning\n",
|
||||
" return self.num_pixels, self.size_pixel \n",
|
||||
" \n",
|
||||
" def get_det_resolution(self, camera):\n",
|
||||
" excel_data = pd.read_excel(calib, sheet_name='Detector')\n",
|
||||
" excel_line = excel_data[excel_data.Type.isin(['Pixels'])]\n",
|
||||
" excel_data = read_excel(calib, sheet_name='Detector')\n",
|
||||
" excel_line = excel_data[excel_data.Type.isin(['Array'])]\n",
|
||||
" num_pixels = np.array([excel_line[camera]]).astype(float)\n",
|
||||
" self.num_pixels = num_pixels.item()\n",
|
||||
" return self.num_pixels\n",
|
||||
" \n",
|
||||
" def get_det_orig_pixel_size(self, camera):\n",
|
||||
" excel_data = pd.read_excel(calib, sheet_name='Detector')\n",
|
||||
" excel_line = excel_data[excel_data.Type.isin(['Real_size'])]\n",
|
||||
" excel_data = read_excel(calib, sheet_name='Detector')\n",
|
||||
" excel_line = excel_data[excel_data.Type.isin(['RealSize'])]\n",
|
||||
" orig_size_pixel = excel_line[camera]\n",
|
||||
" self.orig_size_pixel = orig_size_pixel.item()\n",
|
||||
" return self.orig_size_pixel\n",
|
||||
" \n",
|
||||
" def get_pixel_covers(self,camera, binning): \n",
|
||||
" excel_data = pd.read_excel(calib, sheet_name='Pixel')\n",
|
||||
" excel_data = read_excel(calib, sheet_name='Pixel')\n",
|
||||
" pixel_covers = list(excel_data[camera])\n",
|
||||
" pixel_covers = [str(e) for e in pixel_covers]\n",
|
||||
" pixel_covers = [x for x in pixel_covers if x != 'nan']\n",
|
||||
@ -271,8 +230,8 @@
|
||||
" return self.pixel_covers\n",
|
||||
"\n",
|
||||
" def get_pumping_apertures(self): \n",
|
||||
" excel_data = pd.read_excel(calib,sheet_name='Pixel')\n",
|
||||
" pump_apert = [str(e) for e in list(excel_data.Pumping_aperture_limitation_mrad)]\n",
|
||||
" excel_data = read_excel(calib,sheet_name='Pixel')\n",
|
||||
" pump_apert = [str(e) for e in list(excel_data.PAAR)]\n",
|
||||
" pump_apert = [x for x in pump_apert if x != 'nan']\n",
|
||||
" self.pump_apert = [float(e) for e in pump_apert]\n",
|
||||
" return self.pump_apert \n",
|
||||
@ -291,7 +250,7 @@
|
||||
" \n",
|
||||
" \n",
|
||||
" def cl4ssb(self, detector_cover_a_all):\n",
|
||||
" ssb_cl = copy.deepcopy(detector_cover_a_all)\n",
|
||||
" ssb_cl = deepcopy(detector_cover_a_all)\n",
|
||||
" ssb_cl[ssb_cl<1] = \"nan\"\n",
|
||||
" ssb_cl = np.nanmin(ssb_cl)\n",
|
||||
" kde = np.array(np.where(ssb_cl == detector_cover_a_all)).item()\n",
|
||||
@ -304,7 +263,7 @@
|
||||
"pty = ptychoScopy() \n",
|
||||
" \n",
|
||||
"class interaction:\n",
|
||||
" \"\"\"Live interaction with parameter computing.\"\"\"\n",
|
||||
" \"\"\"Live interaction with computing of various parameters.\"\"\"\n",
|
||||
" \n",
|
||||
" def __init__(self):\n",
|
||||
" self.calib = calib\n",
|
||||
@ -331,82 +290,83 @@
|
||||
" return aperture_res2.value\n",
|
||||
" \n",
|
||||
" def show_fov(self,caller):\n",
|
||||
" fov_res.value = f'Field of view (nm) {pty.get_fov(caller.new) }'\n",
|
||||
" fov_res.value = f'Field of view (nm) {\"{:.2f}\".format(pty.get_fov(caller.new))}'\n",
|
||||
" return fov_res.value\n",
|
||||
" \n",
|
||||
" def show_frame_rate(self,caller):\n",
|
||||
" dwell_time_res.value = f'Frame rate (kHz) {pty.get_aq_frec(caller.new)}' \n",
|
||||
" dwell_time_res.value = f'Frame rate (kHz) {\"{:.2f}\".format(pty.get_aq_frec(caller.new))}' \n",
|
||||
" return dwell_time_res.value\n",
|
||||
" \n",
|
||||
" def show_cd_det(self,caller):\n",
|
||||
" cl_det_res.value = f'Detector CL (cm) {pty.get_cl_detector(caller.new)}' \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",
|
||||
" \n",
|
||||
"inte = interaction() \n",
|
||||
"\n"
|
||||
"inte = interaction() \n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 200,
|
||||
"execution_count": 17,
|
||||
"id": "8055b802-cf83-4250-aea9-54e3e6b73db0",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"### CONTROLS ##########################################\n",
|
||||
"align = dict(layout=widgets.Layout(width='385px') , style = {'description_width': '80px','button_width': \"35px\"}, button_style='primary',disabled=False,)\n",
|
||||
"align3 = dict(layout=widgets.Layout(width='230px') , style = {'description_width': '80px','button_width': \"35px\"}, button_style='primary', disabled=False,)\n",
|
||||
"to_right = dict(layout=widgets.Layout(display=\"flex\", justify_content=\"flex-end\", width=\"95%\", ))\n",
|
||||
"to_right2 = dict(layout=widgets.Layout(display=\"flex\", justify_content=\"flex-end\", width=\"35%\", ))\n",
|
||||
"align = dict(layout=Layout(width='385px') , style = {'description_width': '80px','button_width': \"35px\"}, button_style='primary',disabled=False,)\n",
|
||||
"align3 = dict(layout=Layout(width='230px') , style = {'description_width': '80px','button_width': \"35px\"}, button_style='primary', disabled=False,)\n",
|
||||
"to_right = dict(layout=Layout(display=\"flex\", justify_content=\"flex-end\", width=\"95%\", ))\n",
|
||||
"to_right2 = dict(layout=Layout(display=\"flex\", justify_content=\"flex-end\", width=\"35%\", ))\n",
|
||||
"\n",
|
||||
"### Main controls ###\n",
|
||||
"beam = widgets.Dropdown(options=opt.energies(),value=200,description='Energy (keV)', **align3)\n",
|
||||
"aperture = widgets.ToggleButtons(options=opt.apertures(), value='30um', description='Aperture', **align, tooltips=['', ''])\n",
|
||||
"probe = widgets.ToggleButtons(options=opt.probes(), value='8C', description='Probe', **align, tooltips=['', ''])\n",
|
||||
"defocus = widgets.IntSlider(description='Defocus (nm)', value=0, min=0, max=1000, step=1, continuous_update=False, **align )\n",
|
||||
"beam = Dropdown(options=opt.energies(),value=200,description='Energy (keV)', **align3)\n",
|
||||
"aperture = ToggleButtons(options=opt.apertures(), value='30um', description='Aperture', **align, tooltips=['', ''])\n",
|
||||
"probe = ToggleButtons(options=opt.probes(), value='8C', description='Probe', **align, tooltips=['', ''])\n",
|
||||
"defocus = IntSlider(description='Defocus (nm)', value=0, min=0, max=1000, step=1, continuous_update=False, **align )\n",
|
||||
"defocus.style.handle_color = 'blue'\n",
|
||||
"mag = widgets.ToggleButtons(options=opt.magnifications(),value=3,description='Mag. (Mx)', **align) \n",
|
||||
"matrix = widgets.ToggleButtons(options=opt.mappings(), value=2048, description='Matrix', **align, tooltips=['', ''])\n",
|
||||
"cl = widgets.ToggleButtons(options=opt.cameralengths(), value=12, description='Nominal (cm)', **align, tooltips=['', ''])\n",
|
||||
"camera = widgets.Dropdown(options=opt.detectors(), description='Detector', **align3, tooltips=['', ''])\n",
|
||||
"restriction = widgets.ToggleButtons(options=[('NO',False), ('YES',True)], description='Use PAAR',**align3, tooltips=['', ''])\n",
|
||||
"binning = widgets.ToggleButtons(options=[('NO',1), ('2×2',2), ('4×4',4),('6×6',6),('8×8',8)], description='Binning', **align, tooltips=['Full detector resolution', 'Binning 2x2 - detector resolution /2, pixel size *2', 'Binning 4x4'])\n",
|
||||
"dwell_time = widgets.ToggleButtons(options=opt.dwelltimes(), value=10, description='Dwell time (μs)', **align, tooltips=['', ''])\n",
|
||||
"mag = ToggleButtons(options=opt.magnifications(),value=3,description='Mag. (Mx)', **align) \n",
|
||||
"matrix = ToggleButtons(options=opt.mappings(), value=2048, description='Matrix', **align, tooltips=['', ''])\n",
|
||||
"cl = ToggleButtons(options=opt.cameralengths(), value=12, description='Nominal (cm)', **align, tooltips=['', ''])\n",
|
||||
"camera = Dropdown(options=opt.detectors(), description='Detector', **align3, tooltips=['', ''])\n",
|
||||
"restriction = ToggleButtons(options=[('NO',False), ('YES',True)], description='Use PAAR',**align3, tooltips=['', ''])\n",
|
||||
"binning = ToggleButtons(options=[('NO',1), ('2×2',2), ('4×4',4),('6×6',6),('8×8',8)], description='Binning', **align, tooltips=['Full detector resolution', 'Binning 2x2 - detector resolution /2, pixel size *2', 'Binning 4x4'])\n",
|
||||
"dwell_time = ToggleButtons(options=opt.dwelltimes(), value=10, description='Dwell time (μs)', **align, tooltips=['', ''])\n",
|
||||
"\n",
|
||||
"### Small controls ###\n",
|
||||
"align2 = dict(layout=widgets.Layout(width='200px') , style = {'description_width': '100px','button_width': '50px'}, disabled=False,)\n",
|
||||
"method = widgets.ToggleButtons(options=[('Direct','direct'), ('Iterative','iterative')], description='Methods', **align2, button_style='', tooltips=['SSB', 'PIE, MLc, DM'])\n",
|
||||
"ssb_freq_length = widgets.RadioButtons(options=['mrad', 'A'], description='CTF-SSB x-axis:', **align2) \n",
|
||||
"scans = widgets.RadioButtons(options=[4,6,8,10],description='Scan points:',continuous_update=False, **align2)\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",
|
||||
"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",
|
||||
"\n",
|
||||
"### Live update ### \n",
|
||||
"beam_res = widgets.Label(value = f'Wavelength (pm) '+ str(\"{:.2f}\".format(pty.get_wavelength(beam.value)*1e12)), **to_right2)\n",
|
||||
"beam_res = Label(value = f'Wavelength (pm) '+ str(\"{:.2f}\".format(pty.get_wavelength(beam.value)*1e12)), **to_right2)\n",
|
||||
"beam.observe(inte.show_wavelength, names='value')\n",
|
||||
"camera_res = widgets.Label(value = f'Full pixel array '+ str(\"{:.0f}\".format(pty.get_det_resolution(camera.value))), **to_right2)\n",
|
||||
"camera_res = Label(value = f'Full pixel array '+ str(\"{:.0f}\".format(pty.get_det_resolution(camera.value))), **to_right2)\n",
|
||||
"camera.observe(inte.show_detector, names='value')\n",
|
||||
"pixel_size_res = widgets.Label(value = f'Native pixel size (μm) '+ str(\"{:.0f}\".format(pty.get_det_orig_pixel_size(camera.value))),**to_right)\n",
|
||||
"pixel_size_res = Label(value = f'Native pixel size (μm) '+ str(\"{:.0f}\".format(pty.get_det_orig_pixel_size(camera.value))),**to_right)\n",
|
||||
"camera.observe(inte.show_pixel_size, names='value')\n",
|
||||
"aperture_res = widgets.Label(value = f'Probe semi angle (mrad) '+ str(\"{:.2f}\".format(pty.get_angle(aperture.value))), **to_right)\n",
|
||||
"aperture.observe(inte.show_probe_angle, names='value') \n",
|
||||
"aperture_res2 = widgets.Label(value = f'Corrected semi angle (mrad) '+ str(\"{:.2f}\".format(pty.get_angle_corr(aperture.value))), **to_right)\n",
|
||||
"aperture.observe(inte.show_corrprobe_angle, names='value') \n",
|
||||
"fov_res = widgets.Label(value = f'Field of view (nm) '+ str(pty.get_fov(mag.value)), **to_right)\n",
|
||||
"# aperture_res = Label(value = f'Probe semi angle (mrad) '+ str(\"{:.2f}\".format(pty.get_angle(aperture.value))), **to_right)\n",
|
||||
"# aperture.observe(inte.show_probe_angle, names='value') \n",
|
||||
"# aperture_res2 = Label(value = f'Corrected semi angle (mrad) '+ str(\"{:.2f}\".format(pty.get_angle_corr(aperture.value))), **to_right)\n",
|
||||
"# aperture.observe(inte.show_corrprobe_angle, names='value') \n",
|
||||
"fov_res = Label(value = f'Field of view (nm) '+ str(\"{:.2f}\".format(pty.get_fov(mag.value))), **to_right)\n",
|
||||
"mag.observe(inte.show_fov, names='value') \n",
|
||||
"dwell_time_res = widgets.Label(value = f'Frame rate (kHz) '+ str(pty.get_aq_frec(dwell_time.value)),**to_right)\n",
|
||||
"dwell_time_res = Label(value = f'Frame rate (kHz) '+ str(\"{:.2f}\".format(pty.get_aq_frec(dwell_time.value))),**to_right)\n",
|
||||
"dwell_time.observe(inte.show_frame_rate, names='value') \n",
|
||||
"cl_det_res = widgets.Label(value = f'Detector CL (cm) '+ str(pty.get_cl_detector(cl.value)),**to_right2)\n",
|
||||
"cl_det_res = Label(value = f'Detector CL (cm) '+ str(\"{:.1f}\".format(pty.get_cl_detector(cl.value))),**to_right2)\n",
|
||||
"cl.observe(inte.show_cd_det, names='value') \n",
|
||||
"\n",
|
||||
"box_layout = widgets.Layout(border='solid 2px #1976D2',margin='0px 0px 0px 0px', padding='5px 5px 5px 5px')\n",
|
||||
"col1 = widgets.VBox([widgets.Label('Beam'), widgets.HBox([beam ,beam_res]), aperture, probe, defocus], layout=box_layout) # aperture_res, aperture_res2,\n",
|
||||
"col2 = widgets.VBox([widgets.Label('Scanning'), mag, fov_res, matrix], layout=box_layout)\n",
|
||||
"col3 = widgets.VBox([widgets.Label('Camera length'), cl, widgets.HBox([restriction, cl_det_res])], layout=box_layout)\n",
|
||||
"col4 = widgets.VBox([widgets.Label('Detection'), widgets.HBox([camera, camera_res]), pixel_size_res, binning, dwell_time, dwell_time_res], layout=box_layout)\n",
|
||||
"### Controls layout ###\n",
|
||||
"box_layout = Layout(border='solid 2px #1976D2',margin='0px 0px 0px 0px', padding='5px 5px 5px 5px')\n",
|
||||
"col1 = VBox([Label('Beam'), HBox([beam ,beam_res]), aperture, probe, defocus], layout=box_layout) # aperture_res, aperture_res2,\n",
|
||||
"col2 = VBox([Label('Scanning'), mag, fov_res, matrix], layout=box_layout)\n",
|
||||
"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 = widgets.VBox([widgets.Label('Graph controls'),method, ssb_freq_length, scans], layout = widgets.Layout(border='dashed 0px gray',margin='32px 30px 00px 10px', padding='5px 5px 5px 5px'))\n",
|
||||
"controls = widgets.HBox([widgets.VBox([widgets.Label(''), col1, col2, col3, col4]), small_control])\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",
|
||||
"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, ssb_freq_length, scans):\n",
|
||||
"def ptycho_interact(beam, aperture, probe, cl, matrix, defocus, mag, camera, binning, dwell_time, restriction, method, ctf_xaxis, scans):\n",
|
||||
" \n",
|
||||
" ### SINGLE SETTING PARAMETERS ###\n",
|
||||
" wavelength = pty.get_wavelength(beam)*1e12\n",
|
||||
@ -456,19 +416,20 @@
|
||||
" ### PROBE ##########################################\n",
|
||||
" fig = go.Figure() \n",
|
||||
" fig.update_yaxes(title_text=\" CTF-SSB\")\n",
|
||||
" if ssb_freq_length == 'mrad': \n",
|
||||
" xx = 2*wavelength/(np.sin(semi_angle_corr*omega/1000))/100\n",
|
||||
" if ctf_xaxis == 'mrad': \n",
|
||||
" for x in apertury:\n",
|
||||
" fig.add_trace(go.Scatter(showlegend=False, x=pty.get_angle_corr(x) *omega, y=pctf, marker_color='gray', name='SSB-CTF',))\n",
|
||||
" \n",
|
||||
" fig.add_trace(go.Scatter(x=semi_angle_corr*omega, y=pctf, marker_color='red', name=str(np.round(semi_angle_corr,2))+ ' mrad',))\n",
|
||||
" fig.update_xaxes(title_text=\"Spacial frequency (mrad)\", range=[0, 60], zeroline=False)\n",
|
||||
"\n",
|
||||
" elif ssb_freq_length == 'A':\n",
|
||||
" elif ctf_xaxis == 'A':\n",
|
||||
" for x in apertury:\n",
|
||||
" d = 2*wavelength/(np.sin(pty.get_angle_corr(x)*omega/1000))/100\n",
|
||||
" fig.add_trace(go.Scatter(showlegend=False, x=d, y=pctf, marker_color='gray', name='SSB-CTF',))\n",
|
||||
" \n",
|
||||
" fig.add_trace(go.Scatter(x=2*wavelength/(np.sin(semi_angle_corr*omega/1000))/100, y=pctf, marker_color='red', name=str(np.round(semi_angle_corr,2))+ ' mrad',))\n",
|
||||
" \n",
|
||||
" fig.add_trace(go.Scatter(x=xx, y=pctf, marker_color='red', name=str(np.round(semi_angle_corr,2))+ ' mrad',))\n",
|
||||
" fig.update_xaxes(title_text=\"Real space distance (Å)\", range=[0.0001, 2.5], type=\"log\", zeroline=False)\n",
|
||||
" \n",
|
||||
" fig.update_layout(legend=dict(orientation=\"h\",yanchor=\"bottom\",y=0.75,xanchor=\"right\",x=1))\n",
|
||||
@ -489,8 +450,8 @@
|
||||
" for y in range(len(wid)): \n",
|
||||
" fig5.add_shape(type=\"circle\",xref=\"x\", yref=\"y\", opacity=0.1, fillcolor=\"#FF7F7F\",name=False, x0=wid[x]-beam_diameter/2, y0=wid[y]-beam_diameter/2, x1=wid[x]+beam_diameter/2, y1=wid[y]+beam_diameter/2, line_color=\"red\",secondary_y=False)\n",
|
||||
"\n",
|
||||
" fig5.add_trace(go.Scatter(showlegend=True, x=[-1], y=[-1],marker_size=12, marker_color='blue', name='Step '+str(np.round(step_size,3))+' nm ('+str(np.round(step_size_corr,3))+')'))\n",
|
||||
" fig5.add_trace(go.Scatter(showlegend=True, x=[-1], y=[-1],marker_size=12, marker_color='#FF7F7F', name='Beam ⌀ '+ str(np.round(beam_diameter,2))+\" nm\"))\n",
|
||||
" fig5.add_trace(go.Scatter(showlegend=True, x=[-1], y=[-1],marker_size=12, marker_color='blue', name='Step '+str(np.round(10*step_size,3))+' Å ('+str(np.round(10*step_size_corr,3))+')'))\n",
|
||||
" fig5.add_trace(go.Scatter(showlegend=True, x=[-1], y=[-1],marker_size=12, marker_color='#FF7F7F', name='Beam ⌀ '+ str(np.round(10*beam_diameter,2))+\" Å\"))\n",
|
||||
" fig5.update_layout(legend=dict(orientation=\"v\",yanchor=\"bottom\",y=0.85,xanchor=\"right\",x=0.9))\n",
|
||||
" fig5.add_trace(go.Scatter(showlegend=False, x = scans*step_size_corr*np.ones(len(yyy)), y=yyy, opacity=1,mode='markers',marker_symbol = \"triangle-down\",marker=dict(size=20, color=yyy, colorscale='rainbow_r', showscale=False)),secondary_y=True) \n",
|
||||
" \n",
|
||||
@ -594,25 +555,23 @@
|
||||
" \n",
|
||||
" \n",
|
||||
" ### FINAL CHECKS ########################################## \n",
|
||||
" align3 = dict(layout=widgets.Layout(width='200px') , style = {'description_width': '150px','button_width': \"100px\"}, disabled=True,) \n",
|
||||
" align3 = dict(layout=Layout(width='200px') , style = {'description_width': '150px','button_width': \"100px\"}, disabled=True,) \n",
|
||||
" \n",
|
||||
" check1 = widgets.Valid(value= bool(overlap > 60), description='Overlap > 60 %', **align3)\n",
|
||||
" check2 = widgets.Valid(value= bool(step_size_corr*10 > (wavelength * cl_det)/(num_pixels*size_pixel/1e6)/1e4), description='Ptycho pix < step size', **align3)\n",
|
||||
" check3 = widgets.Valid(value= bool(beam_diameter/2 < probe_window/2), description='Beam ⌀ < window/2', **align3) \n",
|
||||
" check1 = Valid(value= bool(overlap > 60), description='Overlap > 60 %', **align3)\n",
|
||||
" check2 = Valid(value= bool(step_size_corr*10 > (wavelength * cl_det)/(num_pixels*size_pixel/1e6)/1e4), description='Ptycho pix < step size', **align3)\n",
|
||||
" check3 = Valid(value= bool(beam_diameter/2 < probe_window/2), description='Beam ⌀ < window/2', **align3) \n",
|
||||
" \n",
|
||||
" electron_dose = widgets.Label(value = f'Electron dose (e/Å2) '+ str(np.round(dose,1)), **align3) \n",
|
||||
" \n",
|
||||
" acquisition_time = widgets.Label(value = f'Acquisition time (s) '+ str(np.round(matrix*matrix*dwell_time/1e6,1)), **align3) \n",
|
||||
" \n",
|
||||
" focusdepth = widgets.Label(value = f'Depth of focus (nm) '+ str(np.round(wavelength/(semi_angle_corr/1000)**2/1000,1)), **align3) \n",
|
||||
" \n",
|
||||
" \n",
|
||||
"\n",
|
||||
" electron_dose = Label(value = f'Electron dose (e/Å2) '+ str(np.round(dose,1)), **align3) \n",
|
||||
" acquisition_time = Label(value = f'Acquisition time (s) '+ str(np.round(matrix*matrix*dwell_time/1e6,1)), **align3) \n",
|
||||
" focusdepth = Label(value = f'Depth of focus (nm) '+ str(np.round(wavelength/(semi_angle_corr/1000)**2/1000,1)), **align3) \n",
|
||||
"\n",
|
||||
"\n",
|
||||
" ### METHODS ########################################## \n",
|
||||
" if method == 'direct':\n",
|
||||
" \n",
|
||||
" \n",
|
||||
" ssb_sampling = Label(value = f'Recommended sampling (Å) '+ str(np.round(xx[-1]/3,2)), **align3) \n",
|
||||
" \n",
|
||||
" ### CAMERA LENGTH GRAPH ##########################################\n",
|
||||
" fig4 = make_subplots(specs=[[{\"secondary_y\": True}]])\n",
|
||||
" fig4.add_trace(go.Scatter(showlegend=False, x=opt.cameralengths(), y=detector_cover_all, marker_color='gray'), secondary_y=False,)\n",
|
||||
@ -623,29 +582,29 @@
|
||||
" # fig4.update_layout(title={'text': \"CL to α\",'y':0.93, 'x':0.12,'xanchor': 'left','yanchor': 'top'})\n",
|
||||
" fig4.update_xaxes(title_text=\"Nominal camera length (cm)\", type=\"log\", tickvals = opt.cameralengths())\n",
|
||||
" fig4.update_layout(xaxis = dict(tickmode = 'array', tickvals = [1, num_pixels/4, num_pixels/2, 3*num_pixels/4, num_pixels]))\n",
|
||||
" fig4.update_yaxes(title_text=\" Cover angle (mrad)\", secondary_y=False)\n",
|
||||
" fig4.update_yaxes(title_text=\" Cover angle (α)\",showgrid=False, secondary_y=True)\n",
|
||||
" fig4.update_yaxes(title_text=\" Cover angle (mrad)\", range=[0, 1.1*np.max(detector_cover_all)], secondary_y=False)\n",
|
||||
" fig4.update_yaxes(title_text=\" Cover angle (α)\", range=[0, 1.1*np.max(detector_cover_a_all)], showgrid=False, secondary_y=True)\n",
|
||||
" fig4.update_layout(xaxis = dict(tickmode = 'array', tickvals = opt.cameralengths()))\n",
|
||||
" fig4.update_layout(width=800, height=225, margin =dict(l=110, r=30, t=30, b=30))\n",
|
||||
" \n",
|
||||
" \n",
|
||||
" checks = widgets.VBox([widgets.Label('Final checks'), electron_dose,focusdepth, acquisition_time]) \n",
|
||||
" checks.layout = widgets.Layout(border='dashed 1px gray',margin='30px 5px 5px 5px', padding='10px 10px 10px 10px')\n",
|
||||
" checks = VBox([Label('Final checks'), electron_dose, ssb_sampling, focusdepth, acquisition_time]) \n",
|
||||
" checks.layout = Layout(border='dashed 1px gray',margin='30px 5px 5px 5px', padding='10px 10px 10px 10px')\n",
|
||||
" \n",
|
||||
" \n",
|
||||
" ### SHOWING ###\n",
|
||||
" right_column = widgets.VBox([go.FigureWidget(fig),go.FigureWidget(fig5),go.FigureWidget(fig4)])\n",
|
||||
" left_column = widgets.VBox([go.FigureWidget(fig8), go.FigureWidget(fig6)])\n",
|
||||
" display(widgets.HBox([left_column, right_column, checks]))\n",
|
||||
" \n",
|
||||
" right_column = VBox([go.FigureWidget(fig),go.FigureWidget(fig5),go.FigureWidget(fig4)])\n",
|
||||
" left_column = VBox([go.FigureWidget(fig8), go.FigureWidget(fig6)])\n",
|
||||
" display(HBox([left_column, right_column, checks]))\n",
|
||||
" \n",
|
||||
" \n",
|
||||
" \n",
|
||||
" \n",
|
||||
" \n",
|
||||
" if method == 'iterative':\n",
|
||||
" \n",
|
||||
" checks = widgets.VBox([widgets.Label('Final checks'),check1, check2, check3,electron_dose,focusdepth, acquisition_time]) \n",
|
||||
" checks.layout = widgets.Layout(border='dashed 1px gray',margin='30px 5px 5px 5px', padding='10px 10px 10px 10px')\n",
|
||||
" checks = VBox([Label('Final checks'),check1, check2, check3,electron_dose,focusdepth, acquisition_time]) \n",
|
||||
" checks.layout = Layout(border='dashed 1px gray',margin='30px 5px 5px 5px', padding='10px 10px 10px 10px')\n",
|
||||
" \n",
|
||||
" \n",
|
||||
" ### PROBE WINDOW ##########################################\n",
|
||||
@ -675,13 +634,13 @@
|
||||
" dictionary = {}\n",
|
||||
" tab = np.array([np.round(ptycho_pixel_size_all,2),np.round(detector_cover_all,1), np.round(detector_cover_a_all,1), np.round(max_defocus_all,1), np.array(opt.cameralengths())])\n",
|
||||
" \n",
|
||||
" align6 = dict(layout=widgets.Layout(width='50px') , style = {'description_width': '0px','button_width': \"33px\"}, disabled=True,)\n",
|
||||
" align7 = dict(layout=widgets.Layout(width='130px') , style = {'description_width': '0px','button_width': \"110px\"}, disabled=True,)\n",
|
||||
" align6 = dict(layout=Layout(width='50px') , style = {'description_width': '0px','button_width': \"33px\"}, disabled=True,)\n",
|
||||
" align7 = dict(layout=Layout(width='130px') , style = {'description_width': '0px','button_width': \"110px\"}, disabled=True,)\n",
|
||||
" 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",
|
||||
" if data[1] > 1000*math.radians(10):\n",
|
||||
" if data[1] > 1000*np.radians(10):\n",
|
||||
" button_style = 'danger' \n",
|
||||
" if data[0] > step_size_corr*10:\n",
|
||||
" button_style = 'warning'\n",
|
||||
@ -690,26 +649,26 @@
|
||||
" if data[2] < 1:\n",
|
||||
" button_style = 'warning' \n",
|
||||
" \n",
|
||||
" dictionary[i] = widgets.ToggleButtons(options=data, description='',button_style=button_style, **align6)\n",
|
||||
" dictionary[i] = ToggleButtons(options=data, description='',button_style=button_style, **align6)\n",
|
||||
" \n",
|
||||
" legend = widgets.ToggleButtons(options=['Ptycho pix. (A)','Det. cover (mrad)','Det. cover (α)', 'Max. defocus (nm)','Nominal CL (cm)'], description='',button_style='', **align7) \n",
|
||||
" cltab = widgets.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 = widgets.VBox([widgets.Label('Chose your reconstructed ptychographic pixe size, check needed defocus and set CL'), cltab])\n",
|
||||
" cltab.layout = widgets.Layout(border='solid 0px gray',margin='10px 10px 10px 10px', padding='10px 10px 10px 10px')\n",
|
||||
" legend = ToggleButtons(options=['Ptycho pix. (Å)','Det. cover (mrad)','Det. cover (α)', 'Max. defocus (nm)','Nominal CL (cm)'], description='',button_style='', **align7) \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",
|
||||
" \n",
|
||||
" \n",
|
||||
" \n",
|
||||
" ### SHOWING ###\n",
|
||||
" sample_overlap = widgets.HBox([go.FigureWidget(fig5), go.FigureWidget(fig7)]) \n",
|
||||
" right_column = widgets.VBox([go.FigureWidget(fig), sample_overlap, cltab ]) \n",
|
||||
" left_column = widgets.VBox([go.FigureWidget(fig8), go.FigureWidget(fig6)]) \n",
|
||||
" sample_overlap = HBox([go.FigureWidget(fig5), go.FigureWidget(fig7)]) \n",
|
||||
" right_column = VBox([go.FigureWidget(fig), sample_overlap, cltab ]) \n",
|
||||
" left_column = VBox([go.FigureWidget(fig8), go.FigureWidget(fig6)]) \n",
|
||||
" \n",
|
||||
" display(widgets.HBox([left_column, right_column, checks]))\n",
|
||||
" display(HBox([left_column, right_column, checks]))\n",
|
||||
" \n",
|
||||
" 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, \"ssb_freq_length\": ssb_freq_length, \"scans\": scans}) "
|
||||
" \"binning\": binning, \"dwell_time\": dwell_time, \"restriction\": restriction, \"method\": method, \"ctf_xaxis\": ctf_xaxis, \"scans\": scans}) "
|
||||
]
|
||||
},
|
||||
{
|
||||
@ -727,29 +686,29 @@
|
||||
"### Controls\n",
|
||||
"List of controls consists of all parameters needed for proper dataset acquisition design:\n",
|
||||
"\n",
|
||||
"| Beam | | Scanning | | Camera length | | Detection | |\n",
|
||||
"|------ | ------| ------| ------| ------| ------| ------| ------|\n",
|
||||
"| **Aperture**| probe forming aperture gives probe semi-angle (α) | **Magnification**| controls image field of view | **Nominal CL** | sample to detector distance gives maximal detected angle as well as angular sampling | **Detector** | detector used for data collection | \n",
|
||||
"| Beam | | Scanning | | Camera length | | Detection | |\n",
|
||||
"|------ | ------| ------| ------| ------| ------| ------| ------|\n",
|
||||
"| **Aperture**| probe forming aperture gives probe semi-angle (α) | **Magnification**| controls image field of view | **Nominal CL** | sample to detector distance gives maximal detected angle as well as angular sampling | **Detector** | detector used for data collection | \n",
|
||||
"| **Energy** | energy of primary electron beam in keV ... gives final pixel size | **Matrix** | gives beam position to position distance + beam defocus = beam overlap | **Use PAAR** | Pumping Aperture Anglar Restriction, build-in aperture may limit maximal scattering angles for shortest camera lengths |**Binning** | reduction in pixel array size usually increas maximum frame rate |\n",
|
||||
"| **Probe** | probe setting together with chosen probe forming aperture give probe current| | | | | **Dwell time**|single position beam time ... check your detector characteristics |\n",
|
||||
"| **Defocus** | moves focus out of the sample plane - enlarges beam diameter | | | | | | |\n",
|
||||
"\n",
|
||||
"### Start the interactive gui by running the field\n",
|
||||
"```python\n",
|
||||
"display(widgets.HBox([controls, gui]))\n",
|
||||
"display(HBox([controls, gui]))\n",
|
||||
"```"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 201,
|
||||
"execution_count": 18,
|
||||
"id": "7937f054-fcd0-4e67-a20f-7696f5903a94",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"application/vnd.jupyter.widget-view+json": {
|
||||
"model_id": "a6b2620a5190425a830b6176ed85a285",
|
||||
"model_id": "7cc0fdb91d0d4d51a8e99fcbc45fe1ee",
|
||||
"version_major": 2,
|
||||
"version_minor": 0
|
||||
},
|
||||
@ -762,7 +721,7 @@
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"display(widgets.HBox([controls, gui]))"
|
||||
"display(HBox([controls, gui]))"
|
||||
]
|
||||
}
|
||||
],
|
||||
|
Binary file not shown.
@ -3,7 +3,7 @@
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 1,
|
||||
"id": "8f22e3c3",
|
||||
"id": "7425242d-3c91-4c1e-a424-08625a38ee7a",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
@ -13,68 +13,27 @@
|
||||
"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"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"Numpy version 1.26.1\n",
|
||||
"Matplotlib version 3.8.1\n",
|
||||
"Pandas version 2.1.2\n",
|
||||
"Ipywidgets version 7.6.5\n",
|
||||
"Plotly version 5.9.0\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"### Initial packages import ###\n",
|
||||
"import ipywidgets as widgets\n",
|
||||
"import scipy.constants as cons\n",
|
||||
"import math\n",
|
||||
"### Initial packages import ###################################################\n",
|
||||
"import numpy as np\n",
|
||||
"import pandas as pd\n",
|
||||
"import matplotlib\n",
|
||||
"import plotly.graph_objects as go\n",
|
||||
"from ipywidgets import interactive, interactive_output, interact, HBox, Layout, VBox, Label\n",
|
||||
"import copy\n",
|
||||
"import seaborn as sns\n",
|
||||
"import matplotlib.pyplot as plt\n",
|
||||
"from IPython.display import display, HTML, Markdown\n",
|
||||
"\n",
|
||||
"import plotly\n",
|
||||
"import scipy.constants as cons\n",
|
||||
"import plotly.graph_objects as go\n",
|
||||
"from copy import deepcopy\n",
|
||||
"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",
|
||||
"\n",
|
||||
"print(\"Numpy version \", np.__version__)\n",
|
||||
"print(\"Matplotlib version \", matplotlib.__version__)\n",
|
||||
"print(\"Pandas version \", pd.__version__)\n",
|
||||
"print(\"Ipywidgets version \", widgets.__version__)\n",
|
||||
"print(\"Plotly version \", plotly.__version__)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "7671c652-c4e7-4f1f-a87e-e4c67bafed51",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"Tested with packages: \\\n",
|
||||
"Numpy version 1.26.1 \\\n",
|
||||
"Matplotlib version 3.8.1 \\\n",
|
||||
"Pandas version 2.1.2 \\\n",
|
||||
"Ipywidgets version 7.6.5 \\\n",
|
||||
"Plotly version 5.9.0 "
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 170,
|
||||
"id": "7425242d-3c91-4c1e-a424-08625a38ee7a",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"### Function definitions ###\n",
|
||||
"# print(\"Numpy version \", np.__version__)\n",
|
||||
"# print(\"Pandas version \", pd.__version__)\n",
|
||||
"# print(\"Ipywidgets version \", widgets.__version__)\n",
|
||||
"# print(\"Plotly version \", plotly.__version__)\n",
|
||||
"\n",
|
||||
"calib = r'calibrations.xlsx' # Full path to the calibration file\n",
|
||||
"### Function definitions ###################################################\n",
|
||||
"\n",
|
||||
"calib = r'calibrations.xlsx' # Path to the calibration file\n",
|
||||
"\n",
|
||||
"class interaction: \n",
|
||||
" \"\"\"Loads calibration settings and ranges from .xlsx file.\n",
|
||||
@ -85,52 +44,52 @@
|
||||
" self.calib = calib\n",
|
||||
"\n",
|
||||
" def apertures(self):\n",
|
||||
" excel_data = pd.read_excel(self.calib,sheet_name='Probes')\n",
|
||||
" excel_data = read_excel(self.calib,sheet_name='Probes')\n",
|
||||
" excel_lin = list((excel_data[excel_data.Probe.isin([\"Probe\"])]))\n",
|
||||
" apertures = excel_lin[1::]\n",
|
||||
" return apertures\n",
|
||||
" \n",
|
||||
" def detectors(self):\n",
|
||||
" excel_data = pd.read_excel(self.calib,sheet_name='Detector')\n",
|
||||
" excel_data = read_excel(self.calib,sheet_name='Detector')\n",
|
||||
" excel_lin = list((excel_data[excel_data.Type.isin([\"Type\"])]))\n",
|
||||
" detectors = excel_lin[1::]\n",
|
||||
" return detectors\n",
|
||||
" \n",
|
||||
" def probes(self):\n",
|
||||
" probes = list(pd.read_excel(self.calib,sheet_name='Probes').Probe)\n",
|
||||
" probes = list(read_excel(self.calib,sheet_name='Probes').Probe)\n",
|
||||
" probes = probes[3::]\n",
|
||||
" return probes\n",
|
||||
" \n",
|
||||
" def magnifications(self):\n",
|
||||
" excel_data = pd.read_excel(self.calib,sheet_name='Ranges')\n",
|
||||
" excel_data = read_excel(self.calib,sheet_name='Ranges')\n",
|
||||
" magnifications = list(excel_data.Magnification)\n",
|
||||
" return magnifications\n",
|
||||
" \n",
|
||||
" def energies(self): \n",
|
||||
" excel_data = pd.read_excel(self.calib,sheet_name='Ranges')\n",
|
||||
" energies = [str(e) for e in list(excel_data.BeamEnergy_keV)]\n",
|
||||
" excel_data = read_excel(self.calib,sheet_name='Ranges')\n",
|
||||
" energies = [str(e) for e in list(excel_data.BeamEnergy)]\n",
|
||||
" energies = [x for x in energies if x != 'nan']\n",
|
||||
" energies = [int(float(e)) for e in energies]\n",
|
||||
" return energies\n",
|
||||
" \n",
|
||||
" def mappings(self): \n",
|
||||
" excel_data = pd.read_excel(self.calib,sheet_name='Ranges')\n",
|
||||
" excel_data = read_excel(self.calib,sheet_name='Ranges')\n",
|
||||
" mappings = [str(e) for e in list(excel_data.Mapping)]\n",
|
||||
" mappings = [x for x in mappings if x != 'nan']\n",
|
||||
" mappings = [int(float(e)) for e in mappings]\n",
|
||||
" return mappings\n",
|
||||
" \n",
|
||||
" def cameralengths(self): \n",
|
||||
" cameralengths = list(pd.read_excel(self.calib,sheet_name='Pixel').NominalCL)\n",
|
||||
" cameralengths = list(read_excel(self.calib,sheet_name='Pixel').NominalCL)\n",
|
||||
" return cameralengths\n",
|
||||
" \n",
|
||||
" def cameralengths_eff(self): \n",
|
||||
" cameralengths_eff = list(pd.read_excel(self.calib,sheet_name='Pixel').DetectorCL_cm)\n",
|
||||
" cameralengths_eff = list(read_excel(self.calib,sheet_name='Pixel').DetectorCL)\n",
|
||||
" return cameralengths_eff\n",
|
||||
"\n",
|
||||
" def dwelltimes(self): \n",
|
||||
" excel_data = pd.read_excel(self.calib,sheet_name='Ranges')\n",
|
||||
" dwelltimes = [str(e) for e in list(excel_data.DwellTime_us)]\n",
|
||||
" excel_data = read_excel(self.calib,sheet_name='Ranges')\n",
|
||||
" dwelltimes = [str(e) for e in list(excel_data.DwellTime)]\n",
|
||||
" dwelltimes = [x for x in dwelltimes if x != 'nan']\n",
|
||||
" dwelltimes = [int(float(e)) for e in dwelltimes] \n",
|
||||
" return dwelltimes \n",
|
||||
@ -158,40 +117,40 @@
|
||||
" return self.fov\n",
|
||||
" \n",
|
||||
" def get_angle(self, aperture):\n",
|
||||
" excel_data = pd.read_excel(calib, sheet_name='Probes',header=0)\n",
|
||||
" excel_line = excel_data[excel_data.Probe.isin(['ProbeSemi_angle_mrad'])]\n",
|
||||
" excel_data = read_excel(calib, sheet_name='Probes',header=0)\n",
|
||||
" excel_line = excel_data[excel_data.Probe.isin(['SemiAngle'])]\n",
|
||||
" angle = excel_line[aperture]\n",
|
||||
" self.angle = np.array(angle).item()\n",
|
||||
" return self.angle\n",
|
||||
" \n",
|
||||
" def get_angle_corr(self, aperture):\n",
|
||||
" excel_data = pd.read_excel(calib, sheet_name='Probes',header=0)\n",
|
||||
" excel_line = excel_data[excel_data.Probe.isin(['CorrectedProbeSemi_angle_mrad'])]\n",
|
||||
" excel_data = read_excel(calib, sheet_name='Probes',header=0)\n",
|
||||
" excel_line = excel_data[excel_data.Probe.isin(['SemiAngleCorr'])]\n",
|
||||
" angle_corr = excel_line[aperture]\n",
|
||||
" self.angle_corr = np.array(angle_corr).item()\n",
|
||||
" return self.angle_corr\n",
|
||||
" \n",
|
||||
" def get_current(self, probe,aperture):\n",
|
||||
" excel_data = pd.read_excel(calib, sheet_name='Probes',header=0)\n",
|
||||
" excel_data = read_excel(calib, sheet_name='Probes',header=0)\n",
|
||||
" excel_line = excel_data[excel_data.Probe.isin([probe])]\n",
|
||||
" current = excel_line[aperture]\n",
|
||||
" self.current = np.array(current).item()\n",
|
||||
" return self.current\n",
|
||||
" \n",
|
||||
" def get_currents_over_probes(self, probe):\n",
|
||||
" excel_data = pd.read_excel(calib, sheet_name='Probes',header=0)\n",
|
||||
" excel_data = read_excel(calib, sheet_name='Probes',header=0)\n",
|
||||
" currents_probes = np.array(excel_data[excel_data.Probe.isin([probe])])\n",
|
||||
" currents_probes = currents_probes[0]\n",
|
||||
" currents_probes = currents_probes[1::]\n",
|
||||
" return currents_probes\n",
|
||||
"\n",
|
||||
" def get_currents_over_apertures(self, aperture):\n",
|
||||
" excel_data = pd.read_excel(calib, sheet_name='Probes',header=0)\n",
|
||||
" excel_data = read_excel(calib, sheet_name='Probes',header=0)\n",
|
||||
" currents_apertures = np.array(list(excel_data[aperture]))\n",
|
||||
" return currents_apertures\n",
|
||||
"\n",
|
||||
" def get_pixel_angle(self, cl, camera, binning):\n",
|
||||
" excel_data = pd.read_excel(calib,sheet_name='Pixel',header=0)\n",
|
||||
" excel_data = read_excel(calib,sheet_name='Pixel',header=0)\n",
|
||||
" excel_line = excel_data[excel_data.NominalCL.isin([cl])]\n",
|
||||
" pixel_angle = excel_line[camera]\n",
|
||||
" pixel_angle = np.array(pixel_angle).item()\n",
|
||||
@ -199,9 +158,9 @@
|
||||
" return self.pixel_angle\n",
|
||||
" \n",
|
||||
" def get_cl_detector(self,cl):\n",
|
||||
" excel_data = pd.read_excel(calib,sheet_name='Pixel')\n",
|
||||
" excel_data = read_excel(calib,sheet_name='Pixel')\n",
|
||||
" excel_line = excel_data[excel_data.NominalCL.isin([cl])]\n",
|
||||
" self.cl_detector = excel_line['DetectorCL_cm']\n",
|
||||
" self.cl_detector = excel_line['DetectorCL']\n",
|
||||
" self.cl_detector = self.cl_detector.item()\n",
|
||||
" return self.cl_detector\n",
|
||||
" \n",
|
||||
@ -214,54 +173,54 @@
|
||||
" return self.step_size \n",
|
||||
" \n",
|
||||
" def get_step_correction(self): \n",
|
||||
" step_correction = [str(e) for e in list(pd.read_excel(calib,sheet_name='Ranges').Step_size_correction)]\n",
|
||||
" step_correction = [str(e) for e in list(read_excel(calib,sheet_name='Ranges').StepSizeCorr)]\n",
|
||||
" step_correction = np.array([x for x in step_correction if x != 'nan']).astype(float)\n",
|
||||
" self.step_correction = step_correction.item()\n",
|
||||
" return self.step_correction\n",
|
||||
" \n",
|
||||
" def get_beam_diameter(self, aperture, defocus):\n",
|
||||
" excel_data = pd.read_excel(calib, sheet_name='Probes')\n",
|
||||
" excel_line = excel_data[excel_data.Probe.isin(['0_defocus_beam_diameter_nm'])]\n",
|
||||
" excel_data = read_excel(calib, sheet_name='Probes')\n",
|
||||
" excel_line = excel_data[excel_data.Probe.isin(['Def0Diameter'])]\n",
|
||||
" beam_0_diameter = np.array([excel_line[aperture]]).astype(float)\n",
|
||||
" beam_0_diameter = beam_0_diameter.item()\n",
|
||||
" self.beam_diameter = defocus*2*np.tan(self.angle_corr/1000)+beam_0_diameter\n",
|
||||
" return self.beam_diameter\n",
|
||||
" \n",
|
||||
" def get_0beam_diameter(self, aperture):\n",
|
||||
" excel_data = pd.read_excel(calib, sheet_name='Probes')\n",
|
||||
" excel_line = excel_data[excel_data.Probe.isin(['0_defocus_beam_diameter_nm'])]\n",
|
||||
" excel_data = read_excel(calib, sheet_name='Probes')\n",
|
||||
" excel_line = excel_data[excel_data.Probe.isin(['Def0Diameter'])]\n",
|
||||
" beam_0_diameter = np.array([excel_line[aperture]]).astype(float)\n",
|
||||
" self.beam_0_diameter = beam_0_diameter.item()\n",
|
||||
" return self.beam_0_diameter\n",
|
||||
" \n",
|
||||
" def get_detector(self, camera, binning):\n",
|
||||
" excel_data = pd.read_excel(calib, sheet_name='Detector')\n",
|
||||
" excel_line = excel_data[excel_data.Type.isin(['Pixels'])]\n",
|
||||
" excel_data = read_excel(calib, sheet_name='Detector')\n",
|
||||
" excel_line = excel_data[excel_data.Type.isin(['Array'])]\n",
|
||||
" num_pixels = np.array([excel_line[camera]]).astype(float)\n",
|
||||
" num_pixels = num_pixels.item()\n",
|
||||
" self.num_pixels = num_pixels/binning\n",
|
||||
" excel_line = excel_data[excel_data.Type.isin(['Real_size'])]\n",
|
||||
" excel_line = excel_data[excel_data.Type.isin(['RealSize'])]\n",
|
||||
" size_pixel = excel_line[camera]\n",
|
||||
" size_pixel = size_pixel.item()\n",
|
||||
" self.size_pixel = size_pixel*binning\n",
|
||||
" return self.num_pixels, self.size_pixel \n",
|
||||
" \n",
|
||||
" def get_det_resolution(self, camera):\n",
|
||||
" excel_data = pd.read_excel(calib, sheet_name='Detector')\n",
|
||||
" excel_line = excel_data[excel_data.Type.isin(['Pixels'])]\n",
|
||||
" excel_data = read_excel(calib, sheet_name='Detector')\n",
|
||||
" excel_line = excel_data[excel_data.Type.isin(['Array'])]\n",
|
||||
" num_pixels = np.array([excel_line[camera]]).astype(float)\n",
|
||||
" self.num_pixels = num_pixels.item()\n",
|
||||
" return self.num_pixels\n",
|
||||
" \n",
|
||||
" def get_det_orig_pixel_size(self, camera):\n",
|
||||
" excel_data = pd.read_excel(calib, sheet_name='Detector')\n",
|
||||
" excel_line = excel_data[excel_data.Type.isin(['Real_size'])]\n",
|
||||
" excel_data = read_excel(calib, sheet_name='Detector')\n",
|
||||
" excel_line = excel_data[excel_data.Type.isin(['RealSize'])]\n",
|
||||
" orig_size_pixel = excel_line[camera]\n",
|
||||
" self.orig_size_pixel = orig_size_pixel.item()\n",
|
||||
" return self.orig_size_pixel\n",
|
||||
" \n",
|
||||
" def get_pixel_covers(self,camera, binning): \n",
|
||||
" excel_data = pd.read_excel(calib, sheet_name='Pixel')\n",
|
||||
" excel_data = read_excel(calib, sheet_name='Pixel')\n",
|
||||
" pixel_covers = list(excel_data[camera])\n",
|
||||
" pixel_covers = [str(e) for e in pixel_covers]\n",
|
||||
" pixel_covers = [x for x in pixel_covers if x != 'nan']\n",
|
||||
@ -271,8 +230,8 @@
|
||||
" return self.pixel_covers\n",
|
||||
"\n",
|
||||
" def get_pumping_apertures(self): \n",
|
||||
" excel_data = pd.read_excel(calib,sheet_name='Pixel')\n",
|
||||
" pump_apert = [str(e) for e in list(excel_data.Pumping_aperture_limitation_mrad)]\n",
|
||||
" excel_data = read_excel(calib,sheet_name='Pixel')\n",
|
||||
" pump_apert = [str(e) for e in list(excel_data.PAAR)]\n",
|
||||
" pump_apert = [x for x in pump_apert if x != 'nan']\n",
|
||||
" self.pump_apert = [float(e) for e in pump_apert]\n",
|
||||
" return self.pump_apert \n",
|
||||
@ -291,7 +250,7 @@
|
||||
" \n",
|
||||
" \n",
|
||||
" def cl4ssb(self, detector_cover_a_all):\n",
|
||||
" ssb_cl = copy.deepcopy(detector_cover_a_all)\n",
|
||||
" ssb_cl = deepcopy(detector_cover_a_all)\n",
|
||||
" ssb_cl[ssb_cl<1] = \"nan\"\n",
|
||||
" ssb_cl = np.nanmin(ssb_cl)\n",
|
||||
" kde = np.array(np.where(ssb_cl == detector_cover_a_all)).item()\n",
|
||||
@ -304,7 +263,7 @@
|
||||
"pty = ptychoScopy() \n",
|
||||
" \n",
|
||||
"class interaction:\n",
|
||||
" \"\"\"Live interaction with parameter computing.\"\"\"\n",
|
||||
" \"\"\"Live interaction with computing of various parameters.\"\"\"\n",
|
||||
" \n",
|
||||
" def __init__(self):\n",
|
||||
" self.calib = calib\n",
|
||||
@ -331,82 +290,83 @@
|
||||
" return aperture_res2.value\n",
|
||||
" \n",
|
||||
" def show_fov(self,caller):\n",
|
||||
" fov_res.value = f'Field of view (nm) {pty.get_fov(caller.new) }'\n",
|
||||
" fov_res.value = f'Field of view (nm) {\"{:.2f}\".format(pty.get_fov(caller.new))}'\n",
|
||||
" return fov_res.value\n",
|
||||
" \n",
|
||||
" def show_frame_rate(self,caller):\n",
|
||||
" dwell_time_res.value = f'Frame rate (kHz) {pty.get_aq_frec(caller.new)}' \n",
|
||||
" dwell_time_res.value = f'Frame rate (kHz) {\"{:.2f}\".format(pty.get_aq_frec(caller.new))}' \n",
|
||||
" return dwell_time_res.value\n",
|
||||
" \n",
|
||||
" def show_cd_det(self,caller):\n",
|
||||
" cl_det_res.value = f'Detector CL (cm) {pty.get_cl_detector(caller.new)}' \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",
|
||||
" \n",
|
||||
"inte = interaction() \n",
|
||||
"\n"
|
||||
"inte = interaction() \n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 200,
|
||||
"execution_count": 17,
|
||||
"id": "8055b802-cf83-4250-aea9-54e3e6b73db0",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"### CONTROLS ##########################################\n",
|
||||
"align = dict(layout=widgets.Layout(width='385px') , style = {'description_width': '80px','button_width': \"35px\"}, button_style='primary',disabled=False,)\n",
|
||||
"align3 = dict(layout=widgets.Layout(width='230px') , style = {'description_width': '80px','button_width': \"35px\"}, button_style='primary', disabled=False,)\n",
|
||||
"to_right = dict(layout=widgets.Layout(display=\"flex\", justify_content=\"flex-end\", width=\"95%\", ))\n",
|
||||
"to_right2 = dict(layout=widgets.Layout(display=\"flex\", justify_content=\"flex-end\", width=\"35%\", ))\n",
|
||||
"align = dict(layout=Layout(width='385px') , style = {'description_width': '80px','button_width': \"35px\"}, button_style='primary',disabled=False,)\n",
|
||||
"align3 = dict(layout=Layout(width='230px') , style = {'description_width': '80px','button_width': \"35px\"}, button_style='primary', disabled=False,)\n",
|
||||
"to_right = dict(layout=Layout(display=\"flex\", justify_content=\"flex-end\", width=\"95%\", ))\n",
|
||||
"to_right2 = dict(layout=Layout(display=\"flex\", justify_content=\"flex-end\", width=\"35%\", ))\n",
|
||||
"\n",
|
||||
"### Main controls ###\n",
|
||||
"beam = widgets.Dropdown(options=opt.energies(),value=200,description='Energy (keV)', **align3)\n",
|
||||
"aperture = widgets.ToggleButtons(options=opt.apertures(), value='30um', description='Aperture', **align, tooltips=['', ''])\n",
|
||||
"probe = widgets.ToggleButtons(options=opt.probes(), value='8C', description='Probe', **align, tooltips=['', ''])\n",
|
||||
"defocus = widgets.IntSlider(description='Defocus (nm)', value=0, min=0, max=1000, step=1, continuous_update=False, **align )\n",
|
||||
"beam = Dropdown(options=opt.energies(),value=200,description='Energy (keV)', **align3)\n",
|
||||
"aperture = ToggleButtons(options=opt.apertures(), value='30um', description='Aperture', **align, tooltips=['', ''])\n",
|
||||
"probe = ToggleButtons(options=opt.probes(), value='8C', description='Probe', **align, tooltips=['', ''])\n",
|
||||
"defocus = IntSlider(description='Defocus (nm)', value=0, min=0, max=1000, step=1, continuous_update=False, **align )\n",
|
||||
"defocus.style.handle_color = 'blue'\n",
|
||||
"mag = widgets.ToggleButtons(options=opt.magnifications(),value=3,description='Mag. (Mx)', **align) \n",
|
||||
"matrix = widgets.ToggleButtons(options=opt.mappings(), value=2048, description='Matrix', **align, tooltips=['', ''])\n",
|
||||
"cl = widgets.ToggleButtons(options=opt.cameralengths(), value=12, description='Nominal (cm)', **align, tooltips=['', ''])\n",
|
||||
"camera = widgets.Dropdown(options=opt.detectors(), description='Detector', **align3, tooltips=['', ''])\n",
|
||||
"restriction = widgets.ToggleButtons(options=[('NO',False), ('YES',True)], description='Use PAAR',**align3, tooltips=['', ''])\n",
|
||||
"binning = widgets.ToggleButtons(options=[('NO',1), ('2×2',2), ('4×4',4),('6×6',6),('8×8',8)], description='Binning', **align, tooltips=['Full detector resolution', 'Binning 2x2 - detector resolution /2, pixel size *2', 'Binning 4x4'])\n",
|
||||
"dwell_time = widgets.ToggleButtons(options=opt.dwelltimes(), value=10, description='Dwell time (μs)', **align, tooltips=['', ''])\n",
|
||||
"mag = ToggleButtons(options=opt.magnifications(),value=3,description='Mag. (Mx)', **align) \n",
|
||||
"matrix = ToggleButtons(options=opt.mappings(), value=2048, description='Matrix', **align, tooltips=['', ''])\n",
|
||||
"cl = ToggleButtons(options=opt.cameralengths(), value=12, description='Nominal (cm)', **align, tooltips=['', ''])\n",
|
||||
"camera = Dropdown(options=opt.detectors(), description='Detector', **align3, tooltips=['', ''])\n",
|
||||
"restriction = ToggleButtons(options=[('NO',False), ('YES',True)], description='Use PAAR',**align3, tooltips=['', ''])\n",
|
||||
"binning = ToggleButtons(options=[('NO',1), ('2×2',2), ('4×4',4),('6×6',6),('8×8',8)], description='Binning', **align, tooltips=['Full detector resolution', 'Binning 2x2 - detector resolution /2, pixel size *2', 'Binning 4x4'])\n",
|
||||
"dwell_time = ToggleButtons(options=opt.dwelltimes(), value=10, description='Dwell time (μs)', **align, tooltips=['', ''])\n",
|
||||
"\n",
|
||||
"### Small controls ###\n",
|
||||
"align2 = dict(layout=widgets.Layout(width='200px') , style = {'description_width': '100px','button_width': '50px'}, disabled=False,)\n",
|
||||
"method = widgets.ToggleButtons(options=[('Direct','direct'), ('Iterative','iterative')], description='Methods', **align2, button_style='', tooltips=['SSB', 'PIE, MLc, DM'])\n",
|
||||
"ssb_freq_length = widgets.RadioButtons(options=['mrad', 'A'], description='CTF-SSB x-axis:', **align2) \n",
|
||||
"scans = widgets.RadioButtons(options=[4,6,8,10],description='Scan points:',continuous_update=False, **align2)\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",
|
||||
"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",
|
||||
"\n",
|
||||
"### Live update ### \n",
|
||||
"beam_res = widgets.Label(value = f'Wavelength (pm) '+ str(\"{:.2f}\".format(pty.get_wavelength(beam.value)*1e12)), **to_right2)\n",
|
||||
"beam_res = Label(value = f'Wavelength (pm) '+ str(\"{:.2f}\".format(pty.get_wavelength(beam.value)*1e12)), **to_right2)\n",
|
||||
"beam.observe(inte.show_wavelength, names='value')\n",
|
||||
"camera_res = widgets.Label(value = f'Full pixel array '+ str(\"{:.0f}\".format(pty.get_det_resolution(camera.value))), **to_right2)\n",
|
||||
"camera_res = Label(value = f'Full pixel array '+ str(\"{:.0f}\".format(pty.get_det_resolution(camera.value))), **to_right2)\n",
|
||||
"camera.observe(inte.show_detector, names='value')\n",
|
||||
"pixel_size_res = widgets.Label(value = f'Native pixel size (μm) '+ str(\"{:.0f}\".format(pty.get_det_orig_pixel_size(camera.value))),**to_right)\n",
|
||||
"pixel_size_res = Label(value = f'Native pixel size (μm) '+ str(\"{:.0f}\".format(pty.get_det_orig_pixel_size(camera.value))),**to_right)\n",
|
||||
"camera.observe(inte.show_pixel_size, names='value')\n",
|
||||
"aperture_res = widgets.Label(value = f'Probe semi angle (mrad) '+ str(\"{:.2f}\".format(pty.get_angle(aperture.value))), **to_right)\n",
|
||||
"aperture.observe(inte.show_probe_angle, names='value') \n",
|
||||
"aperture_res2 = widgets.Label(value = f'Corrected semi angle (mrad) '+ str(\"{:.2f}\".format(pty.get_angle_corr(aperture.value))), **to_right)\n",
|
||||
"aperture.observe(inte.show_corrprobe_angle, names='value') \n",
|
||||
"fov_res = widgets.Label(value = f'Field of view (nm) '+ str(pty.get_fov(mag.value)), **to_right)\n",
|
||||
"# aperture_res = Label(value = f'Probe semi angle (mrad) '+ str(\"{:.2f}\".format(pty.get_angle(aperture.value))), **to_right)\n",
|
||||
"# aperture.observe(inte.show_probe_angle, names='value') \n",
|
||||
"# aperture_res2 = Label(value = f'Corrected semi angle (mrad) '+ str(\"{:.2f}\".format(pty.get_angle_corr(aperture.value))), **to_right)\n",
|
||||
"# aperture.observe(inte.show_corrprobe_angle, names='value') \n",
|
||||
"fov_res = Label(value = f'Field of view (nm) '+ str(\"{:.2f}\".format(pty.get_fov(mag.value))), **to_right)\n",
|
||||
"mag.observe(inte.show_fov, names='value') \n",
|
||||
"dwell_time_res = widgets.Label(value = f'Frame rate (kHz) '+ str(pty.get_aq_frec(dwell_time.value)),**to_right)\n",
|
||||
"dwell_time_res = Label(value = f'Frame rate (kHz) '+ str(\"{:.2f}\".format(pty.get_aq_frec(dwell_time.value))),**to_right)\n",
|
||||
"dwell_time.observe(inte.show_frame_rate, names='value') \n",
|
||||
"cl_det_res = widgets.Label(value = f'Detector CL (cm) '+ str(pty.get_cl_detector(cl.value)),**to_right2)\n",
|
||||
"cl_det_res = Label(value = f'Detector CL (cm) '+ str(\"{:.1f}\".format(pty.get_cl_detector(cl.value))),**to_right2)\n",
|
||||
"cl.observe(inte.show_cd_det, names='value') \n",
|
||||
"\n",
|
||||
"box_layout = widgets.Layout(border='solid 2px #1976D2',margin='0px 0px 0px 0px', padding='5px 5px 5px 5px')\n",
|
||||
"col1 = widgets.VBox([widgets.Label('Beam'), widgets.HBox([beam ,beam_res]), aperture, probe, defocus], layout=box_layout) # aperture_res, aperture_res2,\n",
|
||||
"col2 = widgets.VBox([widgets.Label('Scanning'), mag, fov_res, matrix], layout=box_layout)\n",
|
||||
"col3 = widgets.VBox([widgets.Label('Camera length'), cl, widgets.HBox([restriction, cl_det_res])], layout=box_layout)\n",
|
||||
"col4 = widgets.VBox([widgets.Label('Detection'), widgets.HBox([camera, camera_res]), pixel_size_res, binning, dwell_time, dwell_time_res], layout=box_layout)\n",
|
||||
"### Controls layout ###\n",
|
||||
"box_layout = Layout(border='solid 2px #1976D2',margin='0px 0px 0px 0px', padding='5px 5px 5px 5px')\n",
|
||||
"col1 = VBox([Label('Beam'), HBox([beam ,beam_res]), aperture, probe, defocus], layout=box_layout) # aperture_res, aperture_res2,\n",
|
||||
"col2 = VBox([Label('Scanning'), mag, fov_res, matrix], layout=box_layout)\n",
|
||||
"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 = widgets.VBox([widgets.Label('Graph controls'),method, ssb_freq_length, scans], layout = widgets.Layout(border='dashed 0px gray',margin='32px 30px 00px 10px', padding='5px 5px 5px 5px'))\n",
|
||||
"controls = widgets.HBox([widgets.VBox([widgets.Label(''), col1, col2, col3, col4]), small_control])\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",
|
||||
"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, ssb_freq_length, scans):\n",
|
||||
"def ptycho_interact(beam, aperture, probe, cl, matrix, defocus, mag, camera, binning, dwell_time, restriction, method, ctf_xaxis, scans):\n",
|
||||
" \n",
|
||||
" ### SINGLE SETTING PARAMETERS ###\n",
|
||||
" wavelength = pty.get_wavelength(beam)*1e12\n",
|
||||
@ -456,19 +416,20 @@
|
||||
" ### PROBE ##########################################\n",
|
||||
" fig = go.Figure() \n",
|
||||
" fig.update_yaxes(title_text=\" CTF-SSB\")\n",
|
||||
" if ssb_freq_length == 'mrad': \n",
|
||||
" xx = 2*wavelength/(np.sin(semi_angle_corr*omega/1000))/100\n",
|
||||
" if ctf_xaxis == 'mrad': \n",
|
||||
" for x in apertury:\n",
|
||||
" fig.add_trace(go.Scatter(showlegend=False, x=pty.get_angle_corr(x) *omega, y=pctf, marker_color='gray', name='SSB-CTF',))\n",
|
||||
" \n",
|
||||
" fig.add_trace(go.Scatter(x=semi_angle_corr*omega, y=pctf, marker_color='red', name=str(np.round(semi_angle_corr,2))+ ' mrad',))\n",
|
||||
" fig.update_xaxes(title_text=\"Spacial frequency (mrad)\", range=[0, 60], zeroline=False)\n",
|
||||
"\n",
|
||||
" elif ssb_freq_length == 'A':\n",
|
||||
" elif ctf_xaxis == 'A':\n",
|
||||
" for x in apertury:\n",
|
||||
" d = 2*wavelength/(np.sin(pty.get_angle_corr(x)*omega/1000))/100\n",
|
||||
" fig.add_trace(go.Scatter(showlegend=False, x=d, y=pctf, marker_color='gray', name='SSB-CTF',))\n",
|
||||
" \n",
|
||||
" fig.add_trace(go.Scatter(x=2*wavelength/(np.sin(semi_angle_corr*omega/1000))/100, y=pctf, marker_color='red', name=str(np.round(semi_angle_corr,2))+ ' mrad',))\n",
|
||||
" \n",
|
||||
" fig.add_trace(go.Scatter(x=xx, y=pctf, marker_color='red', name=str(np.round(semi_angle_corr,2))+ ' mrad',))\n",
|
||||
" fig.update_xaxes(title_text=\"Real space distance (Å)\", range=[0.0001, 2.5], type=\"log\", zeroline=False)\n",
|
||||
" \n",
|
||||
" fig.update_layout(legend=dict(orientation=\"h\",yanchor=\"bottom\",y=0.75,xanchor=\"right\",x=1))\n",
|
||||
@ -489,8 +450,8 @@
|
||||
" for y in range(len(wid)): \n",
|
||||
" fig5.add_shape(type=\"circle\",xref=\"x\", yref=\"y\", opacity=0.1, fillcolor=\"#FF7F7F\",name=False, x0=wid[x]-beam_diameter/2, y0=wid[y]-beam_diameter/2, x1=wid[x]+beam_diameter/2, y1=wid[y]+beam_diameter/2, line_color=\"red\",secondary_y=False)\n",
|
||||
"\n",
|
||||
" fig5.add_trace(go.Scatter(showlegend=True, x=[-1], y=[-1],marker_size=12, marker_color='blue', name='Step '+str(np.round(step_size,3))+' nm ('+str(np.round(step_size_corr,3))+')'))\n",
|
||||
" fig5.add_trace(go.Scatter(showlegend=True, x=[-1], y=[-1],marker_size=12, marker_color='#FF7F7F', name='Beam ⌀ '+ str(np.round(beam_diameter,2))+\" nm\"))\n",
|
||||
" fig5.add_trace(go.Scatter(showlegend=True, x=[-1], y=[-1],marker_size=12, marker_color='blue', name='Step '+str(np.round(10*step_size,3))+' Å ('+str(np.round(10*step_size_corr,3))+')'))\n",
|
||||
" fig5.add_trace(go.Scatter(showlegend=True, x=[-1], y=[-1],marker_size=12, marker_color='#FF7F7F', name='Beam ⌀ '+ str(np.round(10*beam_diameter,2))+\" Å\"))\n",
|
||||
" fig5.update_layout(legend=dict(orientation=\"v\",yanchor=\"bottom\",y=0.85,xanchor=\"right\",x=0.9))\n",
|
||||
" fig5.add_trace(go.Scatter(showlegend=False, x = scans*step_size_corr*np.ones(len(yyy)), y=yyy, opacity=1,mode='markers',marker_symbol = \"triangle-down\",marker=dict(size=20, color=yyy, colorscale='rainbow_r', showscale=False)),secondary_y=True) \n",
|
||||
" \n",
|
||||
@ -594,25 +555,23 @@
|
||||
" \n",
|
||||
" \n",
|
||||
" ### FINAL CHECKS ########################################## \n",
|
||||
" align3 = dict(layout=widgets.Layout(width='200px') , style = {'description_width': '150px','button_width': \"100px\"}, disabled=True,) \n",
|
||||
" align3 = dict(layout=Layout(width='200px') , style = {'description_width': '150px','button_width': \"100px\"}, disabled=True,) \n",
|
||||
" \n",
|
||||
" check1 = widgets.Valid(value= bool(overlap > 60), description='Overlap > 60 %', **align3)\n",
|
||||
" check2 = widgets.Valid(value= bool(step_size_corr*10 > (wavelength * cl_det)/(num_pixels*size_pixel/1e6)/1e4), description='Ptycho pix < step size', **align3)\n",
|
||||
" check3 = widgets.Valid(value= bool(beam_diameter/2 < probe_window/2), description='Beam ⌀ < window/2', **align3) \n",
|
||||
" check1 = Valid(value= bool(overlap > 60), description='Overlap > 60 %', **align3)\n",
|
||||
" check2 = Valid(value= bool(step_size_corr*10 > (wavelength * cl_det)/(num_pixels*size_pixel/1e6)/1e4), description='Ptycho pix < step size', **align3)\n",
|
||||
" check3 = Valid(value= bool(beam_diameter/2 < probe_window/2), description='Beam ⌀ < window/2', **align3) \n",
|
||||
" \n",
|
||||
" electron_dose = widgets.Label(value = f'Electron dose (e/Å2) '+ str(np.round(dose,1)), **align3) \n",
|
||||
" \n",
|
||||
" acquisition_time = widgets.Label(value = f'Acquisition time (s) '+ str(np.round(matrix*matrix*dwell_time/1e6,1)), **align3) \n",
|
||||
" \n",
|
||||
" focusdepth = widgets.Label(value = f'Depth of focus (nm) '+ str(np.round(wavelength/(semi_angle_corr/1000)**2/1000,1)), **align3) \n",
|
||||
" \n",
|
||||
" \n",
|
||||
"\n",
|
||||
" electron_dose = Label(value = f'Electron dose (e/Å2) '+ str(np.round(dose,1)), **align3) \n",
|
||||
" acquisition_time = Label(value = f'Acquisition time (s) '+ str(np.round(matrix*matrix*dwell_time/1e6,1)), **align3) \n",
|
||||
" focusdepth = Label(value = f'Depth of focus (nm) '+ str(np.round(wavelength/(semi_angle_corr/1000)**2/1000,1)), **align3) \n",
|
||||
"\n",
|
||||
"\n",
|
||||
" ### METHODS ########################################## \n",
|
||||
" if method == 'direct':\n",
|
||||
" \n",
|
||||
" \n",
|
||||
" ssb_sampling = Label(value = f'Recommended sampling (Å) '+ str(np.round(xx[-1]/3,2)), **align3) \n",
|
||||
" \n",
|
||||
" ### CAMERA LENGTH GRAPH ##########################################\n",
|
||||
" fig4 = make_subplots(specs=[[{\"secondary_y\": True}]])\n",
|
||||
" fig4.add_trace(go.Scatter(showlegend=False, x=opt.cameralengths(), y=detector_cover_all, marker_color='gray'), secondary_y=False,)\n",
|
||||
@ -623,29 +582,29 @@
|
||||
" # fig4.update_layout(title={'text': \"CL to α\",'y':0.93, 'x':0.12,'xanchor': 'left','yanchor': 'top'})\n",
|
||||
" fig4.update_xaxes(title_text=\"Nominal camera length (cm)\", type=\"log\", tickvals = opt.cameralengths())\n",
|
||||
" fig4.update_layout(xaxis = dict(tickmode = 'array', tickvals = [1, num_pixels/4, num_pixels/2, 3*num_pixels/4, num_pixels]))\n",
|
||||
" fig4.update_yaxes(title_text=\" Cover angle (mrad)\", secondary_y=False)\n",
|
||||
" fig4.update_yaxes(title_text=\" Cover angle (α)\",showgrid=False, secondary_y=True)\n",
|
||||
" fig4.update_yaxes(title_text=\" Cover angle (mrad)\", range=[0, 1.1*np.max(detector_cover_all)], secondary_y=False)\n",
|
||||
" fig4.update_yaxes(title_text=\" Cover angle (α)\", range=[0, 1.1*np.max(detector_cover_a_all)], showgrid=False, secondary_y=True)\n",
|
||||
" fig4.update_layout(xaxis = dict(tickmode = 'array', tickvals = opt.cameralengths()))\n",
|
||||
" fig4.update_layout(width=800, height=225, margin =dict(l=110, r=30, t=30, b=30))\n",
|
||||
" \n",
|
||||
" \n",
|
||||
" checks = widgets.VBox([widgets.Label('Final checks'), electron_dose,focusdepth, acquisition_time]) \n",
|
||||
" checks.layout = widgets.Layout(border='dashed 1px gray',margin='30px 5px 5px 5px', padding='10px 10px 10px 10px')\n",
|
||||
" checks = VBox([Label('Final checks'), electron_dose, ssb_sampling, focusdepth, acquisition_time]) \n",
|
||||
" checks.layout = Layout(border='dashed 1px gray',margin='30px 5px 5px 5px', padding='10px 10px 10px 10px')\n",
|
||||
" \n",
|
||||
" \n",
|
||||
" ### SHOWING ###\n",
|
||||
" right_column = widgets.VBox([go.FigureWidget(fig),go.FigureWidget(fig5),go.FigureWidget(fig4)])\n",
|
||||
" left_column = widgets.VBox([go.FigureWidget(fig8), go.FigureWidget(fig6)])\n",
|
||||
" display(widgets.HBox([left_column, right_column, checks]))\n",
|
||||
" \n",
|
||||
" right_column = VBox([go.FigureWidget(fig),go.FigureWidget(fig5),go.FigureWidget(fig4)])\n",
|
||||
" left_column = VBox([go.FigureWidget(fig8), go.FigureWidget(fig6)])\n",
|
||||
" display(HBox([left_column, right_column, checks]))\n",
|
||||
" \n",
|
||||
" \n",
|
||||
" \n",
|
||||
" \n",
|
||||
" \n",
|
||||
" if method == 'iterative':\n",
|
||||
" \n",
|
||||
" checks = widgets.VBox([widgets.Label('Final checks'),check1, check2, check3,electron_dose,focusdepth, acquisition_time]) \n",
|
||||
" checks.layout = widgets.Layout(border='dashed 1px gray',margin='30px 5px 5px 5px', padding='10px 10px 10px 10px')\n",
|
||||
" checks = VBox([Label('Final checks'),check1, check2, check3,electron_dose,focusdepth, acquisition_time]) \n",
|
||||
" checks.layout = Layout(border='dashed 1px gray',margin='30px 5px 5px 5px', padding='10px 10px 10px 10px')\n",
|
||||
" \n",
|
||||
" \n",
|
||||
" ### PROBE WINDOW ##########################################\n",
|
||||
@ -675,13 +634,13 @@
|
||||
" dictionary = {}\n",
|
||||
" tab = np.array([np.round(ptycho_pixel_size_all,2),np.round(detector_cover_all,1), np.round(detector_cover_a_all,1), np.round(max_defocus_all,1), np.array(opt.cameralengths())])\n",
|
||||
" \n",
|
||||
" align6 = dict(layout=widgets.Layout(width='50px') , style = {'description_width': '0px','button_width': \"33px\"}, disabled=True,)\n",
|
||||
" align7 = dict(layout=widgets.Layout(width='130px') , style = {'description_width': '0px','button_width': \"110px\"}, disabled=True,)\n",
|
||||
" align6 = dict(layout=Layout(width='50px') , style = {'description_width': '0px','button_width': \"33px\"}, disabled=True,)\n",
|
||||
" align7 = dict(layout=Layout(width='130px') , style = {'description_width': '0px','button_width': \"110px\"}, disabled=True,)\n",
|
||||
" 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",
|
||||
" if data[1] > 1000*math.radians(10):\n",
|
||||
" if data[1] > 1000*np.radians(10):\n",
|
||||
" button_style = 'danger' \n",
|
||||
" if data[0] > step_size_corr*10:\n",
|
||||
" button_style = 'warning'\n",
|
||||
@ -690,26 +649,26 @@
|
||||
" if data[2] < 1:\n",
|
||||
" button_style = 'warning' \n",
|
||||
" \n",
|
||||
" dictionary[i] = widgets.ToggleButtons(options=data, description='',button_style=button_style, **align6)\n",
|
||||
" dictionary[i] = ToggleButtons(options=data, description='',button_style=button_style, **align6)\n",
|
||||
" \n",
|
||||
" legend = widgets.ToggleButtons(options=['Ptycho pix. (A)','Det. cover (mrad)','Det. cover (α)', 'Max. defocus (nm)','Nominal CL (cm)'], description='',button_style='', **align7) \n",
|
||||
" cltab = widgets.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 = widgets.VBox([widgets.Label('Chose your reconstructed ptychographic pixe size, check needed defocus and set CL'), cltab])\n",
|
||||
" cltab.layout = widgets.Layout(border='solid 0px gray',margin='10px 10px 10px 10px', padding='10px 10px 10px 10px')\n",
|
||||
" legend = ToggleButtons(options=['Ptycho pix. (Å)','Det. cover (mrad)','Det. cover (α)', 'Max. defocus (nm)','Nominal CL (cm)'], description='',button_style='', **align7) \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",
|
||||
" \n",
|
||||
" \n",
|
||||
" \n",
|
||||
" ### SHOWING ###\n",
|
||||
" sample_overlap = widgets.HBox([go.FigureWidget(fig5), go.FigureWidget(fig7)]) \n",
|
||||
" right_column = widgets.VBox([go.FigureWidget(fig), sample_overlap, cltab ]) \n",
|
||||
" left_column = widgets.VBox([go.FigureWidget(fig8), go.FigureWidget(fig6)]) \n",
|
||||
" sample_overlap = HBox([go.FigureWidget(fig5), go.FigureWidget(fig7)]) \n",
|
||||
" right_column = VBox([go.FigureWidget(fig), sample_overlap, cltab ]) \n",
|
||||
" left_column = VBox([go.FigureWidget(fig8), go.FigureWidget(fig6)]) \n",
|
||||
" \n",
|
||||
" display(widgets.HBox([left_column, right_column, checks]))\n",
|
||||
" display(HBox([left_column, right_column, checks]))\n",
|
||||
" \n",
|
||||
" 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, \"ssb_freq_length\": ssb_freq_length, \"scans\": scans}) "
|
||||
" \"binning\": binning, \"dwell_time\": dwell_time, \"restriction\": restriction, \"method\": method, \"ctf_xaxis\": ctf_xaxis, \"scans\": scans}) "
|
||||
]
|
||||
},
|
||||
{
|
||||
@ -727,29 +686,29 @@
|
||||
"### Controls\n",
|
||||
"List of controls consists of all parameters needed for proper dataset acquisition design:\n",
|
||||
"\n",
|
||||
"| Beam | | Scanning | | Camera length | | Detection | |\n",
|
||||
"|------ | ------| ------| ------| ------| ------| ------| ------|\n",
|
||||
"| **Aperture**| probe forming aperture gives probe semi-angle (α) | **Magnification**| controls image field of view | **Nominal CL** | sample to detector distance gives maximal detected angle as well as angular sampling | **Detector** | detector used for data collection | \n",
|
||||
"| Beam | | Scanning | | Camera length | | Detection | |\n",
|
||||
"|------ | ------| ------| ------| ------| ------| ------| ------|\n",
|
||||
"| **Aperture**| probe forming aperture gives probe semi-angle (α) | **Magnification**| controls image field of view | **Nominal CL** | sample to detector distance gives maximal detected angle as well as angular sampling | **Detector** | detector used for data collection | \n",
|
||||
"| **Energy** | energy of primary electron beam in keV ... gives final pixel size | **Matrix** | gives beam position to position distance + beam defocus = beam overlap | **Use PAAR** | Pumping Aperture Anglar Restriction, build-in aperture may limit maximal scattering angles for shortest camera lengths |**Binning** | reduction in pixel array size usually increas maximum frame rate |\n",
|
||||
"| **Probe** | probe setting together with chosen probe forming aperture give probe current| | | | | **Dwell time**|single position beam time ... check your detector characteristics |\n",
|
||||
"| **Defocus** | moves focus out of the sample plane - enlarges beam diameter | | | | | | |\n",
|
||||
"\n",
|
||||
"### Start the interactive gui by running the field\n",
|
||||
"```python\n",
|
||||
"display(widgets.HBox([controls, gui]))\n",
|
||||
"display(HBox([controls, gui]))\n",
|
||||
"```"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 201,
|
||||
"execution_count": 18,
|
||||
"id": "7937f054-fcd0-4e67-a20f-7696f5903a94",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"application/vnd.jupyter.widget-view+json": {
|
||||
"model_id": "a6b2620a5190425a830b6176ed85a285",
|
||||
"model_id": "7cc0fdb91d0d4d51a8e99fcbc45fe1ee",
|
||||
"version_major": 2,
|
||||
"version_minor": 0
|
||||
},
|
||||
@ -762,7 +721,7 @@
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"display(widgets.HBox([controls, gui]))"
|
||||
"display(HBox([controls, gui]))"
|
||||
]
|
||||
}
|
||||
],
|
||||
|
Reference in New Issue
Block a user