Esempio n. 1
0
def polaranisotropy(data, pwdist, lags, tol, nsectors):
    angle = 360.0 / nsectors
    atol = angle / 2.0
    sectors = [atol + i * angle for i in range(nsectors)]

    fig, ax = subplots()
    cnorm = colors.Normalize(vmin=0, vmax=1)
    scalarmap = cm.ScalarMappable(norm=cnorm, cmap=cm.jet)

    for sector in sectors:
        for lag in lags:

            anisodata = (data, pwdist, lag, tol, sector, atol)
            indices = variograms.anilagindices(*anisodata)
            sv = variograms.semivariance(data, indices)
            fc = scalarmap.to_rgba(sv)

            center, r, width = (0, 0), lag, lags[0] * 2
            theta1 = utilities.degree_to_bearing(sector + atol)
            theta2 = utilities.degree_to_bearing(sector - atol)
            wedge = mpatches.Wedge(center, r, theta1, theta2, width, color=fc)
            ax.add_patch(wedge)

    ax.set_xlim(-lags[-1], lags[-1])
    ax.set_ylim(-lags[-1], lags[-1])
    ax.set_aspect('equal')
Esempio n. 2
0
def polaranisotropy(data, pwdist, lags, tol, nsectors):
    angle = 360.0 / nsectors
    atol = angle / 2.0
    sectors = [atol + i * angle for i in range(nsectors)]

    fig, ax = subplots()
    cnorm = colors.Normalize(vmin=0, vmax=1)
    scalarmap = cm.ScalarMappable(norm=cnorm, cmap=cm.jet)

    for sector in sectors:
        for lag in lags:

            anisodata = (data, pwdist, lag, tol, sector, atol)
            indices = variograms.anilagindices(*anisodata)
            sv = variograms.semivariance(data, indices)
            fc = scalarmap.to_rgba(sv)

            center, r, width = (0, 0), lag, lags[0] * 2
            theta1 = utilities.degree_to_bearing(sector + atol)
            theta2 = utilities.degree_to_bearing(sector - atol)
            wedge = mpatches.Wedge(center, r, theta1, theta2, width, color=fc)
            ax.add_patch(wedge)

    ax.set_xlim(-lags[-1], lags[-1])
    ax.set_ylim(-lags[-1], lags[-1])
    ax.set_aspect('equal')
Esempio n. 3
0
def hscattergram(data, pwdist, lag, tol):
    '''
    Input:  (data)    NumPy array with three columns, the first two
                      columns should be the x and y coordinates, and
                      third should be the measurements of the variable
                      of interest
            (lag)     the lagged distance of interest
            (tol)     the allowable tolerance about (lag)
            (pwdist)  a square pairwise distance matrix
    Output:           h-scattergram figure showing the distribution of
                      measurements taken at a certain lag and tolerance
    '''
    # calculate the pairwise distances
    indices = variograms.lagindices(pwdist, lag, tol)
    # collect the head and tail measurements
    head = data[indices[:, 0], 2]
    tail = data[indices[:, 1], 2]
    # create a scatterplot with equal axes
    fig, ax = subplots()
    ax.scatter(head, tail, marker="o", facecolor="none", edgecolor="k", alpha=0.5)
    ax.set_aspect("equal")
    # set the labels and the title
    ax.set_ylabel("$z(u+h)$")
    ax.set_xlabel("$z(u)$")
    ax.set_title("Lags Between " + str(lag - tol) + " and " + str(lag + tol))
    # grab the limits of the axes
    xmin, xmax = ax.get_xlim()
    ymin, ymax = ax.get_ylim()
    # calculate the covariance and annotate
    cv = variograms.covariance(data, indices)
    ax.text(xmin * 1.25, ymin * 1.050, 'Covariance = {:3.2f}'.format(cv))
    # calculate the semivariance and annotate
    sv = variograms.semivariance(data, indices)
    ax.text(xmin * 1.25, ymin * 1.025, 'Semivariance = {:3.2f}'.format(sv))
    show()
Esempio n. 4
0
def hscattergram(data, pwdist, lag, tol):
    '''
    Input:  (data)    NumPy array with three columns, the first two 
                      columns should be the x and y coordinates, and 
                      third should be the measurements of the variable
                      of interest
            (lag)     the lagged distance of interest
            (tol)     the allowable tolerance about (lag)
            (pwdist)  a square pairwise distance matrix
    Output:           h-scattergram figure showing the distribution of
                      measurements taken at a certain lag and tolerance
    '''
    # calculate the pairwise distances
    indices = variograms.lagindices(pwdist, lag, tol)
    # collect the head and tail measurements
    head = data[indices[:, 0], 2]
    tail = data[indices[:, 1], 2]
    # create a scatterplot with equal axes
    fig, ax = subplots()
    ax.scatter(head,
               tail,
               marker="o",
               facecolor="none",
               edgecolor="k",
               alpha=0.5)
    ax.set_aspect("equal")
    # set the labels and the title
    ax.set_ylabel("$z(u+h)$")
    ax.set_xlabel("$z(u)$")
    ax.set_title("Lags Between " + str(lag - tol) + " and " + str(lag + tol))
    # grab the limits of the axes
    xmin, xmax = ax.get_xlim()
    ymin, ymax = ax.get_ylim()
    # calculate the covariance and annotate
    cv = variograms.covariance(data, indices)
    ax.text(xmin * 1.25, ymin * 1.050, 'Covariance = {:3.2f}'.format(cv))
    # calculate the semivariance and annotate
    sv = variograms.semivariance(data, indices)
    ax.text(xmin * 1.25, ymin * 1.025, 'Semivariance = {:3.2f}'.format(sv))
    show()