Module Expr Str ImportFrom alias alias alias ImportFrom alias Import alias identifier Import alias ImportFrom alias ImportFrom alias alias alias ImportFrom alias alias alias alias alias FunctionDef arguments args NameParam NameParam NameParam NameParam NameParam NameParam NameParam defaults body Expr Str Assign NameStore SubscriptLoad NameLoad Index NameLoad Assign NameStore SubscriptLoad Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad keyword NameLoad Index Num Assign NameStore Call NameLoad NameLoad NameLoad BinOpMult NameLoad Call AttributeLoad NameLoad attr NameLoad keyword NameLoad Assign TupleStore NameStore NameStore Call NameLoad NameLoad NameLoad NameLoad NameLoad NameLoad Assign NameStore Call AttributeLoad NameLoad attr Call AttributeLoad NameLoad attr NameLoad Assign NameStore Call NameLoad Num Call AttributeLoad NameLoad attr ListLoad Call NameLoad NameLoad Call NameLoad NameLoad NameLoad Assign NameStore BinOpDiv SubscriptLoad NameLoad Index NameLoad SubscriptLoad NameLoad Index NameLoad Return TupleLoad Call AttributeLoad NameLoad attr NameLoad Call AttributeLoad NameLoad attr NameLoad decorator_list Assign AttributeStore NameLoad attr Call NameLoad NameLoad FunctionDef arguments args NameParam NameParam NameParam NameParam NameParam NameParam NameParam NameParam NameParam NameParam defaults NameLoad NameLoad NameLoad body Expr Str If CompareIs NameLoad NameLoad body Assign NameStore Call NameLoad BinOpMult Call AttributeLoad NameLoad attr AttributeLoad NameLoad attr Num Assign NameStore Call AttributeLoad Call NameLoad NameLoad AttributeLoad NameLoad attr NameLoad attr Assign NameStore Call AttributeLoad Call NameLoad NameLoad AttributeLoad NameLoad attr NameLoad attr Assign NameStore Call AttributeLoad NameLoad attr Assign NameStore Call AttributeLoad NameLoad attr UnaryOpUSub AttributeLoad NameLoad attr AttributeLoad NameLoad attr NameLoad keyword NameLoad Assign NameStore Call NameLoad For TupleStore NameStore NameStore Call NameLoad NameLoad body Assign NameStore BinOpMult CompareLtE NameLoad NameLoad CompareGt NameLoad NameLoad Expr Call AttributeLoad NameLoad attr Call NameLoad SubscriptLoad NameLoad Index NameLoad SubscriptLoad NameLoad Index NameLoad keyword NameLoad keyword NameLoad keyword NameLoad Assign NameStore Call NameLoad NameLoad Assign NameStore ListLoad For TupleStore NameStore NameStore NameStore NameLoad body Assign NameStore CompareGt NameLoad Num Assign NameStore BinOpDiv SubscriptLoad NameLoad Index NameLoad SubscriptLoad NameLoad Index NameLoad Assign NameStore SubscriptLoad Call NameLoad NameLoad Index NameLoad Assign NameStore SubscriptLoad Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad keyword NameLoad Index Num Assign NameStore Call NameLoad NameLoad NameLoad BinOpMult NameLoad Call AttributeLoad NameLoad attr NameLoad keyword NameLoad Expr Call AttributeLoad NameLoad attr SubscriptLoad NameLoad Index SubscriptLoad NameLoad Slice NameLoad Assign NameStore ListComp Call NameLoad NameLoad comprehension NameStore NameLoad Assign NameStore Call AttributeLoad NameLoad attr NameLoad Assign NameStore AttributeLoad Call AttributeLoad NameLoad attr ListComp SubscriptLoad NameLoad Slice NameLoad comprehension NameStore NameLoad attr Assign NameStore Call AttributeLoad NameLoad attr BinOpSub NameLoad Call AttributeLoad NameLoad attr NameLoad keyword Num keyword NameLoad keyword Num Assign NameStore Call NameLoad NameLoad Assign NameStore Call AttributeLoad NameLoad attr Call AttributeLoad NameLoad attr NameLoad Assign NameStore BinOpDiv BinOpMult Call AttributeLoad NameLoad attr BinOpMult Call AttributeLoad NameLoad attr NameLoad NameLoad NameLoad BinOpMult AttributeLoad NameLoad attr SubscriptLoad NameLoad Index Num Assign NameStore BinOpDiv BinOpMult Call AttributeLoad NameLoad attr BinOpMult Call AttributeLoad NameLoad attr NameLoad NameLoad NameLoad BinOpMult AttributeLoad NameLoad attr SubscriptLoad NameLoad Index Num Return Call NameLoad BinOpAdd Call AttributeLoad NameLoad attr NameLoad Call AttributeLoad NameLoad attr ListLoad NameLoad NameLoad decorator_list
N/A N/A 
This is the module for calibration functions and data
 __future__ absolute_import division print_function collections deque N/A numpy np N/A scipy.signal constants calibration_standards feature filter_peak_height peak_refinement refine_log_quadratic utils angle_grid radial_grid pairwise bin_edges_to_centers bin_1D estimate_d_blind N/A N/A name wavelength bin_centers ring_average window_size max_peak_count thresh N/A N/A N/A 
    Estimate the sample-detector distance

    Given a radially integrated calibration image return an estimate for
    the sample-detector distance.  This function does not require a
    rough estimate of what d should be.

    For the peaks found the detector-sample distance is estimated via
    .. math ::

        D = \frac{r}{\tan 2\theta}

    where :math:`r` is the distance in mm from the calibrated center
    to the ring on the detector and :math:`D` is the distance from
    the sample to the detector.

    Parameters
    ----------
    name : str
        The name of the calibration standard.  Used to look up the
        expected peak location
        For valid options, see the name attribute on this function

    wavelength : float
        The wavelength of scattered x-ray in nm

    bin_centers : array
        The distance from the calibrated center to the center of
        the ring's annulus in mm

    ring_average : array
        The average intensity in the given ring of a azimuthally integrated
        powder pattern.  In counts [arb]

    window_size : int
        The number of elements on either side of a local maximum to
        use for locating and refining peaks.  Candidates are identified
        as a relative maximum in a window sized (2*window_size + 1) and
        the same window is used for fitting the peaks to refine the location.

    max_peak_count : int
        Use at most this many peaks

    thresh : float
        Fraction of maximum peak height

    Returns
    -------
    dist_sample : float
        The detector-sample distance in mm.  This is the mean of the estimate
        from all of the peaks used.

    std_dist_sample : float
        The standard deviation of d computed from the peaks used.
     N/A cal N/A calibration_standards N/A name N/A cands N/A N/A N/A N/A scipy signal argrelmax ring_average order window_size N/A 0 N/A cands N/A filter_peak_height ring_average cands N/A thresh N/A N/A np max ring_average window window_size N/A N/A peaks_x peaks_y N/A peak_refinement bin_centers ring_average cands window_size refine_log_quadratic N/A tan2theta N/A N/A np tan N/A N/A cal convert_2theta wavelength N/A slc N/A slice 0 N/A N/A np min N/A N/A len tan2theta N/A len peaks_x max_peak_count N/A d_array N/A N/A peaks_x N/A slc N/A tan2theta N/A slc N/A N/A N/A N/A np mean d_array N/A N/A np std d_array N/A N/A N/A estimate_d_blind name N/A list calibration_standards refine_center N/A N/A image calibrated_center pixel_size phi_steps max_peaks thresh window_size nx min_x max_x N/A None None None N/A N/A 
    Refines the location of the center of the beam.

    This relies on being able to see the whole powder pattern.

    Parameters
    ----------
    image : ndarray
        The image

    calibrated_center : tuple
        (row, column) the estimated center

    pixel_size : tuple
        (pixel_height, pixel_width)

    phi_steps : int
        How many regions to split the ring into, should be >10

    max_peaks : int
        Number of rings to look it

    thresh : float
        Fraction of maximum peak height

    window_size : int, optional
        The window size to use (in bins) to use when refining peaks

    nx : int, optional
        Number of bins to use for radial binning

    min_x : float, optional
        The minimum radius to use for radial binning

    max_x : float, optional
        The maximum radius to use for radial binning

    Returns
    -------
    calibrated_center : tuple
        The refined calibrated center.
     N/A N/A nx None N/A N/A nx N/A int N/A N/A N/A np mean N/A image shape 2 N/A phi N/A N/A N/A angle_grid calibrated_center N/A image shape pixel_size ravel N/A r N/A N/A N/A radial_grid calibrated_center N/A image shape pixel_size ravel N/A I N/A N/A image ravel N/A phi_steps N/A N/A np linspace N/A N/A np pi N/A np pi phi_steps endpoint True N/A out N/A deque N/A N/A phi_start phi_end N/A pairwise phi_steps N/A N/A mask N/A N/A phi phi_end N/A phi phi_start N/A N/A N/A out append N/A bin_1D N/A r N/A mask N/A I N/A mask nx nx min_x min_x max_x max_x N/A out N/A list out N/A ring_trace N/A N/A N/A bins b_sum b_count out N/A N/A mask N/A b_sum 10 N/A avg N/A N/A b_sum N/A mask N/A b_count N/A mask N/A bin_centers N/A N/A bin_edges_to_centers bins N/A mask N/A cands N/A N/A N/A N/A scipy signal argrelmax avg order window_size N/A 0 N/A cands N/A filter_peak_height avg cands N/A thresh N/A N/A np max avg window window_size N/A N/A N/A ring_trace append N/A bin_centers N/A N/A cands N/A max_peaks N/A tr_len N/A N/A len rt N/A rt ring_trace N/A mm N/A N/A np min tr_len N/A ring_trace N/A N/A N/A np vstack N/A N/A rt N/A mm N/A rt ring_trace T N/A mean_dr N/A N/A np mean N/A ring_trace N/A N/A np mean ring_trace axis 1 keepdims True axis 0 N/A phi_centers N/A bin_edges_to_centers phi_steps N/A delta N/A N/A np mean N/A N/A np diff phi_centers N/A col_shift N/A N/A N/A N/A np sum N/A N/A N/A np sin phi_centers mean_dr delta N/A N/A np pi N/A pixel_size N/A 1 N/A row_shift N/A N/A N/A N/A np sum N/A N/A N/A np cos phi_centers mean_dr delta N/A N/A np pi N/A pixel_size N/A 0 N/A N/A tuple N/A N/A N/A np array calibrated_center N/A N/A np array N/A row_shift col_shift N/A