Skip to content

bdata.asym

Derek Fujimoto edited this page Sep 3, 2021 · 11 revisions

This function controls how the asymmetry is calculated. [source]

Function signature

asym(option="", omit="", rebin=1, hist_select='', nbm=False, deadtime=0, scan_repair_options='')

Usage description

Input Type Description
option string Controls what kind of asymmetry is calculation.
omit string Mode 1 bins to omit if space separated string in options is not feasible.
rebin int Weighted average over this many bins to reduce array length by a factor of rebin.
hist_select string string to specify which histograms get combined into making the asymmetry calculation. Deliminate with ,, ;, or .
nbm boolean If True, use neutral beam monitors in calculations.
deadtime float Detector deadtime used to correct counter values (s)
scan_repair_options string Dictates treatment options for scans. Deliminate options with :.

Status of data corrections

Mode 1 (TI)

  • Manual removal of unwanted bins.
  • Provides the option of deadtime correction. Set to zero to disable.
  • Baseline correction
    • Fit the baseline on a scan-by-scan basis with a linear line and subtract from the data to flatten. The mean of the subtracted linear function is added back to keep the average the same.
    • Requires removal of incomplete scans
  • Remove incomplete scans.
  • Scan Combination:
    • The run may be considered to be a single scan with long integration time. To this effect, the histogram bins are summed according to their frequency bin, and the errors are considered to be Poissonian.
    • Otherwise, we take the mean of the non-zero counts in each bin, with errors treated still as Possionian.

Mode 2 (TD)

  • Automatically removes prebeam bins.
  • Provides the option of deadtime correction. Set to zero to disable.
  • Rebinning:
    • returned time is average time over rebin range
    • returned asymmetry is weighted mean

2e Mode

  • Prebeam bin removal.
  • Postbeam bin removal. Assumes beamoff time is 0.
  • Splits saved 1D histograms into 2D.
  • Deadtime corrections are not yet available for this mode.

Input Description

option

omit

rebin

hist_select

If we wished to do a simple asymmetry calculation in the form of

(F-B)/(F+B)

for each helicity, then we would set

hist_select = 'F+, F-, B+, B-'

The pattern is

  1. counter 1, helicity 1
  2. counter 1, helicity 2
  3. counter 2, helicity 1
  4. counter 2, helicity 2

For alpha diffusion calculations append the two alpha counters

hist_select = 'R+, R-, L+, L-, A+, A-

For alpha tagged calculations do the following

hist_select = 'R+, R-, L+, L-, TR+, TR-, TL+, TL-, nTR+, nTR-, nTL+, nTL-'

where

  • TR is the right counter tagged (coincident) with alphas,
  • TL is the left counter tagged with alphas,
  • nTR is the right counter tagged with !alphas (absence of),
  • nLR is the right counter tagged with !alphas,

deadtime

scan_repair_options

Value should be a :-deliminated string composed of the following options, of which all are optional. Ex: 10:omit:overcorrect

