我正在使用MODIS有效半径数据,它包含纬度和经度信息。
数据大小为[2030] [1354],而纬度/经度大小为lat [406] [270]。 我需要炸掉lat / lon以匹配数据大小。
我的问题如下:
如何插入/填充此信息之间的间隙以获得与所有数据点对应的Lat / Lon?
这是我获取lat的纬度/经度大小信息的代码[406] [1354] 但是我希望获得[2030] [1354]的纬度/经度大小的信息。
import numpy as np
from pyhdf.SD import SD, SDC
# Open HDF4 file.
FILE_NAME = 'File.hdf'
hdf = SD(FILE_NAME, SDC.READ)
sds_obj = hdf.select('Effective Radius')
data = sds_obj.get()
lat = hdf.select('Latitude')
latnp = lat[:,:]
lon = hdf.select('Longitude')
lonnp = lon[:,:]
step1=5
step2=4
m=406
n=1354
# We need to interpolate lat and lon to match the size of data.
longitude = np.zeros((m,n), dtype=np.float)
latitude = np.zeros((m,n), dtype=np.float)
for i in range (0, 406):
# print i
for j in range (0, 270):
# print j
if j == 0:
latitude[i,j] = latnp[i,j]
# print latitude[i]
longitude[i,j] = lonnp[i,j]
continue
if j > 0 and j < 270-1 :
# print 'step1='+str(step1)
count=step1*(j-1)+1
# print 'count='+str(count)
arr_fill=np.linspace(latnp[i,(j-1)], latnp[i, j], (step1+1))
# print arr_fill
latitude[i, count:count+(step1)] = arr_fill[0:step1]
# print latitude[i]
arr_fill=np.linspace(lonnp[i,(j-1)], lonnp[i, j], (step1+1))
longitude[i, count:count+(step1)] = arr_fill[0:step1]
continue
if j == 270-1:
count=step1*(j-1)+1
arr_fill=np.linspace(latnp[i,(j-1)], latnp[i, j], (step2+1))
latitude[i, count:count+(step2)] = arr_fill[0:step2]
arr_fill=np.linspace(lonnp[i,(j-1)], lonnp[i, j], (step2+1))
longitude[i, count:count+(step2)] = arr_fill[0:step2]
continue