爱气象,爱气象家园! 

气象家园

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博登陆

只需一步, 快速开始

搜索
查看: 12433|回复: 13

[脚本编辑] IBtracs资料 数据,看了家园里的各种帖子还是没搞明白怎么写描述文件,求指导

[复制链接]

新浪微博达人勋

发表于 2015-10-22 15:38:30 | 显示全部楼层 |阅读模式

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

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

x
本帖最后由 洗雨 于 2015-11-21 19:56 编辑

请问通过头文件怎么确定描述文件的初始时间?这种又怎么书写呢?在家园里逛了好久浏览了一些写描述文件的方法,但是当自己写时发现差异较大,所以就无着了,求取各位朋友的解决之道。

netcdf Basin.EP.ibtracs_all.v03r06 {
dimensions:
storm = UNLIMITED ; // (1101 currently)
time = 191 ;
ncharsn = 13 ;
ncharnm = 57 ;
center = 25 ;
ncharcn = 10 ;
variables:
char storm_sn(storm, ncharsn) ;
  storm_sn:long_name = "Storm serial number" ;
char name(storm, ncharnm) ;
  name:long_name = "Storm name" ;
short numObs(storm) ;
  numObs:long_name = "Number of observations for the storm" ;
short season(storm) ;
  season:long_name = "Year based on season" ;
  season:Note = "Following WMO,\n",
   "NH Seasons begin 1 January and \n",
   "SH Seasons begin 1 July the prior year" ;
byte track_type(storm) ;
  track_type:long_name = "Track type" ;
  track_type:key = "0 = main - cyclogenesis to cyclolysis\n",
   "1 = merge - cyclogenesis to merger\n",
   "2 = split - split to cyclolysis\n",
   "3 = other - split to merger" ;
byte genesis_basin(storm) ;
  genesis_basin:long_name = "Basin of genesis" ;
  genesis_basin:units = " " ;
  genesis_basin:key = "0 = NA - North Atlantic\n",
   "1 = SA - South Atlantic\n",
   "2 = WP - West Pacific\n",
   "3 = EP - East Pacific\n",
   "4 = SP - South Pacific\n",
   "5 = NI - North Indian\n",
   "6 = SI - South Indian\n",
   "7 = AS - Arabian Sea\n",
   "8 = BB - Bay of Bengal\n",
   "9 = EA - Eastern Australia\n",
   "10 = WA - Western Australia\n",
   "11 = CP - Central Pacific\n",
   "12 = CS - Carribbean Sea\n",
   "13 = GM - Gulf of Mexico\n",
   "14 = MM - Missing" ;
  genesis_basin:Note = "Based on where the storm began" ;
byte num_basins(storm) ;
  num_basins:long_name = "Number of basins through which the storm passes" ;
  num_basins:units = " " ;
byte basin(storm, time) ;
  basin:long_name = "Basin" ;
  basin:units = " " ;
  basin:key = "0 = NA - North Atlantic\n",
   "1 = SA - South Atlantic\n",
   "2 = WP - West Pacific\n",
   "3 = EP - East Pacific\n",
   "4 = SP - South Pacific\n",
   "5 = NI - North Indian\n",
   "6 = SI - South Indian\n",
   "7 = AS - Arabian Sea\n",
   "8 = BB - Bay of Bengal\n",
   "9 = EA - Eastern Australia\n",
   "10 = WA - Western Australia\n",
   "11 = CP - Central Pacific\n",
   "12 = CS - Carribbean Sea\n",
   "13 = GM - Gulf of Mexico\n",
   "14 = MM - Missing" ;
  basin:Note = "Based on present location" ;
  basin:_FillValue = -127b ;
byte wind_avg_period(center) ;
  wind_avg_period:long_name = "Wind speed averaging period" ;
  wind_avg_period:units = "min" ;
  wind_avg_period:_FillValue = -127b ;
char source(center, ncharcn) ;
  source:long_name = "Source name" ;
  source:Note = "This order matches the dimension in source_* variables" ;
double source_time(storm, time) ;
  source_time:long_name = "Modified Julian Day" ;
  source_time:units = "days since 1858-11-17 00:00:00" ;
  source_time:_FillValue = -99999. ;
short lat_for_mapping(storm, time) ;
  lat_for_mapping:long_name = "Latitude for mapping purposes only" ;
  lat_for_mapping:units = "degrees_north" ;
  lat_for_mapping:scale_factor = 0.01f ;
  lat_for_mapping:_FillValue = -32767s ;
short lon_for_mapping(storm, time) ;
  lon_for_mapping:long_name = "Longitude for mapping purposes only" ;
  lon_for_mapping:units = "degrees_east" ;
  lon_for_mapping:scale_factor = 0.01f ;
  lon_for_mapping:_FillValue = -32767s ;
byte nature_for_mapping(storm, time) ;
  nature_for_mapping:long_name = "Storm nature" ;
  nature_for_mapping:key = "0 = TS - Tropical\n",
   "1 = SS - Subtropical\n",
   "2 = ET - Extratropical\n",
   "3 = DS - Disturbance\n",
   "4 = MX - Mix of conflicting reports\n",
   "5 = NR - Not Reported\n",
   "6 = MM - Missing\n",
   "7 =  - Missing" ;
  nature_for_mapping:Note = "Based on classification from original sources" ;
  nature_for_mapping:_FillValue = -127b ;
short source_lat(storm, time, center) ;
  source_lat:long_name = "Storm center latitude" ;
  source_lat:units = "degrees_north" ;
  source_lat:scale_factor = 0.01f ;
  source_lat:source = "hurdat_atl td9636 reunion atcf ds824_sh ds824_ni bom ds824_au jtwc_sh jtwc_wp td9635 ds824_wp jtwc_io cma hurdat_epa jtwc_ep ds824_ep jtwc_cp tokyo neumann hko cphc wellington newdelhi nadi" ;
  source_lat:_FillValue = -30000s ;
short source_lon(storm, time, center) ;
  source_lon:long_name = "Storm center longitude" ;
  source_lon:units = "degrees_east" ;
  source_lon:scale_factor = 0.01f ;
  source_lon:source = "hurdat_atl td9636 reunion atcf ds824_sh ds824_ni bom ds824_au jtwc_sh jtwc_wp td9635 ds824_wp jtwc_io cma hurdat_epa jtwc_ep ds824_ep jtwc_cp tokyo neumann hko cphc wellington newdelhi nadi" ;
  source_lon:_FillValue = -30000s ;
short source_wind(storm, time, center) ;
  source_wind:long_name = "Maximum Sustained Wind (MSW)" ;
  source_wind:units = "kt" ;
  source_wind:scale_factor = 0.1f ;
  source_wind:source = "hurdat_atl td9636 reunion atcf ds824_sh ds824_ni bom ds824_au jtwc_sh jtwc_wp td9635 ds824_wp jtwc_io cma hurdat_epa jtwc_ep ds824_ep jtwc_cp tokyo neumann hko cphc wellington newdelhi nadi" ;
  source_wind:_FillValue = -9990s ;
short source_pres(storm, time, center) ;
  source_pres:long_name = "Minimum Central Pressure (MCP)" ;
  source_pres:units = "mb" ;
  source_pres:scale_factor = 0.1f ;
  source_pres:source = "hurdat_atl td9636 reunion atcf ds824_sh ds824_ni bom ds824_au jtwc_sh jtwc_wp td9635 ds824_wp jtwc_io cma hurdat_epa jtwc_ep ds824_ep jtwc_cp tokyo neumann hko cphc wellington newdelhi nadi" ;
  source_pres:_FillValue = -9990s ;
short dist2land(storm, time) ;
  dist2land:long_name = "Distance to land" ;
  dist2land:units = "km" ;
  dist2land:_FillValue = -999s ;
short landfall(storm, time) ;
  landfall:long_name = "Minimum distance to land until next report (0=landfall)" ;
  landfall:units = "km" ;
  landfall:_FillValue = -999s ;
// global attributes:
  :Title = "IBTrACS-WMO: NetCDF reformat" ;
  :Version = "v03r06" ;
  :Description = "IBTrACS-WMO data reformatted to contain \n",
   "all data in one netCDF file. Also an attempt has been made\n",
   "to have the data appear as trajectories in the CDM" ;
  :cdm_datatype = "Trajectory" ;
  :trajectoryDimension = "storm" ;
  :Conventions = "CF-1.0" ;
  :metadata_link = "gov.noaa.ncdc:C00834" ;
}



