dfujim / bfit Goto Github PK
View Code? Open in Web Editor NEWA Python application for the analysis of β-NMR and β-NQR data taken at TRIUMF.
Home Page: https://pypi.org/project/bfit/
License: GNU General Public License v3.0
A Python application for the analysis of β-NMR and β-NQR data taken at TRIUMF.
Home Page: https://pypi.org/project/bfit/
License: GNU General Public License v3.0
Good to know how far things got.
In parameter draw plot, allow mouseover to show info (if no annotation) and on click draw in new window the data and fit line. This will require a new class in the backend similar to the FunctionPlacer.
To ease switching fitting between data sets. Also, have force check state on by default.
the fit ignores removing bad bins (no change in fit when bad bins are
removed, and the spectra visible changes after bin removal and clearly
mismatches the fit)
Internal labelling by run only causes the issue of being unable to re-fetch a run from a different year, especially if it was selected accidentally.
Rather than have each line have it's own frame, if you grid to the containing frame, it may align things better.
Or just find a way to make the line frames align.
In the current version of bfit on muesli the fit button in the Fetch Data tab does not appear to be working.
Not showing
Allow for annotation using this module.
Under the Fetch Data tab it shows a list of runs with the year, run number, temperature, magnetic field, implantation bias, etc. I am currently working on some low field data and the magnetic field is automatically converted from Gauss to Tesla. That is great, but my data at 150 G is showing up as 0.02 T. I think you need to increase the significant figures or change the way it is shown.
Input a switch to change between simple run list input and coded input in file fetcher.
Coded input idea:
Could be useful for getting every other file, or all but one. Run numbers would have to be fetched from file names in year directory.
Examples:
45010 < r
(get latest files)(40001 <= r < 40100) and r not in [40010] and r%10 == 0
(get every 10th but not 40010)When appended to lambda r :
would return true if we should draw it
Behaviour should be as follows:
Upon checking periodic redraw, the next draw (the one associated with the periodicity) should assign a figure number. This figure is then selected on every redraw, and then the focus should be passed back to whatever figure the use was looking at.
Allow for file fetch to combine checked runs by taking weighted mean
Display this somewhere
Need improvement in tracking which data has been taken, what has been fitted. Stores fitdata objects.
Can do this either in bfit object or new external object.
This evening we noticed while switching between 1f and 1w runs that if a 1f run was acquired before the 1w run, then the 1w run will not plot while the data is acquiring. However, it can be plotted just fine once the data acquisition is finalized. The runs I noticed this on were: 2019: 40193.
Drawing runs with the same label (ex: temperature) will remove previous runs with the same label.
Completely separate.
Make a link to this site: http://musr.ca/mud/runSel.html
Have the titles of the runs reflect the labels. Could do something like
[ run number -- label ]
if label != run
Should add proper logging, limiting filesize. Specify location on desktop to put files such as these (ex: ~/.bfit/).
The fit parameter selection goes back to the first entry when the input fields are highlighted.
Seems to reselect combobox for some reason
2019-02-22 18:49:44,963 DEBUG fit_files_tab.get_selected_run() [1052] -- Selected combobx[1] (run 40178)
2019-02-22 18:49:45,660 DEBUG fit_files_tab.set_display() [1160] -- Setting display for run 40178
2019-02-22 18:49:45,661 DEBUG fit_files_tab.get_selected_run() [1052] -- Selected combobx[0] (run 40173)
In fit data tab. No reason for this to not take the whole screen. Make sure grid resizing still works.
Make multiple windows? Multiple sub plots?
Issue #11 added graphical setting of P0. Setting new lines means altering the amplitudes of the old lines already set. This should not happen. Users specify peak height. This value should be fixed, regardless of other components set.
Have you considered implementing the ability to fit a part of the time range?
For example, sometimes I look at the first second of the data to get a good estimate of the initial asymmetry. I will do this specially if I am looking at a sample with a potential missing fraction.
Fit parameters should be able to set via graphical interface. (i.e. select peak and width or lor fits). Needed mostly for 1f
Removing data sometimes leaves remnants of data untracked (fit page doesn't load run, thinks there's a run with blank mode, etc).
Possibly when there's an error elsewhere?
Fitting function resets on file fetch, annoying when fitting a different set of files
Fit parameters which are set by the user are reset after file fetch. Do not change for non-fetched files.
After 18h usage, shows large (50%) usage of RAM
Especially when fetching a large number of files. This needs to be sped up.
Current function: update on next button press. New function: update on user input.
Limit the number of entry boxes and linked parameters. Just save values in fitdata objects.
Also have group parameters checkbox true by default.
For easier input
Set a function whose parameters, based on file meta data (temp, field, etc) set the function inputs (T1, beta, amp, etc). Fitting then optimizes the parameters of this function. Enables fitting to a Korringa law, for example.
Mouse wheel does not scroll file list in fetch data tab.
Make a link to the issue page of this github.
Add to help menu.
In fetch data tab, make checkboxes for fit/data on each data line. Combine "Draw" and "Draw Fit" buttons into single "Draw" button. Draw then draws the checked options. Have both set to true by default. If no fit, then don't draw that.
Need to modify draw_all to match.
For newly fetched runs. Same with rebin options
The following sequence produces an error, where the rebin for the first run gets set to zero.
Log output:
2019-03-12 20:27:38,828 INFO bfit.__init__() [157] -- Initializing --------------------------------------------------
2019-03-12 20:27:39,166 DEBUG fileviewer_tab.__init__() [71] -- Initializing
2019-03-12 20:27:39,181 DEBUG bfit.get_latest_year() [850] -- Latest year with data: 2018 (NMR: True, NQR: True)
2019-03-12 20:27:39,217 DEBUG fileviewer_tab.__init__() [175] -- Initialization success.
2019-03-12 20:27:39,218 DEBUG fetch_files_tab.__init__() [66] -- Initializing
2019-03-12 20:27:39,228 DEBUG bfit.get_latest_year() [850] -- Latest year with data: 2018 (NMR: True, NQR: True)
2019-03-12 20:27:39,295 DEBUG fetch_files_tab.__init__() [259] -- Initialization success.
2019-03-12 20:27:39,295 DEBUG fit_files_tab.__init__() [57] -- Initializing
2019-03-12 20:27:39,362 DEBUG bfit.__init__() [326] -- Initialization success. Starting mainloop.
2019-03-12 20:27:39,374 DEBUG bfit.set_tab_change() [1030] -- Changing to tab 0
2019-03-12 20:27:42,670 DEBUG bfit.set_tab_change() [1030] -- Changing to tab 1
2019-03-12 20:27:44,770 DEBUG bfit.return_binder() [880] -- Calling return key command for notebook index 1
2019-03-12 20:27:44,772 DEBUG fetch_files_tab.return_binder() [480] -- Focus is: run or year entry
2019-03-12 20:27:44,772 DEBUG fetch_files_tab.get_data() [375] -- Fetching runs
2019-03-12 20:27:44,772 DEBUG fetch_files_tab.string2run() [543] -- Parsed "40123" to run numbers (len: 1) [40123]
2019-03-12 20:27:44,781 DEBUG fitdata.__init__() [56] -- Initializing run 40123 (2018).
2019-03-12 20:27:44,781 DEBUG fetch_files_tab.get_data() [422] -- Fetching runs of mode 20
2019-03-12 20:27:44,787 DEBUG bfit.set_asym_calc_mode_box() [1057] -- Setting fileviewer asym combobox values for mode "20"
2019-03-12 20:27:44,789 DEBUG fetch_files_tab.__init__() [596] -- Initializing run 40123 (2018)
2019-03-12 20:27:44,825 DEBUG bfit.get_label() [794] -- Fetching plot label for "Run Number"
2019-03-12 20:27:44,827 DEBUG fit_files_tab.populate() [211] -- Populating data. Groups: [1]
2019-03-12 20:27:44,828 DEBUG fit_files_tab.populate_param() [278] -- Populating fit parameters
2019-03-12 20:27:44,828 DEBUG fit_files_tab.__init__() [942] -- Initalizing fit tab group 1
2019-03-12 20:27:44,829 DEBUG fit_files_tab.create() [955] -- Creating graphics for fit input group 1
2019-03-12 20:27:44,842 DEBUG fit_files_tab.populate_param() [278] -- Populating fit parameters
2019-03-12 20:27:44,842 DEBUG fit_files_tab.get_new_parameters() [1024] -- Fetching new parameters
2019-03-12 20:27:44,843 DEBUG fitdata.set_fitpar() [135] -- Fit parameters set to {'p0': {'amp': 0.07277506954176316, '1/T1': 0.8474576271186439, 'baseline': 0.004470859270959627, 'beta': 0.5}, 'blo': {'amp': 0, '1/T1': 0, 'baseline': -inf, 'beta': 0}, 'bhi': {'amp': inf, '1/T1': inf, 'baseline': inf, 'beta': 1}, 'res': {}, 'dres': {}, 'chi': {}, 'fixed': {}, 'shared': {}}
2019-03-12 20:27:44,844 DEBUG fit_files_tab.populate_param() [1074] -- Populating parameter list with ('1/T1', 'amp', 'baseline')
2019-03-12 20:27:44,845 DEBUG fit_files_tab.get_selected_run() [1054] -- Selected combobx[0] (run 40123)
2019-03-12 20:27:44,848 DEBUG fit_files_tab.set_display() [1162] -- Setting display for run 40123
2019-03-12 20:27:44,848 DEBUG fit_files_tab.get_selected_run() [1054] -- Selected combobx[0] (run 40123)
2019-03-12 20:27:44,850 INFO fetch_files_tab.get_data() [457] -- Fetched runs [40123]
2019-03-12 20:27:46,527 DEBUG bfit.set_tab_change() [1030] -- Changing to tab 2
2019-03-12 20:27:46,527 DEBUG fit_files_tab.populate() [211] -- Populating data. Groups: [1]
2019-03-12 20:27:46,528 DEBUG fit_files_tab.update() [1280] -- Updating fit tab for group 1
2019-03-12 20:27:46,528 DEBUG fit_files_tab.set_display() [1162] -- Setting display for run 40123
2019-03-12 20:27:46,528 DEBUG fit_files_tab.get_selected_run() [1054] -- Selected combobx[0] (run 40123)
2019-03-12 20:27:47,475 INFO fit_files_tab.do_fit() [314] -- Fitting with "Exp" with 1 components
2019-03-12 20:27:47,476 DEBUG fit_files_tab.do_fit() [323] -- Group 1 contains runs [40123]
2019-03-12 20:27:47,744 INFO fit_files_tab.do_fit() [415] -- Fitting run 40123 (2018): [{'1/T1': [0.84746, 0.0, inf, False, False], 'amp': [0.07278, 0.0, inf, False, False], 'baseline': [0.00447, -inf, inf, False, False]}, {'rebin': 1, 'group': 1}]
2019-03-12 20:27:47,788 DEBUG fitdata.set_fitresult() [153] -- Setting fit results to {'p0': {'amp': 0.07278, '1/T1': 0.84746, 'baseline': 0.00447, 'beta': 0.5}, 'blo': {'amp': 0.0, '1/T1': 0.0, 'baseline': -inf, 'beta': 0}, 'bhi': {'amp': inf, '1/T1': inf, 'baseline': inf, 'beta': 1}, 'res': {'1/T1': 1.283244280404294, 'amp': 0.09377768860389923, 'baseline': -0.0015603664610268156}, 'dres': {'1/T1': 0.050978671670798344, 'amp': 0.0011112704100392585, 'baseline': 0.0011822237261787266}, 'chi': {'1/T1': 1.3870614424311014, 'amp': 1.3870614424311014, 'baseline': 1.3870614424311014}, 'fixed': {'1/T1': False, 'amp': False, 'baseline': False}, 'shared': {'1/T1': False, 'amp': False, 'baseline': False}}
2019-03-12 20:27:47,788 DEBUG fit_files_tab.set_display() [1162] -- Setting display for run 40123
2019-03-12 20:27:47,788 DEBUG fit_files_tab.get_selected_run() [1054] -- Selected combobx[0] (run 40123)
2019-03-12 20:27:47,789 DEBUG fetch_files_tab.draw_all() [318] -- Drawing all data (ignore check: False)
2019-03-12 20:27:47,790 DEBUG fetch_files_tab.draw_all() [328] -- Draw style: "stack"
2019-03-12 20:27:47,790 DEBUG fetch_files_tab.draw() [770] -- Draw run 40123 (2018)
2019-03-12 20:27:47,793 INFO bfit.draw() [366] -- Drawing run 40123 (2018). mode: c, rebin: 1, option: , style: stack, {'label': '40123'}
2019-03-12 20:27:48,268 DEBUG bfit.draw() [724] -- Drawing success.
2019-03-12 20:27:48,268 INFO fit_files_tab.draw_fit() [603] -- Drawing fit for run 40123. {}
2019-03-12 20:27:49,816 DEBUG bfit.set_tab_change() [1030] -- Changing to tab 1
2019-03-12 20:27:49,816 DEBUG bfit.set_asym_calc_mode_box() [1057] -- Setting fileviewer asym combobox values for mode "20"
2019-03-12 20:27:52,972 DEBUG bfit.return_binder() [880] -- Calling return key command for notebook index 1
2019-03-12 20:27:52,972 DEBUG fetch_files_tab.return_binder() [480] -- Focus is: run or year entry
2019-03-12 20:27:52,973 DEBUG fetch_files_tab.get_data() [375] -- Fetching runs
2019-03-12 20:27:52,973 DEBUG fetch_files_tab.string2run() [543] -- Parsed "40123,40127" to run numbers (len: 2) [40123, 40127]
2019-03-12 20:27:52,977 DEBUG fitdata.__init__() [56] -- Initializing run 40123 (2018).
2019-03-12 20:27:52,982 DEBUG fitdata.__init__() [56] -- Initializing run 40127 (2018).
2019-03-12 20:27:52,982 DEBUG fetch_files_tab.get_data() [422] -- Fetching runs of mode 20
2019-03-12 20:27:52,983 DEBUG bfit.set_asym_calc_mode_box() [1057] -- Setting fileviewer asym combobox values for mode "20"
2019-03-12 20:27:52,983 DEBUG fetch_files_tab.__init__() [596] -- Initializing run 40127 (2018)
2019-03-12 20:27:53,002 DEBUG bfit.get_label() [794] -- Fetching plot label for "Run Number"
2019-03-12 20:27:53,003 DEBUG fit_files_tab.populate() [211] -- Populating data. Groups: [1]
2019-03-12 20:27:53,003 DEBUG fit_files_tab.update() [1280] -- Updating fit tab for group 1
2019-03-12 20:27:53,004 DEBUG fit_files_tab.set_display() [1162] -- Setting display for run 40123
2019-03-12 20:27:53,004 DEBUG fit_files_tab.get_selected_run() [1054] -- Selected combobx[0] (run 40123)
2019-03-12 20:27:53,004 DEBUG fit_files_tab.get_new_parameters() [1024] -- Fetching new parameters
2019-03-12 20:27:53,005 DEBUG fitdata.set_fitpar() [135] -- Fit parameters set to {'p0': {'amp': 0.07277506954176316, '1/T1': 0.8474576271186439, 'baseline': 0.004470859270959627, 'beta': 0.5}, 'blo': {'amp': 0, '1/T1': 0, 'baseline': -inf, 'beta': 0}, 'bhi': {'amp': inf, '1/T1': inf, 'baseline': inf, 'beta': 1}, 'res': {}, 'dres': {}, 'chi': {}, 'fixed': {}, 'shared': {}}
2019-03-12 20:27:53,005 INFO fetch_files_tab.get_data() [457] -- Fetched runs [40123, 40127]
2019-03-12 20:27:55,808 DEBUG bfit.set_tab_change() [1030] -- Changing to tab 2
2019-03-12 20:27:55,809 DEBUG fit_files_tab.populate() [211] -- Populating data. Groups: [1]
2019-03-12 20:27:55,811 DEBUG fit_files_tab.update() [1280] -- Updating fit tab for group 1
2019-03-12 20:27:55,812 DEBUG fit_files_tab.set_display() [1162] -- Setting display for run 40123
2019-03-12 20:27:55,812 DEBUG fit_files_tab.get_selected_run() [1054] -- Selected combobx[0] (run 40123)
2019-03-12 20:27:56,355 DEBUG bfit.set_tab_change() [1030] -- Changing to tab 1
2019-03-12 20:27:56,356 DEBUG bfit.set_asym_calc_mode_box() [1057] -- Setting fileviewer asym combobox values for mode "20"
2019-03-12 20:27:57,857 DEBUG fetch_files_tab.draw_all() [318] -- Drawing all data (ignore check: False)
2019-03-12 20:27:57,858 DEBUG fetch_files_tab.draw_all() [328] -- Draw style: "stack"
2019-03-12 20:27:57,858 DEBUG fetch_files_tab.draw() [770] -- Draw run 40123 (2018)
2019-03-12 20:27:57,860 INFO bfit.draw() [366] -- Drawing run 40123 (2018). mode: c, rebin: 1, option: , style: stack, {'label': '40123'}
2019-03-12 20:27:58,025 DEBUG bfit.draw() [724] -- Drawing success.
2019-03-12 20:27:58,025 DEBUG fetch_files_tab.draw() [770] -- Draw run 40127 (2018)
2019-03-12 20:27:58,027 INFO bfit.draw() [366] -- Drawing run 40127 (2018). mode: c, rebin: 1, option: , style: stack, {'label': '40127'}
2019-03-12 20:27:58,068 DEBUG bfit.draw() [724] -- Drawing success.
2019-03-12 20:27:59,729 DEBUG bfit.set_tab_change() [1030] -- Changing to tab 2
2019-03-12 20:27:59,730 DEBUG fit_files_tab.populate() [211] -- Populating data. Groups: [1]
2019-03-12 20:27:59,730 DEBUG fit_files_tab.update() [1280] -- Updating fit tab for group 1
2019-03-12 20:27:59,731 DEBUG fit_files_tab.set_display() [1162] -- Setting display for run 40123
2019-03-12 20:27:59,731 DEBUG fit_files_tab.get_selected_run() [1054] -- Selected combobx[0] (run 40123)
2019-03-12 20:28:00,691 INFO fit_files_tab.do_fit() [314] -- Fitting with "Exp" with 1 components
2019-03-12 20:28:00,692 DEBUG fit_files_tab.do_fit() [323] -- Group 1 contains runs [40123, 40127]
2019-03-12 20:28:01,038 INFO fit_files_tab.do_fit() [415] -- Fitting run 40123 (2018): [{'1/T1': [0.84746, 0.0, inf, False, False], 'amp': [0.07278, 0.0, inf, False, False], 'baseline': [0.00447, -inf, inf, False, False]}, {'rebin': 0, 'group': 0}]
2019-03-12 20:28:01,038 INFO fit_files_tab.do_fit() [415] -- Fitting run 40127 (2018): [{'1/T1': [0.84746, 0.0, inf, False, False], 'amp': [0.07278, 0.0, inf, False, False], 'baseline': [0.00447, -inf, inf, False, False]}, {'rebin': 1, 'group': 1}]
2019-03-12 20:28:01,041 ERROR fit_files_tab.do_fit() [423] -- Fitting error
Traceback (most recent call last):
File "/home/fuji/Documents/Research/src/bfit/bfit/gui/fit_files_tab.py", line 421, in do_fit
hist_select=self.bfit.hist_select)
File "/home/fuji/Documents/Research/src/bfit/bfit/fitting/default_routines.py", line 141, in __call__
hist_select=hist_select,p0=p0,bounds=bounds)
File "/home/fuji/Documents/Research/src/bfit/bfit/fitting/fit_bdata.py", line 127, in fit_list
p,s,c = fit_single(r,y,fn,om,re,hist_select,p0=p,bounds=b,xlim=xl,**kwargs)
File "/home/fuji/Documents/Research/src/bfit/bfit/fitting/fit_bdata.py", line 181, in fit_single
x,y,dy = data.asym('c',omit=omit,rebin=rebin,hist_select=hist_select)
File "/home/fuji/Documents/Research/src/bdata/bdata/bdata.py", line 1059, in asym
raise RuntimeError('Rebinning factor must be int >= 1.')
RuntimeError: Rebinning factor must be int >= 1.
2019-03-12 20:31:46,753 INFO bfit.on_closing() [863] -- Closing all windows.
2019-03-12 20:31:47,055 INFO bfit.on_closing() [866] -- Finished --------------------------------------------------
You often want to be able to know which file is which without taking up too much screen space.
See here for details
Even with no fetch. Annoying.
Find the most recent run in file inspect if field is empty (or with some way of specifying bnmr/bnqr).
Doesn't always work. Should work based on emitting signals.
Except for periodic redraw
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.