爱气象,爱气象家园! 

气象家园

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博登陆

只需一步, 快速开始

搜索
查看: 6808|回复: 7

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

[复制链接]

新浪微博达人勋

发表于 2015-3-18 16:12:13 | 显示全部楼层 |阅读模式

登录后查看更多精彩内容~

您需要 登录 才可以下载或查看,没有帐号?立即注册 新浪微博登陆

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

脚本程序如下:
  1. #-----------------------------------------------------
  2. # Author: Yaqiang Wang
  3. # Date: 2015-3-18
  4. # Purpose: Read FY3A AOD hdf5 data
  5. # Note: Sample
  6. #-----------------------------------------------------
  7. from org.meteoinfo.data.meteodata import MeteoDataInfo
  8. from org.meteoinfo.data.meteodata import Dimension
  9. from org.meteoinfo.data.meteodata import DimensionType
  10. from org.meteoinfo.data.meteodata import DrawMeteoData
  11. from org.meteoinfo.legend import LegendScheme
  12. from org.meteoinfo.shape import ShapeTypes
  13. from ucar.nc2 import NetcdfFile
  14. import os.path
  15. import jarray

  16. #Set data directory
  17. dataDir = 'D:/Temp/Hdf'

  18. #Create MeteoDataInfo object
  19. mdi = MeteoDataInfo()

  20. #Read hdf data file
  21. fn = os.path.join(dataDir, 'FY3A_MERSI_GBAL_L3_ASL_MLT_GLL_20140331_AOAM_5000M_MS.HDF')
  22. if os.path.isfile(fn):
  23.     print fn
  24.     mdi.openNetCDFData(fn)
  25.     dataInfo = mdi.getDataInfo()
  26.     #print mdi.getInfoText()
  27.     xmin = -30.0
  28.     ymin = -90.0
  29.     xnum = 7200
  30.     ynum = 3600
  31.     xdelt = 0.05
  32.     ydelt = 0.05
  33.     xlist = []
  34.     ylist = []
  35.     for i in range(0,xnum):
  36.         xlist.append(xmin + xdelt * i)
  37.     for i in range(0,ynum):
  38.         ylist.append(ymin + ydelt * i)

  39.     X = jarray.array(xlist, 'd')
  40.     Y = jarray.array(ylist, 'd')
  41.     xDim = Dimension(DimensionType.X)
  42.     xDim.setValues(X)
  43.     dataInfo.setXDimension(xDim)
  44.     yDim = Dimension(DimensionType.Y)
  45.     yDim.setValues(Y)
  46.     dataInfo.setYDimension(yDim)
  47.     var = dataInfo.getVariable('Aerosol_Optical_Thickness_of_MERSI_550nm')
  48.     print var.getName()
  49.     dimList = [yDim, xDim]
  50.     var.setDimensions(dimList)
  51.     gData = mdi.getGridData(var.getName())      
  52.     gData.yReverse()
  53.     gData = gData.div(10000.0)
  54.     gData.missingValue = -3.2767
  55.     #aLS = LegendManage.createLegendSchemeFromGridData(gData, LegendType.GraduatedColor, ShapeTypes.Polygon)
  56.     aLS = LegendScheme(ShapeTypes.Polygon)
  57.     aLS.importFromXMLFile(os.path.join(dataDir, 'AOD.lgs'))
  58.     aLayer = DrawMeteoData.createRasterLayer(gData, "Test_HDF", aLS)
  59.     mf = miapp.getMapDocument().getActiveMapFrame()
  60.     mf.addLayer(aLayer)
  61.     mf.moveLayer(aLayer, 0)

  62. print 'Finished!'

密码修改失败请联系微信:mofangbao

新浪微博达人勋

 成长值: 19710
发表于 2015-3-18 18:22:43 | 显示全部楼层
王老师真及时,专门间接帮助本科生做论文
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2015-3-26 17:56:33 | 显示全部楼层
王老师,我依葫芦画瓢学着读取FY3A AOD HDF文件,我将老师的代码复制进去,修改了路径和名字,系统提示说找不到指定文件

D:\Temp\Hdf\FY3A_MERSI_GBAL_L3_ASL_MLT_GLL_20140430_AOAM_5000M_MS.HDF
Aerosol_Optical_Thickness_of_MERSI_550nm
Traceback (most recent call last):
  File "<iostream>", line 57, in <module>
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(Unknown Source)
at java.io.FileInputStream.<init>(Unknown Source)
at sun.net.www.protocol.file.FileURLConnection.connect(Unknown Source)
at sun.net.www.protocol.file.FileURLConnection.getInputStream(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLEntityManager.setupCurrentEntity(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLVersionDetector.determineDocVersion(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(Unknown Source)
at javax.xml.parsers.DocumentBuilder.parse(Unknown Source)
at org.meteoinfo.legend.LegendScheme.importFromXMLFile(LegendScheme.java:887)
at org.meteoinfo.legend.LegendScheme.importFromXMLFile(LegendScheme.java:872)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
java.io.FileNotFoundException: java.io.FileNotFoundException: D:\Temp\Hdf\AOD.lgs (系统找不到指定的文件。)

想请教老师,是哪里出错了。

密码修改失败请联系微信:mofangbao

新浪微博达人勋

 楼主| 发表于 2015-3-27 15:17:53 来自手机 | 显示全部楼层
应该是没有AOD.lgs文件
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2015-3-28 11:28:04 | 显示全部楼层
谢谢老师,我从您其他的帖子里面下载到了
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2015-4-1 11:34:13 | 显示全部楼层
大家来顶帖啊。。。
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2015-4-6 15:21:26 | 显示全部楼层
请问哪里看一下到AOD.lgs文件
密码修改失败请联系微信:mofangbao

新浪微博达人勋

 楼主| 发表于 2015-4-6 18:16:19 | 显示全部楼层
密码修改失败请联系微信:mofangbao
您需要登录后才可以回帖 登录 | 立即注册 新浪微博登陆

本版积分规则

Copyright ©2011-2014 bbs.06climate.com All Rights Reserved.  Powered by Discuz! (京ICP-10201084)

本站信息均由会员发表,不代表气象家园立场,禁止在本站发表与国家法律相抵触言论

快速回复 返回顶部 返回列表