I have some data files that contain values only over the continental US and
fill values in the other cells. In order to not lose data when interpolating
to a finer grid, I decided to add some buffer data around the group of
cells that contain values. Right now I'm doing it with several loops and if
statements (see below if interested) that basically copy values first along
the west coast, then the east coast, then the southern cells, and then the
northern cells. This is the only solution I could come up with, and while it
works, it's not particularly speedy. Is there a better way?
-Bridget
do i = 0,nlats-1
do j = 1,nlons-2
if
(num(ismissing(aggobs(:,i,j))).gt.0.and.num(ismissing(aggobs(:,i,j-1))).gt.0.and.num(ismissing(aggobs(:,i,j+1))).eq.0)
then
aggobs(:,i,j) = aggobs(:,i,j+1)
end if
end do
do j = nlons-2,1,1
if
(num(ismissing(aggobs(:,i,j))).gt.0.and.num(ismissing(aggobs(:,i,j+1))).gt.0.and.num(ismissing(aggobs(:,i,j-1))).eq.0)
then
aggobs(:,i,j) = aggobs(:,i,j-1)
end if
end do
if
(num(ismissing(aggobs(:,i,0))).gt.0.and.(num(ismissing(aggobs(:,i,nlons-1))).eq.0.or.num(ismissing(aggobs(:,i,1))).eq.0))
then
aggobs(:,i,0) = avg((/aggobs(:,i,nlons-1),aggobs(:,i,1)/))
end if
if
(num(ismissing(aggobs(:,i,nlons-1))).gt.0.and.(num(ismissing(aggobs(:,i,nlons-2))).eq.0.or.num(ismissing(aggobs(:,i,0))).eq.0))
then
aggobs(:,i,nlons-1) = avg((/aggobs(:,i,nlons-2),aggobs(:,i,0)/))
end if
end do
do j = 0,nlons-1
do i = 1,nlats-2
if
(num(ismissing(aggobs(:,i,j))).gt.0.and.num(ismissing(aggobs(:,i-1,j))).gt.0.and.num(ismissing(aggobs(:,i+1,j))).eq.0)
then
aggobs(:,i,j) = aggobs(:,i+1,j)
end if
end do
do i = nlats-2,1,1
if
(num(ismissing(aggobs(:,i,j))).gt.0.and.num(ismissing(aggobs(:,i+1,j))).gt.0.and.num(ismissing(aggobs(:,i-1,j))).eq.0)
then
aggobs(:,i,j) = aggobs(:,i-1,j)
end if
end do
if
(num(ismissing(aggobs(:,0,j))).gt.0.and.(num(ismissing(aggobs(:,nlats-1,j))).eq.0.or.num(ismissing(aggobs(:,1,j))).eq.0))
then
aggobs(:,0,j) = avg((/aggobs(:,nlats-1,j),aggobs(:,1,j)/))
end if
if
(num(ismissing(aggobs(:,nlats-1,j))).gt.0.and.(num(ismissing(aggobs(:,nlats-2,j))).eq.0.or.num(ismissing(aggobs(:,0,j))).eq.0))
then
aggobs(:,nlats-1,j) = avg((/aggobs(:,nlats-2,j),aggobs(:,0,j)/))
end if
end do
-- Bridget Thrasher, PhD Postdoctoral Researcher Climate Central www.climatecentral.org
_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Fri Jan 8 12:04:29 2010
This archive was generated by hypermail 2.1.8 : Tue Jan 12 2010 - 15:38:20 MST