爱气象,爱气象家园! 

气象家园

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博登陆

只需一步, 快速开始

搜索
查看: 4810|回复: 3

MeteoInfoLab脚本示例:FY2 gpf格式数据

[复制链接]

新浪微博达人勋

发表于 2016-5-16 10:12:47 | 显示全部楼层 |阅读模式

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

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

x
本帖最后由 MeteoInfo 于 2016-5-16 10:36 编辑

FY2C-E的gpf格式是二进制数据,由数据头、定标表、通道数据三部分组成,这里给出一个FY2E gpf文件(经纬度投影)读取、绘图的示例程序。先利用Python读取二进制数据文件的功能读取文件头中相关信息,然后利用MeteoInfoLab的binread函数读取通道数据至二维数组,再绘图。

  1. import struct

  2. fn = 'D:/Temp/binary/FY2E_2011_06_25_00_01_E_PJ3.gpf'

  3. #Read data header parameters
  4. f = open(fn, 'rb')
  5. fileid, = struct.unpack('2s', f.read(2))
  6. version, = struct.unpack('<h', f.read(2))
  7. satid, = struct.unpack('<h', f.read(2))
  8. year, = struct.unpack('<h', f.read(2))
  9. month, = struct.unpack('<h', f.read(2))
  10. day, = struct.unpack('<h', f.read(2))
  11. hour, = struct.unpack('<h', f.read(2))
  12. minute, = struct.unpack('<h', f.read(2))
  13. chnums, = struct.unpack('<h', f.read(2))
  14. pjtype, = struct.unpack('<h', f.read(2))
  15. width, = struct.unpack('<h', f.read(2))
  16. height, = struct.unpack('<h', f.read(2))
  17. clonres, = struct.unpack('<f', f.read(4))
  18. clatres, = struct.unpack('<f', f.read(4))
  19. stdlat1, = struct.unpack('<f', f.read(4))
  20. stdlat2, = struct.unpack('<f', f.read(4))
  21. earthr, = struct.unpack('<f', f.read(4))
  22. minlat, = struct.unpack('<f', f.read(4))
  23. maxlat, = struct.unpack('<f', f.read(4))
  24. minlon, = struct.unpack('<f', f.read(4))
  25. maxlon, = struct.unpack('<f', f.read(4))
  26. ltlat, = struct.unpack('<f', f.read(4))
  27. ltlon, = struct.unpack('<f', f.read(4))
  28. rtlat, = struct.unpack('<f', f.read(4))
  29. rtlon, = struct.unpack('<f', f.read(4))
  30. lblat, = struct.unpack('<f', f.read(4))
  31. lblon, = struct.unpack('<f', f.read(4))
  32. rblat, = struct.unpack('<f', f.read(4))
  33. rblon, = struct.unpack('<f', f.read(4))
  34. stdlon, = struct.unpack('<f', f.read(4))
  35. centerlon, = struct.unpack('<f', f.read(4))
  36. centerlat, = struct.unpack('<f', f.read(4))
  37. chindex = []
  38. for i in range(chnums):
  39.     chindex.append(struct.unpack('b', f.read(1))[0])
  40. f.read(128 - chnums)
  41. plonres, = struct.unpack('<f', f.read(4))
  42. platres, = struct.unpack('<f', f.read(4))
  43. f.read(1808)

  44. #Read calibration table
  45. f.read(32768)

  46. f.close()

  47. #Read one channel data
  48. cn = 1    #Infrared channel 1
  49. skipn = 2048 + 32768
  50. for i in range(1, cn):
  51.     if chindex[i-1] < 5:    #Infrared channel
  52.         byten = 2
  53.     else:
  54.         byten = 1    #Visible light channel
  55.     skipn += width * height * byten
  56. if cn < 5:
  57.     data = binread(fn, [height, width], 'short', skip=skipn)
  58. else:
  59.     data = binread(fn, [height, width], 'byte', skip=skipn)
  60. data = data[::-1,:]
  61. lon = linspace(ltlon, rtlon, width)
  62. lat = linspace(lblat, ltlat, height)

  63. #Plot
  64. axesm()
  65. lworld = shaperead('D:/Temp/Map/country1.shp')
  66. lchina = shaperead('D:/Temp/Map/bou2_4p.shp')
  67. geoshow(lchina, edgecolor='b')
  68. geoshow(lworld, edgecolor='b')
  69. cmap = 'MPL_gist_gray'
  70. layer = imshowm(lon, lat, data, 20, cmap=cmap)
  71. colorbar(layer)
  72. t = datetime.datetime(year, month, day, hour, minute)
  73. title('FY2E (' + t.strftime('%Y-%m-%d') + ')')


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

新浪微博达人勋

发表于 2016-10-2 22:44:52 | 显示全部楼层
王老师,您好!通过您的这些帖子,收获很多,我现在也在不断的学习MeteoInfo并将其作为新的工具,现在有个问题向您请教:将两种类型的数据如何画在同一张图上,MeteInlab脚本该怎么写呢?比如卫星云图和降水量叠加图或者闪电定位和云图叠加等等,能不能给我们这些刚入门的小白一个关于上述MeteInlab脚本示例,让我们不停的去摸索?最后,祝您和家园的各位朋友节日快乐!!!
密码修改失败请联系微信:mofangbao

新浪微博达人勋

 楼主| 发表于 2016-10-3 11:18:20 | 显示全部楼层
wuwei2163 发表于 2016-10-2 22:44
王老师,您好!通过您的这些帖子,收获很多,我现在也在不断的学习MeteoInfo并将其作为新的工具,现在有个 ...

参考此贴:http://bbs.06climate.com/forum.p ... &extra=page%3D1
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2016-10-8 16:54:35 | 显示全部楼层
MeteoInfo 发表于 2016-10-3 11:18
参考此贴:http://bbs.06climate.com/forum.php?mod=viewthread&tid=44833&extra=page%3D1

谢谢王老师,准备好好去研究了
密码修改失败请联系微信:mofangbao
您需要登录后才可以回帖 登录 | 立即注册 新浪微博登陆

本版积分规则

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

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

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