numObs(storm) 0 99 Number of observations for the storm
season(storm) 0 99 Year based on season
lat_for_mapping(storm, time) 0 99 Latitude for mapping purposes only -32767s 0.01f
lon_for_mapping(storm, time) 0 99 Longitude for mapping purposes only -32767s 0.01f
source_lat(storm, time, center) 0 99 Storm center latitude north -30000s 0.01f
source_lon(storm, time, center) 0 99 Storm center longitude -30000s 0.01f
source_wind(storm, time, center) 0 99 Maximum Sustained Wind (MSW)[kt]-9990s 0.1f
source_pres(storm, time, center) 0 99 Minimum Central Pressure (MCP)[mb]-9990s 0.1f
dist2land(storm, time) 0 99 Distance to land[km]-999s
landfall(storm, time) 0 99 Minimum distance to land until next report (0=landfall)[km]-999s
這几个应该是变量,其中维数环境参量应该是storm,time,center,但是grads的维数环境好像都是x,y,z,t等,在这头文件没搞明白其xyt的时间增量应该怎么设置!
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2015-10-22 16:16:37 | 显示全部楼层
这种数据估计GrADS很难处理
密码修改失败请联系微信:mofangbao

新浪微博达人勋

 楼主| 发表于 2015-10-22 20:19:11 | 显示全部楼层
