示例#1
0
def xymagnitude_to_x_y_grid(regular_xymagnitude):
    gridvalues, x0, y0, deltax, deltay = regular_xyval_to_2d_grid_values(regular_xymagnitude)
    nx = numarray.size(gridvalues,0)
    ny = numarray.size(gridvalues,1)
    gridvalues = numarray.reshape(gridvalues,(nx,ny))
    x = numarray.arange(x0,x0+nx*deltax-1e-6,deltax)
    y = numarray.arange(y0,y0+ny*deltay-1e-6,deltay)
    # print "x = ",x
    # print "y = ",y
    # print "z = ",gridvalues
    # print "type(x) = ",type(x)
    # print "type(y) = ",type(y)
    # print "type(z) = ",type(gridvalues)
    # imv.view(gridvalues)
    return x, y, gridvalues
示例#2
0
def xymagnitude_to_x_y_grid(regular_xymagnitude):
    gridvalues, x0, y0, deltax, deltay = regular_xyval_to_2d_grid_values(
        regular_xymagnitude)
    nx = numarray.size(gridvalues, 0)
    ny = numarray.size(gridvalues, 1)
    gridvalues = numarray.reshape(gridvalues, (nx, ny))
    x = numarray.arange(x0, x0 + nx * deltax - 1e-6, deltax)
    y = numarray.arange(y0, y0 + ny * deltay - 1e-6, deltay)
    # print "x = ",x
    # print "y = ",y
    # print "z = ",gridvalues
    # print "type(x) = ",type(x)
    # print "type(y) = ",type(y)
    # print "type(z) = ",type(gridvalues)
    # imv.view(gridvalues)
    return x, y, gridvalues
示例#3
0
def regular_xyval_to_2d_grid_values(xyval):
    """Returns (grid_values, x0, y0, deltax, deltay)"""
    xyval = numarray.array(xyval)
    n = len(xyval)
    x = xyval[:, 0]
    y = xyval[:, 1]
    values = xyval[:, 2:].copy()
    # print "type(values)",type(values)
    valsize = numarray.size(values, 1)
    x0 = x[0]
    y0 = y[0]

    k = 1
    if x[1] == x0:
        deltay = y[1] - y[0]
        while x[k] == x0:
            k = k + 1
        deltax = x[k] - x0
        ny = k
        nx = n // ny
        # print 'A) nx,ny:',nx,ny
        values.shape = (nx, ny, valsize)
        # print "A type(values)",type(values)
        values = numarray.transpose(values, (1, 0, 2))
        # print "B type(values)",type(values)
    elif y[1] == y0:
        deltax = x[1] - x[0]
        while y[k] == y0:
            k = k + 1
        deltay = y[k] - y0
        nx = k
        ny = n // nx
        # print 'B) nx,ny:',nx,ny
        values.shape = (ny, nx, valsize)
        # print "C type(values)",type(values)
        values = numarray.transpose(values, (1, 0, 2))
        # print "D type(values)",type(values)
    else:
        raise ValueError(
            "Strange: x[1]!=x0 and y[1]!=y0 this doesn't look like a regular grid..."
        )

    print 'In regular_xyval_to_2d_grid_values: ', type(xyval), type(values)
    return values, x0, y0, deltax, deltay
示例#4
0
def regular_xyval_to_2d_grid_values(xyval):
    """Returns (grid_values, x0, y0, deltax, deltay)"""
    xyval = numarray.array(xyval)
    n = len(xyval)
    x = xyval[:,0]
    y = xyval[:,1]
    values = xyval[:,2:].copy()
    # print "type(values)",type(values)
    valsize = numarray.size(values,1)
    x0 = x[0]
    y0 = y[0]

    k = 1
    if x[1]==x0:
        deltay = y[1]-y[0]
        while x[k]==x0:
            k = k+1
        deltax = x[k]-x0
        ny = k
        nx = n // ny
        # print 'A) nx,ny:',nx,ny
        values.shape = (nx,ny,valsize)
        # print "A type(values)",type(values)
        values = numarray.transpose(values,(1,0,2))
        # print "B type(values)",type(values)
    elif y[1]==y0:
        deltax = x[1]-x[0]
        while y[k]==y0:
            k = k+1
        deltay = y[k]-y0
        nx = k
        ny = n // nx
        # print 'B) nx,ny:',nx,ny
        values.shape = (ny,nx,valsize)
        # print "C type(values)",type(values)
        values = numarray.transpose(values,(1,0,2))
        # print "D type(values)",type(values)
    else:
        raise ValueError("Strange: x[1]!=x0 and y[1]!=y0 this doesn't look like a regular grid...")

    print 'In regular_xyval_to_2d_grid_values: ', type(xyval), type(values)
    return values, x0, y0, deltax, deltay