Input Value Description
An int Use this many bins on either end of each scan to estimate the baseline slope on a scan-by-scan basis. Apply baseline slope correction. Default: don't correct the baseline
omit Add this keyword to exclude the last scan in the series, if it is incomplete. Default: include all scans
overcorrect Add this keyword to include an over-correction factor to the baseline slopes in order to ensure that the final scan-combined asymmetry has a flat baseline. Default: flatten on a scan-by-scan basis. Requires and integer option to estimate the baseline slope from.
scan_sum or scan_mean Dictate how scans are combined. Functions are applied to the raw counts, not the asymmetry. Default: scan_sum
    Asymmetry calculation outline (with default detectors) ---------------
    
        Split helicity      (NMR): (F-B)/(F+B) for each
        Combined helicity   (NMR): (r-1)/(r+1)
            where r = sqrt([(B+)(F-)]/[(F+)(B-)])
        Split counter       (NMR): (+ - -)/(+ + -) for each F, B
        
        
        
        Split helicity      (NQR): (R-L)/(R+L) for each
        Combined helicity   (NQR): (r-1)/(r+1)
            where r = sqrt([(L+)(R-)]/[(R+)(L-)])
        Split counter       (NMR): (+ - -)/(+ + -) for each R, L
        
        Alpha diffusion     (NQR) sum(AL0)/sum(L+R)
        Alpha tagged        (NQR) same as NQR, but using the tagged counters
        
    Histogram Selection ---------------------------------------------------
    
        
                                      
    Status of Data Corrections --------------------------------------------
        MODE 2 (TD): 
            Removes prebeam bins. 
            Provides the option of deadtime correction. Set to zero to disable.
            Rebinning: 
                returned time is average time over rebin range
                returned asym is weighted mean
            
        MODE 1 (TI): 
            Allows manual removal of unwanted bins. 
            Provides the option of deadtime correction. Set to zero to disable.
            Baseline correction:
                Fit the baseline on a scan-by-scan basis with a linear line 
                and subtract from the data to flatten. Add back the 
                baseline average pre-flatten to keep baseline value 
                approximately the same. Requires removal of incomplete scans
            Remove incomplete scans. 
            Scan Combination:
                Multiscans are considered as a single scan with long 
                integration time. Histogram bins are summed according to 
                their frequency bin, errors are Poissonian.
                
                In the case of split counter asymmetries, we take the mean
                of the non-zero counts in each bin, with errors treated still
                as Possionian.
         
        2E: 
            Prebeam bin removal. 
            Postbeam bin removal. Assumes beamoff time is 0. 
            Splits saved 1D histograms into 2D.
            Deadtime corrections are not yet available for this mode. 
            
            Asymmetry calculations: 
                raw: calculated through differences method (as described in 
                    the asymmetry calculation outline)
                dif: let 0 be the index of the centermost scan in time. dif 
                    asymmetries are then calculated via raw[i+1]-raw[i-1], 
                    where "raw" is as calculated in the above line, for each 
                    of the three types: +, -, combined 
                sl: take a weighted least squares fit to the two bins prior 
                    and the two bins after the center bin (in time). For 
                    each find the value of the asymmetry at the center time 
                    position. Take the difference: post-prior
                
    Option List
    
        MODE 2 DESCRIPTIONS -----------------------------------------------
        
        "":     dictionary of 2D numpy arrays keyed by 
                    {"p", "n", "c", "time_s"} for each helicity and combination 
                    (val, err). Default return state for unrecognized options
        "h":    dictionary 2D numpy arrays keyed by {"p", "n", "time_s"} for 
                    each helicity (val, err).
        "p":    2D np array of up helicity state [time_s, val, err].
        "n":    2D np array of down helicity state [time_s, val, err].
        "f":    2D np array of forward counter [time_s, val, err].
        "b":    2D np array of backward counter [time_s, val, err].
        "l":    2D np array of left counter [time_s, val, err].
        "r":    2D np array of right counter [time_s, val, err].
        "c":    2D np array of combined asymmetry [time_s, val, err].
        "ad":   2D np array of alpha diffusion ratio [time_s, val, err].
        "at":   dictionary of alpha tagged asymmetries key:[val, err]. 
                Keys:
                    
                    'time_s'               : 1D array of times in seconds   
                    'p_wiA', 'n_wiA', 'c_wiA': coincident with alpha
                    'p_noA', 'n_noA', 'c_noA': coincident with no alpha
                    'p_noT', 'n_noT', 'c_noT': untagged
                    
            where p, n, c refer to pos helicity, neg helicity, combined 
            helicity respectively. Only in 2h mode. 
                    
        
        MODE 1 DESCRIPTIONS -----------------------------------------------
        
            all options can include a space deliminated list of bins or 
            ranges of bins which will be omitted. ex: "raw 1 2 5-20 3"
        
        "":     dictionary of 2D numpy arrays keyed by {p, n, c, freq} for each 
                    helicity and combination [val, err]. Default return state 
                    for unrecognized options.
        "r":    Dictionary of 2D numpy arrays keyed by {p, n} for each 
                    helicity (val, err), but listed by bin, not combined by 
                    frequency. 
        "rs":   Dictionary of 2D numpy arrays keyed by {p, n} for each 
                    helicity (val, err), but listed by bin, not combined by 
                    frequency. Split into scans.
        "h":    get unshifted +/- helicity scan-combined asymmetries as a 
                    dictionary {'p':(val, err), 'n':(val, err), 'freq'}
        "p":    get pos helicity states as tuple, combined by frequency 
                    (freq, val, err)
        "n":    similar to p but for negative helicity states
        "f":    similar to p but for forward counter
        "b":    similar to p but for backward counter
        "l":    similar to p but for left counter
        "r":    similar to p but for right counter
        "c":    get combined helicity states as tuple (freq, val, err)
        
                    
        2E DESCRIPTIONS ---------------------------------------------------
        
        "sc":   get slope combined helicity states as tuple (freq, val, err)
        "dc":   get difference combined helicity states as tuple (freq, val, err)
        "rc":   get raw combined helicity states as tuple (freq, time, val, err)
        
            If no options, returns a dictionary with the keys: 
         
        'dif_p':    [val, err][frequency] of pos. helicity asymmetry 
        'dif_n':    [ve][f] of negative helicity asymmetry
        'dif_c':    [ve][f] of combined helicity asymmetry
        
        'raw_p':    [ve][f][time] raw asymmetries of each time bin. Pos hel. 
        'raw_n':    [ve][f][t] negative helicity.
        'raw_c':    [ve][f][t] combined helicity
        
        'freq':     [f] frequency values
        'time':     [t] time bin values
            
        'sl_p':     [ve][f] pos. hel. of asymmetry calcuated through slopes 
                        of pre and post middle time bin. Slope method only 
                        for >= 5 time bins, corresponds to >= 3 RF on delays
        'sl_n':     [ve][f] negative helicity.
        'sl_c':     [ve][f] combined helicity.
    """

Clone this wiki locally