爱气象,爱气象家园! 

气象家园

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博登陆

只需一步, 快速开始

搜索
查看: 3958|回复: 7

[求助] barnes滤波

[复制链接]

新浪微博达人勋

发表于 2017-2-15 16:36:52 | 显示全部楼层 |阅读模式

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

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

x
利用 barnes进行空间滤波 fortran程序一直运算但是生成不了数据  求大神解答

program main
implicit none
integer,parameter::xx=480,yy=241,zz=27,tt=48,dg=1
real   ,parameter :: undef=-32767
!global scale,1*1
real,parameter::C1=4000,C2=16000,G=0.3,pi=3.14

real,external::distance
integer::h,i,j,k,l,m,n
real::r
real::hgt(xx,yy,zz,tt),F1(xx,yy,zz,tt),F2(xx,yy,zz,tt),F(xx,yy,zz,tt),D1(xx,yy,zz,tt),D2(xx,yy,zz,tt),E1(xx,yy,zz,tt),E2(xx,yy,zz,tt),F11(xx,yy,zz,tt),F21(xx,yy,zz,tt),F12(xx,yy,zz,tt),F22(xx,yy,zz,tt),t1,t2,w1,w2

CHARACTER*70 :: FILEPATH1='G:\lunwen_0.75degree\0601\data\ec\decomposional\ud0601_0.75degree\'
CHARACTER*130 :: FILEPATH2='G:\lunwen_0.75degree\0601\data\ec\decomposional\smooth\barnes_smooth\ud0601_0.75degree_c1-4000c2-16000\'

