NSLS-II / pyCHX

chx_analysis_codes
BSD 3-Clause "New" or "Revised" License
5 stars 6 forks source link

speckle visibility - consolidate code #52

Open ambarb opened 3 years ago

ambarb commented 3 years ago

_commonspeckle.chx_speckle

_commonspeckle.chx_specklecp

ambarb commented 3 years ago

pychx.v2._commonspeckle vs skbeam for frame arrays

things skbeam pychx
imports missing warnings six, matplotlib , scipy, datetime.datetime, mpl.pyplot, sp.stat, sp.optimize
xsvs() seems "base" added arguments but some miss docstring
- customizable time_bin
- buf (ring buffer) numpy.ma (mask-able)
useful code comments that should be ported
generally addition of if control flow to prevent error states
_process() helpful comments and disabled warnings added more complexity to internal buf[level, buf_no]
normalize_bin_edges() same same
pychx speckle for frames has additional functions. Are these functions some where else in the skbeam code base? pychx speckle function location in skbeam speckle purpose comment
get_bin_edges() ? return normalized bin edge and centers for each integration time
gammaDist() ? FOR FIT - returns gamma distribution equiv gamma_dist DELETE
gamma_dist() skbeam.core.fitting.lineshapes FOR FIT - returns gamma distribution, equiv gammaDist except 2 parameters passed as variables, not tuple import instead
nbinom_dist() skbeam.core.fitting.lineshapes FOR FIT - returns negative binomial distribution same format at gamma_dist() import instead
poisson() ? FOR FIT - returns poisson distr same as poisson_dist, worse docstring DELETE
poisson_dist() skbeam.core.fitting.lineshapes FOR FIT - returns poisson distr same as poisson, better docstring import instead
diff_mot_con_factor() ? speckle contrast factor for diffuse motion
get_roi() ? returns roi for data above a threshold called in fit_xsvs1(). add doctring
plot_sxvs() ? plots results, WHY NOT xsvs?, SAXS specific?
fit_sxvs1() ? fit negative binomial, gamma, poisson distrib WHY NOT xsvs?, SAXS specific?
plot_xsvs_g2 ? plot g2 results with customize dictionary for SAXS (uid, path, rz_cen, qz_cen) **kwarg for limited matplotlib *Move to plotting module
nbinomlog() ? Residuals for maximum likelihood fit to nbinom distribution mu is defined as a tuple, p: mu, M =p
nbinomlog1() ? Residuals for maximum likelihood fit to nbinom distribution mu and M defined explict: M =p[0], mu=mu
nbinres() ? Residuals for leastsq to fit normal chi-square - no log() Should we combine with nbiomlog and people just ask for what they want with 1 function?
get_xsvs_fit() ? Fit the xsvs by Negative Binomial Function using max-likelihood chi-squares why just nb? look into combining with fit_sxvs()
plot_xsvs_fit() ? SAXS centric plotting of results Move to plotting module
get_max_countc() should be but is something for XPD roi module *COMPRESSED not image in the image module
get_contrast() ? returns contrast factor L with input from ML_val needs docstring
plot_g2_contrast() no plots results from get_contrast(), g2, taus SAXS centric
ambarb commented 3 years ago

chx_speckle vs chx_specklecp for v2_commonspeckle

duplicated functions

comparative functions what chx_speckle chx_specklecp
primary visibility function xsvs xsvsc_single (need verify), docstring close to xsvs
supports - xsvsp, xsvsp_multi,xsvsp_single,xsvsc,xsvsc_multi`
_process initial if different initial if different
TODO histogram to bincount, change error bar calc
uses np.histogram uses np.bincount
normalize_bin_edges same same
get_bin_edges same same
get_roi same but "roi" (https://github.com/NSLS-II/pyCHX/blob/2ecdacf0dd8496dd8e90bb4975273b59e1d08e26/pyCHX/v2/_commonspeckle/chx_speckle.py#L594) same but "ind" - more accurately index?(https://github.com/NSLS-II/pyCHX/blob/2ecdacf0dd8496dd8e90bb4975273b59e1d08e26/pyCHX/chx_specklecp.py#L803)

NOT DONE YET

Functions Unique to specklecp