码迷,mamicode.com
首页 > 其他好文 > 详细

MeteoInfo脚本示例:读取FY3A AOD HDF文件

时间:2015-03-18 17:37:59      阅读:359      评论:0      收藏:0      [点我收藏+]

标签:

FY3A卫星有AOD产品数据,HDF格式,这里示例用MeteoInfo脚本程序读取和显示该类数据。

技术分享

 

脚本程序如下:

#-----------------------------------------------------
# Author: Yaqiang Wang
# Date: 2015-3-18
# Purpose: Read FY3A AOD hdf5 data
# Note: Sample
#-----------------------------------------------------
from org.meteoinfo.data.meteodata import MeteoDataInfo
from org.meteoinfo.data.meteodata import Dimension
from org.meteoinfo.data.meteodata import DimensionType
from org.meteoinfo.data.meteodata import DrawMeteoData
from org.meteoinfo.legend import LegendScheme
from org.meteoinfo.shape import ShapeTypes
from ucar.nc2 import NetcdfFile
import os.path
import jarray

#Set data directory
dataDir = D:/Temp/Hdf

#Create MeteoDataInfo object
mdi = MeteoDataInfo()

#Read hdf data file
fn = os.path.join(dataDir, FY3A_MERSI_GBAL_L3_ASL_MLT_GLL_20140331_AOAM_5000M_MS.HDF)
if os.path.isfile(fn):
    print fn
    mdi.openNetCDFData(fn)
    dataInfo = mdi.getDataInfo()
    #print mdi.getInfoText()
    xmin = -30.0
    ymin = -90.0
    xnum = 7200
    ynum = 3600
    xdelt = 0.05
    ydelt = 0.05
    xlist = []
    ylist = []
    for i in range(0,xnum):
        xlist.append(xmin + xdelt * i)
    for i in range(0,ynum):
        ylist.append(ymin + ydelt * i)

    X = jarray.array(xlist, d)
    Y = jarray.array(ylist, d)
    xDim = Dimension(DimensionType.X)
    xDim.setValues(X)
    dataInfo.setXDimension(xDim)
    yDim = Dimension(DimensionType.Y)
    yDim.setValues(Y)
    dataInfo.setYDimension(yDim)
    var = dataInfo.getVariable(Aerosol_Optical_Thickness_of_MERSI_550nm)
    print var.getName()
    dimList = [yDim, xDim]
    var.setDimensions(dimList)
    gData = mdi.getGridData(var.getName())        
    gData.yReverse()
    gData = gData.div(10000.0)
    gData.missingValue = -3.2767
    #aLS = LegendManage.createLegendSchemeFromGridData(gData, LegendType.GraduatedColor, ShapeTypes.Polygon)
    aLS = LegendScheme(ShapeTypes.Polygon)
    aLS.importFromXMLFile(os.path.join(dataDir, AOD.lgs))
    aLayer = DrawMeteoData.createRasterLayer(gData, "Test_HDF", aLS)
    mf = miapp.getMapDocument().getActiveMapFrame()
    mf.addLayer(aLayer)
    mf.moveLayer(aLayer, 0)

print Finished!

 

MeteoInfo脚本示例:读取FY3A AOD HDF文件

标签:

原文地址:http://www.cnblogs.com/yaqiang/p/4347538.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!