MeteoInfo 发表于 2015-10-22 16:16
这种数据估计GrADS很难处理

搞几天,浏览了很多的描述方法,就没有这种类型的头文件写描述文件的,试过都搞不出来,感觉希望渺茫,老师的提醒坚定我换个方法换个软件试一试,谢谢
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2015-10-22 21:13:52 | 显示全部楼层
6666666666666
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2015-10-22 22:45:09 | 显示全部楼层
洗雨 发表于 2015-10-22 20:19
搞几天,浏览了很多的描述方法,就没有这种类型的头文件写描述文件的,试过都搞不出来,感 ...

可以参考此贴:MeteoInfoLab脚本示例:台风和热带气旋
http://bbs.06climate.com/forum.p ... 985&fromuid=106
(出处: 气象家园)
密码修改失败请联系微信:mofangbao

新浪微博达人勋

 楼主| 发表于 2015-10-23 15:16:21 | 显示全部楼层
MeteoInfo 发表于 2015-10-22 22:45
可以参考此贴:MeteoInfoLab脚本示例:台风和热带气旋
http://bbs.06climate.com/forum.php?mod=viewthr ...

谢谢老师,先看看
密码修改失败请联系微信:mofangbao

新浪微博达人勋

 楼主| 发表于 2015-11-21 19:52:24 | 显示全部楼层
本帖最后由 洗雨 于 2015-11-21 19:59 编辑

! read ibtracs data--basin style

character*200:: path
character*200:: filename
character*3000 :: fline
integer :: L,Nv
integer:: i,j,iv
character*30,allocatable :: fvar(:)
integer :: NUM


path='J:\sst\IBTracks\csv\'
filename=TRIM(path)//'Basin.NI.ibtracs_all.v03r06.csv'
! + open file
open(unit=11,file=TRIM(fname),status='old')
! + open over

! + read head information
read(11,*)
read(11,'(A3000)')fline
read(11,*)

! + read variations
L=LEN_TRIM(fline)
Nv=1
do i=1,L
           if ( fline(i:i).eq.',' ) Nv=Nv+1
enddo
!write(*,*)'Nv=',Nv
allocate(fvar(Nv))

call cal_sub(fline,Nv,fvar)

deallocate(fvar)

! + read data
NUM=0 !TC number

