From de2a10b507a7b4fda391244910884dbfc0d2a77b Mon Sep 17 00:00:00 2001 From: Ivan Usov Date: Tue, 12 Apr 2022 16:44:47 +0200 Subject: [PATCH] Keep ang_lims as nonlocal var --- pyzebra/app/panel_ccl_prepare.py | 9 +++++++-- pyzebra/sxtal_refgen.py | 6 ++---- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/pyzebra/app/panel_ccl_prepare.py b/pyzebra/app/panel_ccl_prepare.py index 40be062..912a891 100644 --- a/pyzebra/app/panel_ccl_prepare.py +++ b/pyzebra/app/panel_ccl_prepare.py @@ -23,6 +23,7 @@ import pyzebra def create(): + ang_lims = None cif_data = None anglim_div = Div(text="Angular min/max limits:") @@ -56,8 +57,10 @@ def create(): ranges_expression.value = params["SRANG"] def open_geom_callback(_attr, _old, new): + nonlocal ang_lims with io.StringIO(base64.b64decode(new).decode()) as fileobj: - _update_ang_lims(pyzebra.read_geom_file(fileobj)) + ang_lims = pyzebra.read_geom_file(fileobj) + _update_ang_lims(ang_lims) open_geom_div = Div(text="or open GEOM:") open_geom = FileInput(accept=".geom", width=200) @@ -115,13 +118,15 @@ def create(): ranges_expression = TextInput(title="sin(​θ​)/λ", value="0.0 0.7", width=200) def geom_radiogroup_callback(_attr, _old, new): + nonlocal ang_lims if new == 0: geom_file = pyzebra.get_zebraBI_default_geom_file() else: geom_file = pyzebra.get_zebraNB_default_geom_file() cfl_file = pyzebra.get_zebra_default_cfl_file() - _update_ang_lims(pyzebra.read_geom_file(geom_file)) + ang_lims = pyzebra.read_geom_file(geom_file) + _update_ang_lims(ang_lims) _update_params(pyzebra.read_cfl_file(cfl_file)) geom_radiogroup_div = Div(text="Geometry:") diff --git a/pyzebra/sxtal_refgen.py b/pyzebra/sxtal_refgen.py index 4692eed..3e31c83 100644 --- a/pyzebra/sxtal_refgen.py +++ b/pyzebra/sxtal_refgen.py @@ -5,8 +5,7 @@ import subprocess SXTAL_REFGEN_PATH = "/afs/psi.ch/project/sinq/rhel7/bin/Sxtal_Refgen" -_zebraBI_default_geom = """! -GEOM 2 Bissecting - HiCHI +_zebraBI_default_geom = """GEOM 2 Bissecting - HiCHI BLFR z-up DIST_UNITS mm ANGL_UNITS deg @@ -26,8 +25,7 @@ ANG_LIMITS Min Max Offset DET_OFF 0 0 0 """ -_zebraNB_default_geom = """! -GEOM 3 Normal Beam +_zebraNB_default_geom = """GEOM 3 Normal Beam BLFR z-up DIST_UNITS mm ANGL_UNITS deg