import numpy
import tables
file = tables.openFile( "....hdf5","r")
lon = numpy.array(file.root.lon)
lon.ravel()
lat = numpy.array(file.root.lat)
lat.ravel()
data = numpy.array(file.root.data)
v0= data.shape[0]
v1= data.shape[1]
v2= data.shape[2]
wind_spectrum_flat = data.reshape((v0, v1*v2))
interval_spectrum = numarray.arange(30) + 0.5
speed_mean = numarray.dot(interval_spectrum, wind_spectrum_flat)/days/24.
value = numarray.reshape(speed_mean, (v1, v2) )
value.ravel()
打印 lat.shape,lon.shape,value.shape
(480,640) (480,640) (307200,)
output = numpy.column_stack((lon,lat,value))
输出如下:
1.131087052608466621e+02 2.245298999778770010e+01 3.922619047619047450e+001.131096961042312046e+02 2.245299666446372910e+01
如何格式化它们以在每行中获取三个数字(非科学)列?IE:
11310870 224529 3.922
11310969 224529 4.512
11320485 223643 5.332
...