!!!!!!!!!!!!!!!!!!!!!!!!!!!    read initial field        !!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! open(10,file='E:\ScientificResearchDuringMaster\Wrf_out\19-21\wavefiltering\0719PRESwavefilter.dat',access='direct',recl=4,status='old')
! open(20,file='E:\ScientificResearchDuringMaster\Wrf_out\19-21\wavefiltering\PRESfiltered.grd',form='binary')
! open(30,file='E:\ScientificResearchDuringMaster\Wrf_out\19-21\wavefiltering\PRESditong.grd',form='binary')
OPEN(10,FILE=trim(FILEPATH1)//'\bin\outud0601_0.75degree20060508_20060519_quyu.bin',FORM='binary',ACCESS='DIRECT',recl=4,status='old')
OPEN(20,FILE=trim(FILEPATH2)//'\bin\outud0601_0.75degree20060508_20060519_quyu_baners.bin',FORM='binary')
OPEN(30,FILE=trim(FILEPATH2)//'\bin\outud0601_0.75degree20060508_20060519_quyu_baner_ditong.bin',FORM='binary')

  h=0
do m=1,tt
print *,'Begin time = ',m
do n=1,zz
  do j=1,yy
   do i=1,xx
    h=h+1
    read(10,rec=h) hgt(i,j,n,m)
    print *, hgt(1,10,20,40)
enddo
enddo
enddo
enddo

do m=1,tt
do n=1,zz
  do j=1,yy
   do i=1,xx
    w1=0
    t1=0
    w2=0
    t2=0
   do k=1,yy,dg
    do l=1,xx,dg
     r=distance(-90.0+(j-1)*0.75,-90.0+(k-1)*0.75,(i-1)*0.75,(l-1)*0.75)
     if(r<=sqrt(C1))then
      w1=w1+exp(-r**2/(4*C1))
      t1=t1+hgt(l,k,n,m)*exp(-r**2/(4*C1))
      print*,r
     endif
     if(r<=sqrt(C2))then
      w2=w2+exp(-r**2/(4*C2))
      t2=t2+hgt(l,k,n,m)*exp(-r**2/(4*C2))
     endif
enddo
enddo
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
   F1(i,j,n,m)=t1/w1     !meso scale
   F2(i,j,n,m)=t2/w2     !large scale
enddo
enddo
enddo
enddo

D1=hgt-F1
D2=hgt-F2

do m=1,tt
do n=1,zz
  do j=1,yy
   do i=1,xx
   w1=0
   t1=0
   w2=0
   t2=0
   do k=1,yy,dg
    do l=1,xx,dg
     r=distance(-90.0+(j-1)*0.75,-90.0+(k-1)*0.75,(i-1)*0.75,(l-1)*0.75)
     if(r<=sqrt(C1))then
      w1=w1+exp(-r**2/(4*G*C1))
      t1=t1+D1(l,k,n,m)*exp(-r**2/(4*G*C1))
     endif
     if(r<=sqrt(C2))then
      w2=w2+exp(-r**2/(4*G*C2))
      t2=t2+D2(l,k,n,m)*exp(-r**2/(4*G*C2))
     endif
    enddo
   enddo

   F11(i,j,n,m)=F1(i,j,n,m)+t1/w1
   F21(i,j,n,m)=F2(i,j,n,m)+t2/w2
enddo
enddo
enddo
enddo
   E1=F11-F1
   E2=F21-F2

do m=1,tt
do n=1,zz
  do j=1,yy
   do i=1,xx
   w1=0
   t1=0
   w2=0
   t2=0
   do k=1,yy,dg
    do l=1,xx,dg
     r=distance(-90.0+(j-1)*0.75,-90.0+(k-1)*0.75,(i-1)*0.75,(l-1)*0.75)
     if(r<=sqrt(C1))then
      w1=w1+exp(-r**2/(4*C1))
      t1=t1+E1(l,k,n,m)*exp(-r**2/(4*C1))
     endif
     if(r<=sqrt(C2))then
      w2=w2+exp(-r**2/(4*C2))
      t2=t2+E2(l,k,n,m)*exp(-r**2/(4*C2))
     endif
    enddo
   enddo
   F12(i,j,n,m)=F11(i,j,n,m)+3*(F11(i,j,n,m)-F1(i,j,n,m))/4-t1/w1
   F22(i,j,n,m)=F21(i,j,n,m)+3*(F21(i,j,n,m)-F2(i,j,n,m))/4-t2/w2
   F(i,j,n,m)=F12(i,j,n,m)-F22(i,j,n,m)
   write(20) F(i,j,n,m)
   write(30) F22(i,j,n,m)
   print *, i,j,n,m
enddo
enddo
enddo

print *,'End time = ',m
enddo


close(10)
close(20)
close(30)
end program main

! write(*,*) hgt(1:10,1:10)
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!   calculate the 'F0' in the Barnes formula!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

!!!!!!!!!!  calculate the 'F2' under different 'C' in the Barnes formula (the second revision)  !!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!calculate the spherical distance between (i,j)  and (k,l)!!!!!!!!!!!!!!!!
function distance(lat1,lat2,lon1,lon2)
implicit none
real,parameter::R=6371.004,pi=3.1415926
real::lat1,lat2,lon1,lon2
real::distance
distance=R*acos(cos(lat1*pi/180)*cos(lat2*pi/180)*cos((lon1-lon2)*pi/180)+sin(lat1*pi/180)*sin(lat2*pi/180))
return
end function distance

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

新浪微博达人勋

发表于 2017-2-15 20:47:13 | 显示全部楼层
二维滤波不是一般用loess么?
密码修改失败请联系微信:mofangbao

新浪微博达人勋

 楼主| 发表于 2017-2-15 21:43:26 | 显示全部楼层
ljchen1989 发表于 2017-2-15 20:47
二维滤波不是一般用loess么?

您说的是用matlab的loess进行空间滤波吗  主要是不太会matlab
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2017-2-16 08:41:35 | 显示全部楼层
yeah... 发表于 2017-2-15 21:43
您说的是用matlab的loess进行空间滤波吗  主要是不太会matlab

会matlab也不一定会loess滤波啊~
那神器,会了直接发nature
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2017-2-16 11:02:41 | 显示全部楼层
非常感谢,赞!!!
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2017-3-19 20:54:42 | 显示全部楼层
ljchen1989 发表于 2017-2-15 20:47
二维滤波不是一般用loess么?

loess二维滤波怎么实现?有么有资料啊
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2017-3-23 15:16:26 | 显示全部楼层
解决了吗,我也想要程序
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2017-11-10 18:08:15 | 显示全部楼层
谢谢  大赞
密码修改失败请联系微信:mofangbao
您需要登录后才可以回帖 登录 | 立即注册 新浪微博登陆

本版积分规则

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

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

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