Exemple #1
0
 def test_makedataset2d_diffdataset():
     p1 = ManualParameter('dummy1')
     p2 = ManualParameter('dummy2')
     ds = qtt.data.makeDataSet2D(p1[0:10:1], p2[0:4:1], ['m1', 'm2'])
     _ = diffDataset(ds)
Exemple #2
0
def perpLineIntersect(ds, description, vertical=True, points=None, fig=588, diff_dir='xy'):
    """ Takes three points in a graph and calculates the length of a linepiece 
        between a line through points 1,2 and a vertical/horizontal line
        through the third point. Uses the currently active figure.

        Args:
            ds (dataset): dataset with charge stability diagram and gate voltage in mV
            vertical (bool): find intersection of point with line vertically (True) 
                or horizontally (False)
            points (None or array): if None, then let the user select points
            diff_dir (None or 'xy'): specification of differentiation direction

        Returns:
            (dict): 'intersection_point' = intersetcion point
                    'distance' = length of line from 3rd clicked point to line
                    through clicked points 1 and 2
                    'clicked_points' = coordinates of the three clicked points
    """

    if diff_dir is not None:
        diffDataset(ds, diff_dir='xy')
        array_name = 'diff_dir_xy'
    else:
        array_name = ds.default_parameter_name()
    plt.figure(fig)
    plt.clf()
    MatPlot(ds.arrays[array_name], num=fig)
    ax = plt.gca()
    ax.set_autoscale_on(False)

    if description == 'lever_arm' and vertical == True:
        print('''Please click three points;
            Point 1: on the addition line for the dot represented on the vertical axis
            Point 2: further on the addition line for the dot represented on the vertical axis
            Point 3: on the triple point at the addition line for the dot represented on the horizontal axis
            where both dot levels are aligned''')
    elif description == 'lever_arm' and vertical == False:
        print('''Please click three points;
            Point 1: on the addition line for the dot represented on the horizontal axis
            Point 2: further on the addition line for the dot represented on the horizontal axis
            Point 3: on the triple point at the addition line for the dot represented on the horizontal axis
            where both dot levels are aligned''')
    elif description == 'E_charging':
        print('''Please click three points;
            Point 1: on the (0, 1) - (0,2) addition line
            Point 2: further on the (0, 1) - (0,2) addition line
            Point 3: on the (0, 0) - (0, 1) addition line ''')
    else:
        # Do something here such that no three points need to be clicked
        raise Exception('''Please make sure that the description argument of this function
              is either 'lever_arm' or 'E_charging' ''')

    if points is not None:
        clicked_pts = points
    else:
        plt.title('Select three points')
        plt.draw()
        plt.pause(1e-3)
        clicked_pts = qtt.pgeometry.ginput(3, '.c')

    qtt.pgeometry.plotPoints(clicked_pts, ':c')
    qtt.pgeometry.plotLabels(clicked_pts)

    linePoints1_2 = qtt.pgeometry.fitPlane(clicked_pts[:, 0:2].T)

    yy = clicked_pts[:, [2, 2]]
    yy[1, -1] += 1
    line_vertical = qtt.pgeometry.fitPlane(yy.T)

    xx = clicked_pts[:, [2, 2]]
    xx[0, -1] += 1
    line_horizontal = qtt.pgeometry.fitPlane(xx.T)

    if vertical == True:
        i = qtt.pgeometry.intersect2lines(linePoints1_2, line_vertical)
        intersectPoint = qtt.pgeometry.dehom(i)
        line = intersectPoint[:, [0, 0]]
        line[0, -1] += 1
    else:
        i = qtt.pgeometry.intersect2lines(linePoints1_2, line_horizontal)
        intersectPoint = qtt.pgeometry.dehom(i)
        line = intersectPoint[:, [0, 0]]
        line[1, -1] += 1

    linePt3_ints = qtt.pgeometry.fitPlane(line.T)
    line_length = np.linalg.norm(intersectPoint - clicked_pts[:, 2:3])

    # visualize
    plotAnalysedLines(clicked_pts, linePoints1_2, line_vertical, line_horizontal, linePt3_ints, intersectPoint)

    return {'intersection_point': intersectPoint, 'distance': line_length, 'clicked_points': clicked_pts, 'array_names': [array.name for array in ds.default_parameter_array().set_arrays]}
