Exemplo n.º 1
0
def test1():
    r = 0.5
    k = [0., 1., -0.1]
    v = [.2, 0.,  1.]
    v1 = surface_intercept(k,v)
    v2 = surface_intercept_bounds(k,v,2.*r)
    print v1,v2
    plot_circle(r)
    plot_points([v1,v2])
    pyplot.grid()
Exemplo n.º 2
0
def test1():
    r = 0.5
    k = [0., 1., -0.1]
    v = [.2, 0., 1.]
    v1 = surface_intercept(k, v)
    v2 = surface_intercept_bounds(k, v, 2. * r)
    print v1, v2
    plot_circle(r)
    plot_points([v1, v2])
    pyplot.grid()
Exemplo n.º 3
0
def _area_round(beam_poly, det_poly, diameter=None, plot=False, fig=None):
    """
    Compute areas for round sample of fixed diameter

    Parameters:
    -----------
    * beam_pol is the beam polygon
    * det_poly is the detector polygon
      if det_poly = None, then just compute the beam and
      sample overlap ie A_int/A_beam = spill fraction
    """
    if plot:
        if fig != None: pyplot.figure(fig)
        pyplot.clf()
    A_beam = poly_area(beam_poly)
    if det_poly != None:
        inner_poly = inner_polygon(beam_poly, det_poly)
    else:
        inner_poly = beam_poly
    if diameter <= 0.:
        diameter = None
    if diameter == None:
        A_int = poly_area(inner_poly)
    else:
        A_int = poly_area_num(beam_poly, diameter=diameter, plot=plot)

    # make plots
    if plot:
        plot_polygon(beam_poly, fmt='ro-', label='Beam')
        if det_poly != None:
            plot_polygon(det_poly, fmt='ko-', label='Detector')
            plot_points(inner_poly, fmt='go-')
            plot_polygon(inner_poly,
                         fmt='g--',
                         linewidth=4,
                         label='Intersection')
        if diameter != None:
            plot_circle(diameter / 2., fmt='b-', label='Sample')
        pyplot.xlabel('Xs')
        pyplot.ylabel('Ys')
        ll = round(num.sqrt(4. * A_int))
        pyplot.xlim(-ll, ll)
        pyplot.ylim(-ll, ll)
        pyplot.grid()
        pyplot.legend()

    return (A_beam, A_int)
Exemplo n.º 4
0
def _area_round(beam_poly,det_poly,diameter=None,plot=False,fig=None):
    """
    Compute areas for round sample of fixed diameter

    Parameters:
    -----------
    * beam_pol is the beam polygon
    * det_poly is the detector polygon
      if det_poly = None, then just compute the beam and
      sample overlap ie A_int/A_beam = spill fraction
    """
    if plot:
        if fig != None: pyplot.figure(fig)
        pyplot.clf()
    A_beam = poly_area(beam_poly)
    if det_poly != None:
        inner_poly = inner_polygon(beam_poly,det_poly)
    else:
        inner_poly = beam_poly
    if diameter <= 0.:
        diameter = None
    if diameter == None:
        A_int = poly_area(inner_poly)
    else:
        A_int = poly_area_num(beam_poly,diameter=diameter,plot=plot)

    # make plots
    if plot:
        plot_polygon(beam_poly,fmt='ro-',label='Beam')
        if det_poly != None:
            plot_polygon(det_poly,fmt='ko-',label='Detector')
            plot_points(inner_poly,fmt='go-')
            plot_polygon(inner_poly,fmt='g--',linewidth=4,label='Intersection')
        if diameter!= None:
            plot_circle(diameter/2.,fmt='b-',label='Sample')
        pyplot.xlabel('Xs')
        pyplot.ylabel('Ys')
        ll = round(num.sqrt(100.*A_int))
        pyplot.xlim(-ll,ll)
        pyplot.ylim(-ll,ll)
        pyplot.grid()
        pyplot.legend()

    return (A_beam,A_int)