|
Dispense
Navigation
Tips - Dritte
PmWiki
pmwiki.org
edit SideBar
|
< Mujpy.JupiterlabSettings | Index | Mujpy.JupyterTricks >
- wip
- introduce possibly MESA, i.e. memspectrum)
- define strategy for histo inspection
- tests for real ISIS datasets
- sort folders: handle mkdir from mujpy? in an ipyw extension? A possible path policy:
- suggest to start always from ~/mujpy and store this as self.rootpath in mudahed
- check that both pathlib objects and string paths (in widgets) are recognised
- a mkdir button navigates to/generates a project subfolders cascade (eg sample/instrument/run/wtf) in mudashed and cd to the last subfolder
- getcwd records this as startuppath and passes it to suite
- so suite generates or detects data, fit, cache, ... folders in self.startuppath
- create mudashed ipynb and run it: insert the core idea below as a method in tests.
import os
import nbformat as nbf
# insert into class ParameterizedRunner()
def test_dashed_notebook_generation(self):
"""Generate a Jupyter Notebook (.ipynb) to test the dashed interface."""
nb = nbf.v4.new_notebook()
# Cell 1: Activate QT backend for Matplotlib
code_cell_1 = "%matplotlib qt"
# Cell 2: Import and instantiate dashboard
code_cell_2 = (
"from mujpy.mudashed import dashed\n"
"dashed(test='gui')"
)
nb['cells'] = [
nbf.v4.new_code_cell(code_cell_1),
nbf.v4.new_code_cell(code_cell_2)
]
self.notebook_filename = 'Mudashed_demos.ipynb'
with open(self.notebook_filename, 'w', encoding='utf-8') as f:
nbf.write(nb, f)
# Verify that file exists
self.assertTrue(os.path.exists(self.notebook_filename))
- is this needed? It requires a
python -m mujpy/tests/mujpy_nb.py or python -c "from mujpy.tests.tests import ParameterisedRunner as PR; rnr=PR(), rnr.write_ipynb()" && jupyter notebook Mudashed_demos.ipynb instead of witing three lines in two nb cells
python -m mujpy.tests.tests test 11 has one Minuit did not converge triggering runtime warning. Make a dialog for Minuit did not converge and trap the np warning with e.g.
with np.errstate(over="ignore",divide="ignore",invalid="ignore"):
...
return chi2
in the assumption that in any case Minuit will not converge.
Then perhaps enhance Minuit did not converge message with a dialog
- win only overflows/underflows happens eg in exp(-lambda*t) when parameters go wild: do something to avoid?
overflow encountered in square normsquaredev = (num/self._e_)**2 , twice
overflow encountered in exp return A*cos(2*pi*self._gamma_Mu_MHzper_mT*B*x+φ*self._radeg_)*exp(-x*λ) , also im multipy
In itself not dangerous, handled by iminuit, see above
- standardize init_csv_row data. Only one T (allow to select which?), nominal B, nominal orient, run. Requires systematic treatment in suite of the different file header infos. Make something simple like, always use Second T if available, with error (empty if not available), a suite __init__ flag to select First T. The suite must store suite.csv_info_legend ['0.Run', '1.T[K]', '2.eT[K]', '3.B[G]', '4.Orient'], and corresponding suite.info_csv_data:w
download results from server
- try installing directly in windows. Install again python3.14 (includes pip and venv), do not install git, make a windows venv, activate and run python -m pip install --upgrade in it. Then run just jupyter lab.
- create a dowload button in the gui that offers a tick palette of folder to include, cache, fit, csv, data, ...
- offers tickbox selection of content cache fit csv to download, chat suggests
import base64
import html
from pathlib import Path
import ipywidgets as widgets
def download_link(filename):
path = Path(filename)
data = base64.b64encode(path.read_bytes()).decode("ascii")
name = html.escape(path.name, quote=True)
return widgets.HTML(
value=(
f'<a href="data:application/octet-stream;base64,{data}" '
f'download="{name}">Download {name}</a>'
)
)
- and
display(download_link("fit_results.json")) while in mudashed self.download_box = widgets.HTML() include in the gui as self.download_box.value = download_link(filename).value (conceptually the url is https://your-server/<session-prefix>/voila/files/downloads/)results.zip
- Mudashed writes results.zip into a designated server folder, say downloads/.
- displays a link to that file.
- clicking it downloads the file to the user’s computer through their browser.
- Remember, always:
- change NG>1 through add/del,
- global fit fixed: define a global parameter, fix it, equate model parameters to it.
Bugs and improvements
- create fit templates with mudashed and test them, save to tests/fit_templates/ and instruct ReadThedocs to let user download them or mudashes to upload them to fit/
- alml (TF) and almlbl (ZF) for A1.A20.B1.B20
- alml.glo and almlbl.glo for A21, B21
- alml.C1 alml.C2 almlbl.C1 almlbl.C2
- suite.histoLength =
self._the_runs_[0][0].get_histoLength_bin() - self.nt0.max() - self.offset -1.
- data load at PSI is slow also because mujpy fits prompts independently on every run and for all histos range(self.numhis); typically, gpd has 16 histograms and only 2 are used. Fit only those, at least for chek mode! Check what changing groups does!
- find ways to reset startuppath, e.g. by path, that now only accepts files
- check that alxx with al fixed and xx with same group alpha give the same results
- check that different binning give (nearly) the same chisquare: they do not.
- error around rebin?
- it rebins as an average. See Mujpy.MujpyVsMusrfitChiSquare#errors
from end August 2026
- Refurbishing fft.
- qt now raises and activates windows under X11
- sequential xxyy fit xx no al) now reads group alpha again
- cleaned up _on_Fit and _on_Plot, simplified the widgets syntax checks ✅
- added a +: = :+ method to speed up add of long lists ✅
- removed arrow from Edge combobox (globpardicts name) ✅
- checking t0 on every run of bulk musr takes 0.3 s/run, non-negligible, but useful to spot automatically time base changes. The fix is to autodetect run addition and removal, dealt by suite.append_runs and pop_runs ✅
- fixed a subtle bug in background subtraction, that affected gpd visibly, and disrupted its global C2 fits ✅
- new +- drop now works, bug fixed ✅
- more consistent checks on ranges with tools.derange, that returns a list of integers and an error message (empty == success) ✅
- restored the rotating frame plot of a time-domsim fit, obtained with an scipy.special.erf low pass filter at cutuff 1.2*f0 and stf 0.1*f0 ✅
- Fixed MusrRoot with uproot to read all root files as of 2026 ✅
- added autolink to /psi.ch/ nsf service, if it exists (i.e. if inside), takes long time to load the list when clicked, be patient ✅
- installed at psi, tunnelled to outside browser and run from outside, see Mujpy.PackageMaintenance ✅
- inserted choice of scan order, Run, T, B or Orient ✅
- intercept change of timebase in run list, keep it up to the change run. Check nt0 in every run (promptfit check= True mode, checks only, does not overwrite self.nt0 etc.) ✅
- initiate a self.grouppath in mudashed, copy standard groups there from mujpy.tests ✅
- set a strategy for csv headers, only one T (sample, check with nxs!), with eT at PSI, include orientation (all facilities). ✅
- fixed add for ambiguous component ✅
- fixed acronym editing (chatGPT changed use of dialogs with def finished to guarantee correct readout of widgets for radio and yes_no) ✅
- fetch data creates data if it does not exist yet, before uploading. ✅
- 6/10/26 committed a version, tested on dell wsl works. fixed editor switching bugs, now the editor works in all tested instances. Can start from scratch all fits, delete global parameters, delete add one model component at a time, switch from sequential to global and viceversa. ✅
- raasonably ** complete documentation **
- debugged wsl win version, using Jupyterlab 7 with subshells, coming soon to linux see jupyterlab.Settings?. Breaks Qt, ealt by QtDispatcher class in tools, mudashed has distinct drawing calls for Qt and ipympl. ✅
- made dialog render multiline '\n' messages ✅
- solved other small bugs, v3.1.4
- published v3.1 on PyPI, see PackageMaintenance ✅
- substituted all tk dialogs with Gemini co-brewed ipyw_path_file_dial+ ValueButton+Dialog tab ✅
- employs display toggling between 'flex' and 'none' to emulate (functionally) popup and single click selection for fastest turnout ✅
- new tests, updated Installation, Tutorial e README ✅
- json very weak against manual manipulation! mudashed checks syntax is right comparing to small list of allowed keys.✅ Does not check their values or the global model feasibility. ❌
- Global model logic checks that: ✅
- all model parameter flags are "=",
- all indices k <= len(globpardicts) are referenced in model functions,
- models with hashes in globpardicts flags and len(groupings)>1 have at least one ";" in model function texts (is this right?)
- if _C1() & len(self.grouping)>1 or suite.nruns==1 raises not a C1
- if _C2() & len(self.grouping)>1 and suite.nruns==1 raises not a C2
- if _AB21 and len(suite.goruping==1)/_ raises not A21 or B21
- data fit and groups by importlib.resources ✅
- remove sidecar ✅
- use font Inter< guaranteed uniform across os'es, must load it and invoke in a css (see css_widget)✅
- fixed _add_del_plot .unobserve and .observe with self._pardicts_observer to pass the index kp ✅
- update command_box, modify an already edited model, add a drop-down to each global parameter widget list with delete/insert/subplot axis, and following modify acronym, ✅
- when model is already displayed, if new acronym adds a component, append an empty one; if it removes one, pop it; for more complex moves offer to start afresh.
- if complex, return empty component and 0, then confirm that the new model will be started afresh, otherwise abort, so return
- if add return component to add and position, then obtain the old model list, insert the component in that position with empty parameters and rebuild the dash
- if remove return component to remove and negative of position, then obtain the old model lists, pop the component and rebuild the dash
- suite_box: extend list and groups after first use works fine, popup must press RL, obnoxious, removed ❌
- tk_error obeys geometry at all calls (tk_error and file_dialog). Important: always add the kwarg root=self.root from mudashed! ✅
- checks coherence of global fits with groups and run list, issues warnings by tk_error, ✅
- fix sphinx-ext-autodoc, update Source (mostly checked) ✅
- made mudashed more pythonic: observe and on_click callbacks become private methods
_on_xx(self,change):
- tag v3.1 on 8 September 26 ✅
- local
pip install . works ✅
- standard groups in mudashed by LG load, ✅
- all messages by tkinter pop up at +400+10 [px] on the screen done, ✅
- tabs: help with function list and initial suggestions, log (comes to focus after fit, substitutes sidecar, mudashed(self,...,sidecar=False) ), about with logo ✅
- renew tests for mudashed(test=None,'gps','lem', 'musr'), ✅
- direct access to PSI data (|vpn + proxy + script), ISIS data, ✅
from May 2026
- v 3.0 ReadTheDocs build after every new version. ✅
- more sensible versioning, see https://packaging.python.org/en/latest/tutorials/packaging-projects/, ✅
- uses
git describe, relies on git tag -a vN.M before git commit -m "description", now works ✅
- set up voila for standalone use (does not need jupiterlab)✅
- use
%matplotlib qt for pop up figure window ✅
- add sidecar to mudashed and direct log to second jupyterlab tab to the right, ❌ removed after putting log in Log tab ✅
- finalize muroot2py in musuite, with one further stantalone test (almg.3561. ... .py) ✅
- remove deprecated methods ✅
- create new mudashed.py class for the GUI
- create test.py and its individual 16 tests, run by hand ...
- upgrade mufitplot to use consistently mucomponents methods for slicing musuite
- mufit uses only in two flavours: sequential (A1, A20, B1, B20) and global (A21, B21, C1, C2). Hash flag to identify the latter two.
- insert slice in musuite to construct asymmetry slices
- standardize
mufit using explicitly self.A1() ... self.C2_calib() identification
- only
dofit_ and dofit_calib_ in the end
- general
execute_log_save_fit
mucomponents stores suite instance
- only
_load_ and _load_calib_ methods switchyards
_reload_ and _reload_calib_ to redefine ranges for plotting purposes
- sequential fits also need reloading
asymm and asyme for different groups/runs: _asymmetry_single calculates asymmetry on a slice and _asymmetry_multirun_multigroup either passes it on (1d) or vstacks a 2d/3d array. This must be selectable from mufit to handle sequential fits in execute_log_save_fit
- lacking an automated mechanism
mufit uses a mucomponents method to set the slice indices for _asymmetry_multirun_multigroup?
from Jan 2025 towards version 3.0.0'
- created muroot2py, based on uproot, mimicking basic methods of MuSR_td_PSI_bin.cpp
- created muisis2py anew, based on nexusformat.nexus, mimicking MuSR_td_PSI_bin.cpp
- redesigned musuite.single_multigroup_for_back_counts which is the building block of asymmetry generation
- fixed several bugs
- tested fits A1, A20, A1_calib, A20_calib, A21_calib
< Mujpy.JupiterlabSettings | Index | Mujpy.JupyterTricks >
|