爱气象,爱气象家园! 

气象家园

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博登陆

只需一步, 快速开始

搜索
查看: 4184|回复: 1

用MeteoInfo绘制全球水色分布图

[复制链接]

新浪微博达人勋

发表于 2013-10-30 11:44:06 | 显示全部楼层 |阅读模式

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

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

x
看到Aires发的用hdfview画全球水色分布图的帖子(http://bbs.06climate.com/forum.php?mod=viewthread&tid=10426&extra=&page=1),也尝试用MeteoInfo Java版做了一下。数据:S19972441997273.L3m_MO_CHL_chlor_a_9km,下载地址:http://oceandata.sci.gsfc.nasa.gov/SeaWiFS/Mapped/Monthly/9km/chlor/

数据是HDF4格式,没有遵循EOS规范,因此MeteoInfo Java版不能自动读取格点位置信息,不过用软件打开文件后可以查看文件信息:
File Name: D:\Temp\Hdf\S19972441997273.L3m_MO_CHL_chlor_a_9km
File type: Hierarchical Data Format, version 4 (HDF4)
Dimensions: 2
        fakeDim0 = 2160;
        fakeDim1 = 4320;
Global Attributes: [Product_Name = "S19972441997273.L3m_MO_CHL_chlor_a_9km", Sensor_Name = "SeaWiFS", Sensor = "Sea-viewing Wide Field-of-view Sensor (SeaWiFS)", Title = "SeaWiFS Level-3 Standard Mapped Image", Data_Center = "NASA/GSFC SeaWiFS Data Processing Center", Station_Name = "Wallops Flight Facility", Station_Latitude = 37.9272f, Station_Longitude = -75.4753f, Mission = "SeaStar SeaWiFS", Mission_Characteristics = "Nominal orbit: inclination = 98.2 (Sun-synchronous); node = 12 noon local (descending); eccentricity = <0.002; altitude = 705 km; ground speed = 6.75 km/sec", Sensor_Characteristics = "Number of bands = 8; number of active bands = 8; wavelengths per band (nm) = 412, 443, 490, 510, 555, 670, 765, 865; bits per pixel = 10; instantaneous field-of-view = 1.5835 mrad; pixels per scan = 1285; scan rate = 6/sec; sample rate = 7710/sec", Product_Type = "other", Processing_Version = "2010.0", Software_Name = "smigen", Software_Version = "4.17", Processing_Time = "2010272172320000", Input_Files = "S19972441997273.L3b_MO_CHL.main", Processing_Control = "smigen par=S19972441997273.L3m_MO_CHL_chlor_a_9km.param", Input_Parameters = "IFILE = /data4/sdpsoper/vdc/vpu3/workbuf/S19972441997273.L3b_MO_CHL.main|OFILE = S19972441997273.L3m_MO_CHL_chlor_a_9km|PFILE = |PROD = chlor_a|PALFILE = DEFAULT|PROCESSING VERSION = 2010.0|MEAS = 1|STYPE = 0|DATAMIN = 0.000000|DATAMAX = 0.000000|LONWEST = -180.000000|LONEAST = 180.000000|LATSOUTH = -90.000000|LATNORTH = 90.000000|RESOLUTION = 9km|PROJECTION = RECT|GAP_FILL = 0|SEAM_LON = -180.000000|PRECISION=F", L2_Flag_Names = "ATMFAIL,LAND,HILT,HISATZEN,STRAYLIGHT,CLDICE,COCCOLITH,LOWLW,CHLWARN,CHLFAIL,NAVWARN,MAXAERITER,ATMWARN,HISOLZEN,NAVFAIL,FILTER,HIGLINT", Period_Start_Year = 1997S, Period_Start_Day = 247S, Period_End_Year = 1997S, Period_End_Day = 273S, Start_Time = "1997247162633871", End_Time = "1997274055157036", Start_Year = 1997S, Start_Day = 247S, Start_Millisec = 59193871, End_Year = 1997S, End_Day = 274S, End_Millisec = 21117036, Start_Orbit = 519, End_Orbit = 905, Orbit = 712, Map_Projection = "Equidistant Cylindrical", Latitude_Units = "degrees North", Longitude_Units = "degrees East", Northernmost_Latitude = 90.0f, Southernmost_Latitude = -90.0f, Westernmost_Longitude = -180.0f, Easternmost_Longitude = 180.0f, Latitude_Step = 0.083333336f, Longitude_Step = 0.083333336f, SW_Point_Latitude = -89.958336f, SW_Point_Longitude = -179.95833f, Data_Bins = 2750226, Number_of_Lines = 2160, Number_of_Columns = 4320, Parameter = "Chlorophyll a concentration", Measure = "Mean", Units = "mg m^-3", Scaling = "linear", Scaling_Equation = "(Slope*l3m_data) + Intercept = Parameter value", Slope = 1.0f, Intercept = 0.0f, Data_Minimum = 0.00149f, Data_Maximum = 97.93204f, Suggested_Image_Scaling_Minimum = 0.01f, Suggested_Image_Scaling_Maximum = 20.0f, Suggested_Image_Scaling_Type = "LOG", Suggested_Image_Scaling_Applied = "No", _History = "Direct read of HDF4 file through CDM library", HDF4_Version = "4.2.5 (HDF Version 4.2 Release 5, February 17, 2010)"]
        : Product_Name = "S19972441997273.L3m_MO_CHL_chlor_a_9km"
        : Sensor_Name = "SeaWiFS"
        : Sensor = "Sea-viewing Wide Field-of-view Sensor (SeaWiFS)"
        : Title = "SeaWiFS Level-3 Standard Mapped Image"
        : Data_Center = "NASA/GSFC SeaWiFS Data Processing Center"
        : Station_Name = "Wallops Flight Facility"
        : Station_Latitude = 37.9272f
        : Station_Longitude = -75.4753f
        : Mission = "SeaStar SeaWiFS"
        : Mission_Characteristics = "Nominal orbit: inclination = 98.2 (Sun-synchronous); node = 12 noon local (descending); eccentricity = <0.002; altitude = 705 km; ground speed = 6.75 km/sec"
        : Sensor_Characteristics = "Number of bands = 8; number of active bands = 8; wavelengths per band (nm) = 412, 443, 490, 510, 555, 670, 765, 865; bits per pixel = 10; instantaneous field-of-view = 1.5835 mrad; pixels per scan = 1285; scan rate = 6/sec; sample rate = 7710/sec"
        : Product_Type = "other"
        : Processing_Version = "2010.0"
        : Software_Name = "smigen"
        : Software_Version = "4.17"
        : Processing_Time = "2010272172320000"
        : Input_Files = "S19972441997273.L3b_MO_CHL.main"
        : Processing_Control = "smigen par=S19972441997273.L3m_MO_CHL_chlor_a_9km.param"
        : Input_Parameters = "IFILE = /data4/sdpsoper/vdc/vpu3/workbuf/S19972441997273.L3b_MO_CHL.main|OFILE = S19972441997273.L3m_MO_CHL_chlor_a_9km|PFILE = |PROD = chlor_a|PALFILE = DEFAULT|PROCESSING VERSION = 2010.0|MEAS = 1|STYPE = 0|DATAMIN = 0.000000|DATAMAX = 0.000000|LONWEST = -180.000000|LONEAST = 180.000000|LATSOUTH = -90.000000|LATNORTH = 90.000000|RESOLUTION = 9km|PROJECTION = RECT|GAP_FILL = 0|SEAM_LON = -180.000000|PRECISION=F"
        : L2_Flag_Names = "ATMFAIL,LAND,HILT,HISATZEN,STRAYLIGHT,CLDICE,COCCOLITH,LOWLW,CHLWARN,CHLFAIL,NAVWARN,MAXAERITER,ATMWARN,HISOLZEN,NAVFAIL,FILTER,HIGLINT"
        : Period_Start_Year = 1997S
        : Period_Start_Day = 247S
        : Period_End_Year = 1997S
        : Period_End_Day = 273S
        : Start_Time = "1997247162633871"
        : End_Time = "1997274055157036"
        : Start_Year = 1997S
        : Start_Day = 247S
        : Start_Millisec = 59193871
        : End_Year = 1997S
        : End_Day = 274S
        : End_Millisec = 21117036
        : Start_Orbit = 519
        : End_Orbit = 905
        : Orbit = 712
        : Map_Projection = "Equidistant Cylindrical"
        : Latitude_Units = "degrees North"
        : Longitude_Units = "degrees East"
        : Northernmost_Latitude = 90.0f
        : Southernmost_Latitude = -90.0f
        : Westernmost_Longitude = -180.0f
        : Easternmost_Longitude = 180.0f
        : Latitude_Step = 0.083333336f
        : Longitude_Step = 0.083333336f
        : SW_Point_Latitude = -89.958336f
        : SW_Point_Longitude = -179.95833f
        : Data_Bins = 2750226
        : Number_of_Lines = 2160
        : Number_of_Columns = 4320
        : Parameter = "Chlorophyll a concentration"
        : Measure = "Mean"
        : Units = "mg m^-3"
        : Scaling = "linear"
        : Scaling_Equation = "(Slope*l3m_data) + Intercept = Parameter value"
        : Slope = 1.0f
        : Intercept = 0.0f
        : Data_Minimum = 0.00149f
        : Data_Maximum = 97.93204f
        : Suggested_Image_Scaling_Minimum = 0.01f
        : Suggested_Image_Scaling_Maximum = 20.0f
        : Suggested_Image_Scaling_Type = "LOG"
        : Suggested_Image_Scaling_Applied = "No"
        : _History = "Direct read of HDF4 file through CDM library"
        : HDF4_Version = "4.2.5 (HDF Version 4.2 Release 5, February 17, 2010)"
Variations: 1
        float l3m_data(fakeDim0,fakeDim1);
                l3m_data: Fill = -32767.0f
                l3m_data: Scaling = "linear"
                l3m_data: Scaling_Equation = "(Slope*l3m_data) + Intercept = Parameter value"
                l3m_data: Slope = 1.0f
                l3m_data: Intercept = 0.0f


文件信息里有格点投影、起始经纬度、经纬度间隔等信息,利用这些信息在MeteoInfo的脚本编辑器中写一个Jython脚本即可正确打开数据并生成数据图层。修改图例后显示如下:
Image00471.png

脚本代码:
  1. #-----------------------------------------------------
  2. # Author: Yaqiang Wang
  3. # Date: 2013-10-29
  4. # Purpose: Read hdf4 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.projection import ProjectionInfo
  12. from org.meteoinfo.legend import LegendManage
  13. from org.meteoinfo.legend import LegendType
  14. from org.meteoinfo.shape import ShapeTypes
  15. import os.path
  16. import jarray

  17. #Set data directory
  18. dataDir = 'D:/Temp/hdf/'

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

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

  40.         X = jarray.array(xlist, 'd')
  41.         Y = jarray.array(ylist, 'd')
  42.         xDim = Dimension(DimensionType.X)
  43.         xDim.setValues(X)
  44.         dataInfo.setXDimension(xDim)
  45.         yDim = Dimension(DimensionType.Y)
  46.         yDim.setValues(Y)
  47.         dataInfo.setYDimension(yDim)
  48.         var = dataInfo.getVariable('l3m_data')
  49.         dimList = [yDim, xDim]
  50.         var.setDimensions(dimList)
  51.         gData = mdi.getGridData(var.getName())
  52.         gData.yReverse()
  53.         gData.missingValue = -32767.0
  54.         aLS = LegendManage.createLegendSchemeFromGridData(gData, LegendType.GraduatedColor, ShapeTypes.Polygon)
  55.         aLayer = DrawMeteoData.createRasterLayer(gData, "Test_HDF", aLS)
  56.         aLayer.setProjInfo(dataInfo.getProjectionInfo())
  57.         mf = miapp.getMapDocument().getActiveMapFrame()
  58.         mf.addLayer(aLayer)
  59.         mf.moveLayer(aLayer, 0)

  60. print 'Finished!'

评分

参与人数 3金钱 +48 贡献 +16 体力 +80 收起 理由
言深深 + 15 + 5
mofangbao + 15 + 5
Aires + 18 + 6 + 80 很给力!

查看全部评分

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

新浪微博达人勋

发表于 2013-10-30 12:11:43 | 显示全部楼层
膜拜王老师
小A的帖子能让王老师看到好开心
密码修改失败请联系微信:mofangbao
您需要登录后才可以回帖 登录 | 立即注册 新浪微博登陆

本版积分规则

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

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

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