data(seq(i,1),i=1,5) / 65, 66, 67, 68, 69/ ! - jtwc_wp
data(seq(i,2),i=1,5) /120,121,122,123,124/ ! - hko
data(seq(i,3),i=1,5) /110,111,112,113,114/ ! - tokyo
data(seq(i,4),i=1,5) / 85, 86, 87, 88, 89/ ! - cma



!
! + SUBROUTINES
!
subroutine cal_sub(fline,Nv,fvar)
implicit none


character*3000 :: fline
integer :: Nv
character*30 :: fvar(Nv)
integer :: i,j,iv,L


L=LEN_TRIM(fline)
iv=1
j=1
do i=1,L
        if ( fline(i:i).eq.',' ) then
                fvar(iv)=fline(j:i-1)
                iv=iv+1
                j=i+1
        endif
enddo
if ( iv.ne.Nv ) write(*,*) 'ERROR'
fvar(iv)=fline(j:L)


return
end



subroutine read_ibtracs(fname,year,NUM,NREC,TCNAME,DAT,INF)
implicit none


character*300 :: fname
integer :: year
logical :: flag
character*3000 :: fline
integer :: L,Nv
integer :: i,j,iv
character*30,allocatable :: fvar(:)
integer :: yr,id,id0
character*30 :: name
integer :: dat0(4)
real :: inf0(5,4)
integer :: seq(5,4)
integer,parameter :: TCMax=100,RECMax=300
integer :: NUM
integer :: NREC(TCMax)
character*30 :: TCNAME(TCMax)
integer :: DAT(4,RECMax,TCMax)
real :: INF(5,RECMax,TCMax,4)



! + FILE
inquire(file=TRIM(fname),exist=flag)
if ( .not.flag ) then
        write(*,*) TRIM(fname),' does not exist!'
        STOP
endif


! + READ HEAD INFORMATION
open(unit=31,file=TRIM(fname),status='old',action='read')
read(31,*)
read(31,'(A3000)') fline
read(31,*)


! + VARIABLES
L=LEN_TRIM(fline)
Nv=1
do i=1,L
        if ( fline(i:i).eq.',' ) Nv=Nv+1
enddo
!write(*,*) 'Nv= ',Nv
allocate(fvar(Nv))
!iv=1
!j=1
!do i=1,L
!        if ( fline(i:i).eq.',' ) then
!                fvar(iv)=fline(j:i-1)
!                iv=iv+1
!                j=i+1
!        endif
!enddo
!if ( iv.ne.Nv ) write(*,*) 'ERROR'
!fvar(iv)=fline(j:L)
call cal_sub(fline,Nv,fvar)
!open(unit=41,file='var_list.txt',status='unknown',action='write')
!do iv=1,Nv
!        L=LEN_TRIM(fvar(iv))
!        write(41,'(I3.3,3X,A<L>)') iv,TRIM(fvar(iv))
!enddo
!close(41)
deallocate(fvar)


! + READ DATA
NUM=0
id0=0
data(seq(i,1),i=1,5) / 65, 66, 67, 68, 69/ ! - jtwc_wp
data(seq(i,2),i=1,5) /120,121,122,123,124/ ! - hko
data(seq(i,3),i=1,5) /110,111,112,113,114/ ! - tokyo
data(seq(i,4),i=1,5) / 85, 86, 87, 88, 89/ ! - cma
do while ( .not.EOF(31) )
        read(31,'(A3000)') fline
        allocate(fvar(Nv))
        call cal_sub(fline,Nv,fvar)

        read(fvar(2),*) yr        ! - Season
        read(fvar(3),*) id        ! - Num
        name=fvar(6)                ! - Name
        L=LEN_TRIM(fvar(7))        ! - ISO_time
        if ( L.ne.19 ) write(*,*) 'ERROR ISO-TIME'
        read(fvar(7)(1:L),'(I4,1X,I2,1X,I2,1X,I2,6X)') (dat0(i),i=1,4)
        do j=1,4
                do i=1,5
                        read(fvar(seq(i,j)),*) inf0(i,j)        ! - lat, lon, grade, wind, pres
                enddo
        enddo

        if ( yr.eq.year ) then
                if ( id.ne.id0 ) then
                        NUM=NUM+1
                        id0=id
                        NREC(NUM)=0
                        TCNAME(NUM)=name
                endif
                if ( MOD(dat0(4),6).eq.0 ) then
                        NREC(NUM)=NREC(NUM)+1
                        do i=1,4
                                DAT(i,NREC(NUM),NUM)=dat0(i)
                        enddo
                        do j=1,4
                                do i=1,5
                                        INF(i,NREC(NUM),NUM,j)=inf0(i,j)
                                enddo
                        enddo
                endif
        endif
        deallocate(fvar)
