1 | function 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 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
54 | if nargin < 5 |
---|
55 | error('Not enough input arguments') |
---|
56 | elseif nargin < 6 |
---|
57 | disp('using default decorrelation scale: ro = 500 km') |
---|
58 | ro = 5e5; |
---|
59 | end |
---|
60 | if nargin < 7 |
---|
61 | savefile=2; |
---|
62 | end |
---|
63 | % |
---|
64 | mdata=mean(data); |
---|
65 | data=data-mdata; |
---|
66 | % |
---|
67 | if 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 | % |
---|
81 | elseif savefile==0 |
---|
82 | load tmp.mat; |
---|
83 | end |
---|
84 | % |
---|
85 | extrfield=mdata+(exp(-r2*invro)/exp(-r1*invro))*data; |
---|
86 | % |
---|
87 | return |
---|
88 | |
---|