- 积分
- 1323
- 贡献
-
- 精华
- 在线时间
- 小时
- 注册时间
- 2011-8-5
- 最后登录
- 1970-1-1
|
登录后查看更多精彩内容~
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
请教各位懂GPF文件的帮帮忙!我是本科生,第一次编程!读二进制文件有些困难!
大家看看我这么写对不对,读出来的数据是不是正确的~
程序如下:
Program main
Implicit None
Integer*4 :: ChIndex,start1,start2
character(len=12)::chname
Character(Len=2) ::fid
real*4 :: dingbiao(1024)
real*4 :: FYdata(804*601) !!!!通道数据只占两个字节!!!!!!!!!!!!
integer*2 ver,sid,yer,mon,day,hor,min,chn,pjt,wid,hei
real*4 lonres,latres,stdlat1,stdlat2,r,minlat,maxlat,minlon,maxlon,ltlon,ltlat,rtlon,rtlat,lblon,lblat,rblon,rblat,stdlon,clon,clat,PLonRes,PLatRes
Open(12,File = 'FY2E_2011_06_25_00_01_E_PJ3.gpf',Form = 'binary',recl=2) !通道数据算法
open(13,File = 'FY2E_2011_06_25_00_01_E_PJ3.dat',Form = 'binary',recl=4) !定标数据算法
open(10,File = '定标表数据.txt')
open(20,File = '通道数据.txt')
open(1,File = 'Title文件.txt')
!!!!!!程序功能说明!!
write(*,*) "-------------------------------------------------------------------------------"
write(*,*) "本程序用于从FY-2EGPF文件中读出Title,并将选择通道的定标表和观测数据写入相应文件"
write(*,*) "-------------------------------------------------------------------------------"
!!!!!!探测通道选择!!
!!!recl=4
!rec
!IR1 513-1536 IR2 1537-2560 IR3 2561-3584 IR4 3585-4608
!VI1 4609-5632 VI2 5633-6656 VI3 6657-7680 VI4 7681-8704
!!!问题????????可见光通道为什么四个???通道数据里只有一个吗?????????
!!!???????????????????????????????????????????????????????????????????????????????????
write(*,*) "请选择通道索引:IR1 1;IR2 2;IR3 3;IR4 4;VIS 5 "
write(*,*) " (暂时只支持IR1-4通道,更多支持需后期修改!)"
read(*,*) ChIndex
100 if(Chindex==1)then
chname='IR1 红外一'
start1=513
start2=17409
elseif(Chindex==2)then
chname='IR2 红外二'
start1=1537
start2=17409+804*601
elseif(chindex==3)then
chname='IR3 水汽通道'
start1=2561
start2=17409+804*601*2
elseif(chindex==4)then
chname='IR4 短波红外'
start1=3585
start2=17409+804*601*3
elseif(chindex==5)then
chname='VIS 可见光'
start1=4609
start2=17409+804*601*4
!!!!!!!可见光要更改recl!!!!!
else
print*,"通道不存在,请重新输入!" !!程序能够对重新输入的通道索引进行识别,直到输出正确的索引为止!!
read(*,*) chindex
goto 100
endif
!!!!!!!!!!!!!!!!!!!!!!!!!
!!每个变量占两个字节!!
Read( 12 , Rec=1) fid
Read( 12 , Rec=2) ver !1
Read( 12 , Rec=3) sid
Read( 12 , Rec=4) yer !2
Read( 12 , Rec=5) mon
Read( 12 , Rec=6) day !3
Read( 12 , Rec=7) hor
Read( 12 , Rec=8) min !4
Read( 12 , Rec=9) chn
Read( 12 , Rec=10) pjt !5
Read( 12 , Rec=11) wid
Read( 12 , Rec=12) hei !6
!!每个变量占四个字节!!
read(13,rec=7) lonres !7
read(13,rec=8) latres
read(13,rec=9) stdlat1
read(13,rec=10) stdlat2
read(13,rec=11) r
read(13,rec=12) minlat
read(13,rec=13) maxlat
read(13,rec=14) minlon
read(13,rec=15) maxlon
read(13,rec=16) ltlat
read(13,rec=17) ltlon
read(13,rec=18) rtlat
read(13,rec=19) rtlon
read(13,rec=20) lblat
read(13,rec=21) lblon
read(13,rec=22) rblat
read(13,rec=23) rblon
read(13,rec=24) stdlon
read(13,rec=25) clon
read(13,rec=26) clat !!104字节
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!BYTE ucChIndex[128]; //104+128=232,通道索引:红外1 为1,红外2 为2,//红外3 为3,红外4 为4,可见光为5!!!
!! 通道索引暂时没有读取 !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
read(13,rec=59) PLonRes !!236字节
read(13,rec=60) PLatRes!!240字节
!!2048字节对应为rec=512!!
!!!投影数据头结束!!!
write(*,*) "------------------------------------------------------------------------------"
write(*,*) "Title"
write(*,*) "------------------------------------------------------------------------------"
Write(*,*) "文件标号 " ,fid
write(*,*) "版本号 ",ver
write(*,*) "卫星标识",sid
write(*,*) "开始扫描时间:年",yer
write(*,*) "开始扫描时间:月",mon
write(*,*) "开始扫描时间:日",day
write(*,*) "开始扫描时间:时",hor
write(*,*) "开始扫描时间:分",min
write(*,*) "通道数目",chn
write(*,*) "投影方式",pjt
write(*,*) "宽度",wid
write(*,*) "高度",hei
write(*,*) "投影展开面上中心点像素对应的地球点的分辨",lonres
write(*,*) "投影展开面上中心点像素对应的地球点的分辨",latres
write(*,*) "标准纬度1",stdlat1
write(*,*) "标准纬度2",stdlat2
write(*,*) "地球半径",r
write(*,*) "投影范围最小纬度",minlat
write(*,*) "投影范围最大纬度",maxlat
write(*,*) "投影范围最小经度",minlon
write(*,*) "投影范围最大经度",maxlon
write(*,*) "左上角纬度",ltlat
write(*,*) "左上角经度",ltlon
write(*,*) "右上角纬度",rtlat
write(*,*) "右上角经度",rtlon
write(*,*) "左下角纬度",lblat
write(*,*) "左下角经度",lblon
write(*,*) "右下角纬度",rblat
write(*,*) "右下角经度",rblon
write(*,*) "标准经度(中心经度)",stdlon
write(*,*) "中心经度",clon
write(*,*) "中心纬度",clat
write(*,*) "探测通道 ",chname !!!!程序要求输入不同通道索引之后能够提取出相应通道的(定标表)和(通道数据)
write(*,*) "投影展开面的经向分辨率",PLonRes
write(*,*) "投影展开面的纬向分辨率",PLatRes
write(*,*) "------------------------------------------------------------------------------"
!!!
write(1,*) "------------------------------------------------------------------------------"
write(1,*) "Title"
write(1,*) "------------------------------------------------------------------------------"
Write(1,*) "文件标号 " ,fid
write(1,*) "版本号 ",ver
write(1,*) "卫星标识",sid
write(1,*) "开始扫描时间:年",yer
write(1,*) "开始扫描时间:月",mon
write(1,*) "开始扫描时间:日",day
write(1,*) "开始扫描时间:时",hor
write(1,*) "开始扫描时间:分",min
write(1,*) "通道数目",chn
write(1,*) "投影方式",pjt
write(1,*) "宽度",wid
write(1,*) "高度",hei
write(1,*) "投影展开面上中心点像素对应的地球点的分辨",lonres
write(1,*) "投影展开面上中心点像素对应的地球点的分辨",latres
write(1,*) "标准纬度1",stdlat1
write(1,*) "标准纬度2",stdlat2
write(1,*) "地球半径",r
write(1,*) "投影范围最小纬度",minlat
write(1,*) "投影范围最大纬度",maxlat
write(1,*) "投影范围最小经度",minlon
write(1,*) "投影范围最大经度",maxlon
write(1,*) "左上角纬度",ltlat
write(1,*) "左上角经度",ltlon
write(1,*) "右上角纬度",rtlat
write(1,*) "右上角经度",rtlon
write(1,*) "左下角纬度",lblat
write(1,*) "左下角经度",lblon
write(1,*) "右下角纬度",rblat
write(1,*) "右下角经度",rblon
write(1,*) "标准经度(中心经度)",stdlon
write(1,*) "中心经度",clon
write(1,*) "中心纬度",clat
write(1,*) "探测通道 ",chname !!!!程序要求输入不同通道索引之后能够提取出相应通道的(定标表)和(通道数据)
write(1,*) "投影展开面的经向分辨率",PLonRes
write(1,*) "投影展开面的纬向分辨率",PLatRes
write(1,*) "------------------------------------------------------------------------------"
!!!
!!!!读定标表!!占四个字节!!
read(13,rec=start1) dingbiao
!!!!写定标表
write(*,*) "定标表:"
write(*,*) "------------------------------------------------------------------------------"
write(*,*) dingbiao
write(10,*) dingbiao
write(*,*) "定标数据读取完成……"
pause
!!!!读通道数据!!IR占两个字节,VIS占一个字节!!
read(12,rec=start2) FYdata
!!!!写通道数据
write(*,*) "------------------------------------------------------------------------------"
write(*,*) "通道数据:"
write(*,*) "------------------------------------------------------------------------------"
write(*,*) FYdata
write(*,*) "------------------------------------------------------------------------------"
write(*,*) "定标数据和通道数据已提取成功!谢谢使用!By 张庆"
Close(12)
close(13)
close(10)
End Program main
|
|