enddo


close(31)


return
end


!
! + SUBROUTINES
!
subroutine cal_sub(fline,Nv,fvar)
implicit none


character*3000 :: fline
integer :: Nv
character*30 :: fvar(Nv)
integer :: i,j,iv,L


L=LEN_TRIM(fline)
iv=1
j=1
do i=1,L
        if ( fline(i:i).eq.',' ) then
                fvar(iv)=fline(j:i-1)
                iv=iv+1
                j=i+1
        endif
enddo
if ( iv.ne.Nv ) write(*,*) 'ERROR'
fvar(iv)=fline(j:L)


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

新浪微博达人勋

 楼主| 发表于 2015-11-21 19:58:07 | 显示全部楼层
本帖最后由 洗雨 于 2015-11-21 20:35 编辑

! read ibtracs data--basin style IBtracs数据的csv格式读取
character*200:: path
character*200:: filename
character*3000 :: fline
integer :: L,Nv
integer:: i,j,iv
character*30,allocatable :: fvar(:)
integer :: NUM

path='J:\sst\IBTracks\csv\'
filename=TRIM(path)//'Basin.NI.ibtracs_all.v03r07.csv'
! + open file
open(unit=11,file=TRIM(fname),status='old')
! + open over
! + read head information
read(11,*)
read(11,'(A3000)')fline
read(11,*)
! + read variations
L=LEN_TRIM(fline)
Nv=1
do i=1,L
    if ( fline(i:i).eq.',' ) Nv=Nv+1
enddo
!write(*,*)'Nv=',Nv
allocate(fvar(Nv))
call cal_sub(fline,Nv,fvar)
deallocate(fvar)
! + read data
NUM=0 !TC number
data(seq(i,1),i=1,5) / 65, 66, 67, 68, 69/ ! - jtwc_wp
data(seq(i,2),i=1,5) /120,121,122,123,124/ ! - hko
data(seq(i,3),i=1,5) /110,111,112,113,114/ ! - tokyo
data(seq(i,4),i=1,5) / 85, 86, 87, 88, 89/ ! - cma

!
! + SUBROUTINES
!
subroutine cal_sub(fline,Nv,fvar)
implicit none

character*3000 :: fline
integer :: Nv
character*30 :: fvar(Nv)
integer :: i,j,iv,L

L=LEN_TRIM(fline)
iv=1
j=1
do i=1,L
if ( fline(i:i).eq.',' ) then
  fvar(iv)=fline(j:i-1)
  iv=iv+1
  j=i+1
endif
enddo
if ( iv.ne.Nv ) write(*,*) 'ERROR'
fvar(iv)=fline(j:L)

return
end

subroutine read_ibtracs(fname,year,NUM,NREC,TCNAME,DAT,INF)
implicit none

character*300 :: fname
integer :: year
logical :: flag
character*3000 :: fline
integer :: L,Nv
integer :: i,j,iv
character*30,allocatable :: fvar(:)
integer :: yr,id,id0
character*30 :: name
integer :: dat0(4)
real :: inf0(5,4)
integer :: seq(5,4)
integer,parameter :: TCMax=100,RECMax=300
integer :: NUM
integer :: NREC(TCMax)
character*30 :: TCNAME(TCMax)
integer :: DAT(4,RECMax,TCMax)
real :: INF(5,RECMax,TCMax,4)

! + FILE
inquire(file=TRIM(fname),exist=flag)
if ( .not.flag ) then
write(*,*) TRIM(fname),' does not exist!'
STOP
endif

