Exemplo n.º 1
0
def xyz2Grid(x, y, z):
    """Transform x, y,z to grid data object

	Parameters:
        x,y : The x and y coordinates of the grid points
        z : The value at the grid points

    return:
        grid :grid is a Grid2D object
    """
    from geoist.others.geodict import GeoDict
    from geoist.others.grid2d import Grid2D
    xmin = np.min(x)
    xmax = np.max(x)
    ymin = np.min(y)
    ymax = np.max(y)
    nx = len(set(x))
    ny = len(set(y))
    dx = (xmax - xmin) / (nx - 1)
    dy = (ymax - ymin) / (ny - 1)
    geodict = {
        'xmin': xmin,
        'xmax': xmax,
        'ymin': ymin,
        'ymax': ymax,
        'dx': dx,
        'dy': dy,
        'nx': nx,
        'ny': ny
    }
    gd = GeoDict(geodict, adjust='res')
    data = z.reshape(nx, ny).T[::-1]
    grid = Grid2D(data[::-1], gd)
    return grid
Exemplo n.º 2
0
def grid2Grid(x, y, data):
    from geoist.others.geodict import GeoDict
    from geoist.others.grid2d import Grid2D
    xmin = np.min(x)
    xmax = np.max(x)
    ymin = np.min(y)
    ymax = np.max(y)
    nx = len(x)
    ny = len(y)
    dx = (xmax - xmin) / (nx - 1)
    dy = (ymax - ymin) / (ny - 1)
    geodict = {
        'xmin': xmin,
        'xmax': xmax,
        'ymin': ymin,
        'ymax': ymax,
        'dx': dx,
        'dy': dy,
        'nx': nx,
        'ny': ny
    }
    gd = GeoDict(geodict, adjust='res')
    grid = Grid2D(data[::-1], gd)
    return grid
Exemplo n.º 3
0
project.inverse = 'L2'
#project.inverse = 'bayes'
print(project.inverse)
project.mask = mask
project.estimate_grid(30, atype='joint')
project.plot_results(mean_Te=True,
                     mask=True,
                     contours=contours,
                     cmap='Spectral')
project.plot_results(std_Te=True, mask=True, contours=contours, cmap='magma_r')

eetdict = topo_m.getGeoDict().copy()
eetny, eetnx = project.mean_Te_grid.shape
eetdict.nx = eetnx
eetdict.ny = eetny
eetgrid = Grid2D(project.mean_Te_grid[::-1], eetdict)
eet_jw = eetgrid.project(p_jw)

# save grid2d data to file in the DATA_PATH
grid2srf(eet_jw, filename='chinaeet.grd')
# transform to jw
topo_jw = topo_m.project(p_jw)

fig, (ax0, ax1) = plt.subplots(nrows=1, ncols=2, figsize=(12, 6))
ax0.imshow(topo_jw.getData())
ax1.imshow(topo.getData())

fig, axes = plt.subplots(nrows=2, ncols=2, figsize=(16, 12))
fig.tight_layout()
map2DGrid(axes[0, 0], topo, 'Topography', 5, 5, isLeft=True, xinc=5.0)
map2DGrid(axes[0, 1], topo_jw, 'Topography', 5, 5, isLeft=True, xinc=5.0)
Exemplo n.º 4
0
ncols = len(np.arange(xmin,xmax+xdim,xdim))
nrows = len(np.arange(ymin,ymax+ydim,ydim))
data = np.arange(0,nrows*ncols)
data.shape = (nrows,ncols)

geodict = {'xmin':xmin,
           'xmax':xmax,
           'ymin':ymin,
           'ymax':ymax,
           'dx':xdim,
           'dy':ydim,
           'nx':ncols,
           'ny':nrows,}

grid = Grid2D(data,GeoDict(geodict))

plt.figure()
plt.imshow(grid.getData(),interpolation='nearest')
plt.colorbar()

lat,lon = grid.getLatLon(4,4)
print('The coordinates at the center of the grid are %.3f,%.3f' % (lat,lon))
value = grid.getValue(lat,lon)
print('The data value at the center of the grid is %i' % (value))

xmin = 119.2
xmax = 119.8
ymin = 32.7
ymax = 33.3
dx = 0.33