Exemple #3
0
def perpLineIntersect(ds, description, vertical = True, points=None):
    """ Takes three points in a graph and calculates the length of a linepiece 
        between a line through points 1,2 and a vertical/horizontal line
        through the third point. Uses the currently active figure.
        
        Args:
            ds (dataset): dataset with charge stability diagram and gate voltage in mV
            vertical (bool): find intersection of point with line vertically (True) 
            or horizontally (False)
            description: 
        
        Returns:
            (dict): 'intersection_point' = intersetcion point
                    'distance' = length of line from 3rd clicked point to line
                    through clicked points 1 and 2
                    'clicked_points' = coordinates of the three clicked points
    """
    diffDataset(ds, diff_dir='xy')
    plt.figure(588); plt.clf()
    MatPlot(ds.diff_dir_xy, num = 588)
    ax = plt.gca()
    ax.set_autoscale_on(False)
    ax.set_xlabel(ax.get_xlabel()[:2])
    ax.set_ylabel(ax.get_ylabel()[:2])
    
#    ax = plt.gca()
#    ax.set_autoscale_on(False)
    if description == 'lever_arm' and vertical == True:
        print('''Please click three points;
            Point 1: on the addition line for the dot represented on the vertical axis
            Point 2: further on the addition line for the dot represented on the vertical axis
            Point 3: on the triple point at the addition line for the dot represented on the horizontal axis
            where both dot levels are aligned''')
    elif description == 'lever_arm' and vertical == False:
        print('''Please click three points;
            Point 1: on the addition line for the dot represented on the horizontal axis
            Point 2: further on the addition line for the dot represented on the horizontal axis
            Point 3: on the triple point at the addition line for the dot represented on the horizontal axis
            where both dot levels are aligned''')
    elif description == 'E_charging':
        print('''Please click three points;
            Point 1: on the (0, 1) - (0,2) addition line
            Point 2: further on the (0, 1) - (0,2) addition line
            Point 3: on the (0, 0) - (0, 1) addition line ''')
    else:
        # Do something here such that no three points need to be clicked
        print('''Please make sure that the descirption argument of this function
              is either 'lever_arm' or 'E_charging' ''')
    
    if points is not None:
        clicked_pts = points
    else:
        clicked_pts=qtt.pgeometry.ginput(3, '.c')
    
    qtt.pgeometry.plotPoints(clicked_pts, ':c')
    qtt.pgeometry.plotLabels(clicked_pts)
    
    linePoints1_2 = qtt.pgeometry.fitPlane( clicked_pts[:, 0:2].T )
    
    yy = clicked_pts[:,[2, 2]]; yy[1, -1] += 1
    line_vertical = qtt.pgeometry.fitPlane( yy.T )

    xx = clicked_pts[:,[2, 2]]; xx[0, -1] += 1
    line_horizontal = qtt.pgeometry.fitPlane( xx.T )
        
    if vertical == True:
        i = qtt.pgeometry.intersect2lines(linePoints1_2, line_vertical)
        intersectPoint = qtt.pgeometry.dehom(i)
        line = intersectPoint[:,[0,0]]; line[0,-1]+=1
    else:
        i = qtt.pgeometry.intersect2lines(linePoints1_2, line_horizontal)
        intersectPoint = qtt.pgeometry.dehom(i)
        line = intersectPoint[:,[0,0]]; line[1,-1]+=1
    
    linePt3_ints = qtt.pgeometry.fitPlane(line.T)
    line_length = np.linalg.norm(intersectPoint - clicked_pts[:,2:3])
    
    # visualize
    plotAnalysedLines(clicked_pts, linePoints1_2, line_vertical, line_horizontal, linePt3_ints, intersectPoint)
    
    return {'intersection_point': intersectPoint, 'distance': line_length, 'clicked_points': clicked_pts}