! + READ HEAD INFORMATION
open(unit=31,file=TRIM(fname),status='old',action='read')
read(31,*)
read(31,'(A3000)') fline
read(31,*)

! + VARIABLES
L=LEN_TRIM(fline)
Nv=1
do i=1,L
if ( fline(i:i).eq.',' ) Nv=Nv+1
enddo
!write(*,*) 'Nv= ',Nv
allocate(fvar(Nv))
!iv=1
!j=1
!do i=1,L
! if ( fline(i:i).eq.',' ) then
!  fvar(iv)=fline(j:i-1)
!  iv=iv+1
!  j=i+1
! endif
!enddo
!if ( iv.ne.Nv ) write(*,*) 'ERROR'
!fvar(iv)=fline(j:L)
call cal_sub(fline,Nv,fvar)
!open(unit=41,file='var_list.txt',status='unknown',action='write')
!do iv=1,Nv
! L=LEN_TRIM(fvar(iv))
! write(41,'(I3.3,3X,A<L>)') iv,TRIM(fvar(iv))
!enddo
!close(41)
deallocate(fvar)

! + READ DATA
NUM=0
id0=0
data(seq(i,1),i=1,5) / 65, 66, 67, 68, 69/ ! - jtwc_wp
data(seq(i,2),i=1,5) /120,121,122,123,124/ ! - hko
data(seq(i,3),i=1,5) /110,111,112,113,114/ ! - tokyo
data(seq(i,4),i=1,5) / 85, 86, 87, 88, 89/ ! - cma
do while ( .not.EOF(31) )
read(31,'(A3000)') fline
allocate(fvar(Nv))
call cal_sub(fline,Nv,fvar)
read(fvar(2),*) yr ! - Season
read(fvar(3),*) id ! - Num
name=fvar(6)  ! - Name
L=LEN_TRIM(fvar(7)) ! - ISO_time
if ( L.ne.19 ) write(*,*) 'ERROR ISO-TIME'
read(fvar(7)(1:L),'(I4,1X,I2,1X,I2,1X,I2,6X)') (dat0(i),i=1,4)
do j=1,4
  do i=1,5
   read(fvar(seq(i,j)),*) inf0(i,j) ! - lat, lon, grade, wind, pres
  enddo
enddo
if ( yr.eq.year ) then
  if ( id.ne.id0 ) then
   NUM=NUM+1
   id0=id
   NREC(NUM)=0
   TCNAME(NUM)=name
  endif
  if ( MOD(dat0(4),6).eq.0 ) then
   NREC(NUM)=NREC(NUM)+1
   do i=1,4
    DAT(i,NREC(NUM),NUM)=dat0(i)
   enddo
   do j=1,4
    do i=1,5
     INF(i,NREC(NUM),NUM,j)=inf0(i,j)
    enddo
   enddo
  endif
endif
deallocate(fvar)
enddo

close(31)

return
end

!
! + SUBROUTINES
!
subroutine cal_sub(fline,Nv,fvar)
implicit none

character*3000 :: fline
integer :: Nv
character*30 :: fvar(Nv)
integer :: i,j,iv,L

L=LEN_TRIM(fline)
iv=1
j=1
do i=1,L
if ( fline(i:i).eq.',' ) then
  fvar(iv)=fline(j:i-1)
  iv=iv+1
  j=i+1
endif
enddo
if ( iv.ne.Nv ) write(*,*) 'ERROR'
fvar(iv)=fline(j:L)

return
end

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

新浪微博达人勋

发表于 2019-12-3 22:20:18 | 显示全部楼层
楼主有用过ncl处理IBTrACS的数据吗?
密码修改失败请联系微信:mofangbao
回复 支持 反对

使用道具 举报

新浪微博达人勋

 楼主| 发表于 2019-12-5 18:00:06 | 显示全部楼层
fey 发表于 2019-12-3 22:20
楼主有用过ncl处理IBTrACS的数据吗?

没有用NCL处理过
密码修改失败请联系微信:mofangbao
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册 新浪微博登陆

本版积分规则

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

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

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