Closed mfittere closed 7 years ago
Few comments:
why as os
in import os as os
I like a style in which you can write:
bsrt=pytimber.BSRT.fromdb(t1,t2,beam='B1').fit(...).plot(...)
In this case you save the data in the class and you return the class itself. The advantage is that you can hide the way the data is represented inside the class, you have access to intermediate steps if needed and you have compact code. A bit of docstring should help in finding where find the data in the class.
The __init__
method should contain all the data needed to clone the state of the object. I would default post-processed data with None
.
import os
pytimber.BSRT.fromdb
should return the class itself?
... return cls(emit=bsrt_dict)
I just tested it and you can do e.g. pytimber.BSRT.fromdb(t1,t2,beam='B1',db=db).plot_fit(t1,t2)
To have everything in the class, I would need to add e.g. bsrt_fit_dict
to the class. Then one could for example return the class instead of bsrt_fit_dict
in fit
.We should then also check this with Georges and Enrico as it is then sth. more official and it would be good to get their approval.
I rewrote parts of the codes, some additional comments/questions:
fit_sig_h_var,fit_sig_v_var,gate_delay_var=db.search('%LHC%BSRT%'+beam.upper()+'%FIT_SIGMA_%')+db.search('%LHC%BSRT%'+beam.upper()+'%GATE_DELAY%')
emitfit[slot][(t1,t2)]
if force=true in BSRT.fit() existing values are overwritten. Like this several fits can be plotted at the same time.plot
plots the data and the fitplot_fit(t1fit,t2fit)
plots only the fit for the data in the interval [t1fit,t2fit]. Like this different fits can be plotted on the same data
Here a first version of the BSRT class. You can try it with e.g.:
In case no database is specified, it generates it:
if db==None: db=pytimber.LoggingDB()
We could also add a method of the db directly, e.g.:db.getbsrt(t1,t2,beam='B1')
which callspytimber.BSRT.fromdb(t1,t2,beam='B1',db=db)
I added an additional file
toolbox.py
with useful functions. I would keep those separate as they might be reused also for other postprocessing classes.Please have a look at the code. I just basically copied and pasted what I had with some minor modificiations, it might still need some clean up.