Exemple #1
0
f = tb.openFile('/Users/fpaolo/data/shelves/all_elev.h5')
f2 = tb.openFile('/Users/fpaolo/data/shelves/all_19920716_20111015_shelf_tide_grids_mts.h5')
#elev = f.root.elev[:]
elev = f2.root.dh_mean_all_interp_corr_short_tint[:]
lon = f2.root.x_edges[:]
lat = f2.root.y_edges[:]

lon, lat = np.meshgrid(lon, lat)
lon = lon.ravel()
lat = lat.ravel()

#plt.plot(lon, lat, '.')
plt.imshow(elev[10,...], origin='lower')
plt.show()

x, y, z = ap.sph2xyz(lon, lat)

'''
points = mlab.points3d(x, y, z,
                     scale_mode='none',
                     scale_factor=0.01,
                     color=(0, 0, 1))

mlab.show()
'''

'''
points = np.column_stack((x,y,z)) 
#triangles = array([[0,1,3], [0,3,2], [1,2,3], [0,2,1]])
#temperature = array([10., 20., 30., 40.])
Exemple #2
0
    plt.imshow(trends[3], origin='lower', interpolation='nearest')
    plt.show()
    sys.exit()

# regrid fields
print 'regridding fields...'
inc = 3
trends, xx, yy = ap.regrid2d(trends, lon, lat, inc_by=inc)

# create 3d coordinates of nodes (x,y,z)
xed = np.linspace(xed.min(), xed.max(), inc * len(lon) + 1)
yed = np.linspace(yed.min(), yed.max(), inc * len(lat) + 1)
xx, yy = np.meshgrid(xed, yed)
lon = xx.ravel()
lat = yy.ravel()
xyz = np.column_stack(ap.sph2xyz(lon, lat))

#---------------------------------------------------------------------
# save data
#---------------------------------------------------------------------

print 'saving data...'
ff = tb.openFile(DIR + 'elev.h5', 'a')
#ff.createArray('/', 'xyz_nodes_regrid', xyz)
ff.createArray('/', 'time_linear', time2)
ff.createGroup('/', 'linear_dhdt')

for k, field in enumerate(trends):
    ff.createArray('/linear_dhdt', 'elev_%02d' % k, field)
ff.close()
print 'done.'
Exemple #3
0
    f = poly_rate[~np.isnan(poly_rate)].round(2)
    print 'poly rate (m/yr):  ', f 
    f = line_rate[~np.isnan(line_rate)].round(2)
    print 'line rate (m/yr):  ', f 
    f = dpoly_rate[~np.isnan(dpoly_rate)].round(2)
    print 'dpoly acce (m/yr2): ', f

#---------------------------------------------------------------------
# save data 
#---------------------------------------------------------------------

# spherical -> cartesian
xx, yy = np.meshgrid(lon, lat)
xed, yed = ap.cell2node(lon, lat)
xed2d, yed2d = np.meshgrid(xed, yed)
xyz = np.column_stack(ap.sph2xyz(xed2d.ravel(), yed2d.ravel()))

if 1:
    print('saving data...')
    fout = tb.open_file(DIR + FILE_OUT, 'w')
    try:
        fout.create_array('/', 'time', time)
    except:
        pass
    try:
        fout.create_array('/', 'lon', lon)
        fout.create_array('/', 'lat', lat)
    except:
        pass
    try:
        fout.create_array('/', 'xyz_nodes', xyz)
Exemple #4
0
    plt.show()
    sys.exit()


# regrid fields
print "regridding fields..."
inc = 3
trends, xx, yy = ap.regrid2d(trends, lon, lat, inc_by=inc)

# create 3d coordinates of nodes (x,y,z)
xed = np.linspace(xed.min(), xed.max(), inc * len(lon) + 1)
yed = np.linspace(yed.min(), yed.max(), inc * len(lat) + 1)
xx, yy = np.meshgrid(xed, yed)
lon = xx.ravel()
lat = yy.ravel()
xyz = np.column_stack(ap.sph2xyz(lon, lat))

# ---------------------------------------------------------------------
# save data
# ---------------------------------------------------------------------

print "saving data..."
ff = tb.openFile(DIR + "elev.h5", "a")
# ff.createArray('/', 'xyz_nodes_regrid', xyz)
ff.createArray("/", "time_linear", time2)
ff.createGroup("/", "linear_dhdt")

for k, field in enumerate(trends):
    ff.createArray("/linear_dhdt", "elev_%02d" % k, field)
ff.close()
print "done."
Exemple #5
0
# (NO) filter ts with std > max_std 
if 0:
    print 'std filtering...'
    data = as_frame(data, dt, lat, lon)
    data = data.apply(std_filt, x=time, max_std=2, max_deg=3, plot=False, raw=False)

# (yes) filter out uncomplete time series
if 1:
    print 'percent filtering...'
    data = data.apply(percent_filt, min_perc=0.7, plot=False, raw=True)

# spherical -> cartesian
xed, yed = ap.cell2node(lon, lat)
xed2d, yed2d = np.meshgrid(xed, yed)
xyz = np.column_stack(ap.sph2xyz(xed2d.ravel(), yed2d.ravel()))

data = as_frame(data, dt, lat, lon)
data = data.apply(ap.referenced, to='mean', raw=True)    # to mean !!!
data = as_array(data)
error[np.isnan(data)] = np.nan

#---------------------------------------------------------------------

if PLOT: # plot time series
    data = as_array(data)
    j, = ap.find_nearest(lon, LON)
    i, = ap.find_nearest(lat, LAT)
    i, j = i[0], j[0]
    y = data[:,i,j]
    plt.plot(time, y, linewidth=2)