source: Roms_tools/Preprocessing_tools/oainterp.m @ 2

Last change on this file since 2 was 1, checked in by cholod, 13 years ago

import Roms_Agrif

File size: 2.5 KB
Line 
1function extrfield = oainterp(londata,latdata,data,lon,lat,ro,savefile)
2%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3%
4% function extrfield = oainterp(londata,latdata,data,lon,lat,ro)
5%
6%
7% compute an objective analysis on a scalar field.
8%
9%   input:
10%  londata   : longitude of data points (vector)
11%  latdata   : latitude of data points (vector)
12%  data      : values of the data points (vector)
13%  lon       : longitude of the estimated points (vector)
14%  lat       : latitude of the estimated points (vector)
15%  ro        : decorrelation scale
16%  savefile  : to avoid recomputing r1 and r2
17%               2 do nothing
18%               1 save r1 and r2 in tmp.mat
19%               0 load r1 and r2 from tmp.mat
20%
21%   output:
22%  extrfield : estimated values (vector)
23%
24%  Further Information: 
25%  http://www.brest.ird.fr/Roms_tools/
26
27%  This file is part of ROMSTOOLS
28%
29%  ROMSTOOLS is free software; you can redistribute it and/or modify
30%  it under the terms of the GNU General Public License as published
31%  by the Free Software Foundation; either version 2 of the License,
32%  or (at your option) any later version.
33%
34%  ROMSTOOLS is distributed in the hope that it will be useful, but
35%  WITHOUT ANY WARRANTY; without even the implied warranty of
36%  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
37%  GNU General Public License for more details.
38%
39%  You should have received a copy of the GNU General Public License
40%  along with this program; if not, write to the Free Software
41%  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
42%  MA  02111-1307  USA
43%
44%  Copyright (c) 2001-2006 by Pierrick Penven
45%  e-mail:Pierrick.Penven@ird.fr 
46%
47%  Derived from a fortran program of Alain Colin de
48%  Verdiere (UBO, 2000)
49%
50%  Updated    2-Oct-2006 by Xavier Capet and Pierrick Penven
51%                        (add the 'savefile option')
52%
53%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
54if nargin < 5
55  error('Not enough input arguments')
56elseif nargin < 6
57  disp('using default decorrelation scale:  ro = 500 km')
58  ro = 5e5;
59end
60if nargin < 7
61  savefile=2;
62end
63%
64mdata=mean(data);
65data=data-mdata;
66%
67if savefile ~=0
68  invro=1/ro;
69  i=[1:1:length(londata)];
70  j=[1:1:length(lon)];
71  [I,J]=meshgrid(i,i);
72  r1=spheric_dist(latdata(I),latdata(J),londata(I),londata(J));
73%
74  [I,J]=meshgrid(i,j);
75  r2=spheric_dist(lat(J),latdata(I),lon(J),londata(I));
76%
77  if savefile ==1
78    save tmp.mat r1 r2 invro;
79  end
80%
81elseif savefile==0
82  load tmp.mat;
83end
84%
85extrfield=mdata+(exp(-r2*invro)/exp(-r1*invro))*data;
86%
87return
88
Note: See TracBrowser for help on using the repository browser.