-
Notifications
You must be signed in to change notification settings - Fork 1
/
openMA_modes_interp_lonlat.m
75 lines (72 loc) · 2.87 KB
/
openMA_modes_interp_lonlat.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
function [cc,ux,uy] = openMA_modes_interp_lonlat( ll, origin, ...
scale, nm, dm, bm )
% OPENMA_MODES_INTERP_LONLAT - interpolates modes at a specific set of
% longitude, latitude points and returns either the modes themselves or the
% velocities at those points.
%
% NOTE that this function does not do any scaling of the modes or
% velocities because of change of coordinate system - that must be done
% afterward if necessary.
%
% NOTE also that this function requires the lonlat2km function from Mike
% Cook's HFradarmap toolbox.
%
% Usage: cc = openMA_modes_interp_lonlat( ll, origin, scale )
% [cc,u] = openMA_modes_interp_lonlat( ll, origin, scale, vfm, dfm, bm )
% [cc,ux,uy] = openMA_modes_interp_lonlat( ll, origin, scale, vfm, dfm, bm )
%
% The first form just returns the coordinates in the coordinate space of
% the modes that correspond to the lon,lat coordinates in ll (which must be
% a 2 column matrix).
%
% The second form also returns the modes themselves at the coordinates in ll.
%
% The third form returns the velocities of the modes at the coordinates.
%
% NOTE that the number of output arguments is very important to the result.
%
% ll = longitude,latitude
%
% origin = a two element vector of the origin in lon,lat space that
% corresponds to 0,0 in the coordinate system of the modes.
%
% scale = a scale factor to be applied to the km positions of the
% coordinates in ll with respect to the origin. All kilometer positions
% will be divided by this number (perhaps sqrt(domain_area)). This can be
% used if you created modes, for example, on a domain of unit area by
% dividing all spatial scales by the sqrt(domain_area). Defaults to 1.
%
% vfm, dfm, and bm are the vorticity-free modes (formerly known as the
% Neumann modes), divergence-free modes (formerly the Dirichlet modes) and
% the boundary modes (or harmonic modes), respectively. These should be in
% the format generated by the openMA_pdetool_neumann_modes_solve,
% openMA_pdetool_dirichlet_modes_solve and
% openMA_pdetool_boundary_modes_solve. If any of them is empty or absent,
% those modes will be ignored.
%
% The format of u, ux and uy will be an array with one row for each point
% in ll and one column for each mode in the order returned by
% openMA_modes_order.
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% $Id: openMA_modes_interp_lonlat.m 79 2007-03-05 21:51:20Z dmk $
%
% Copyright (C) 2005 David M. Kaplan
% Licence: GPL (Gnu Public License)
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
if ~exist('scale','var')
scale = 1;
end
[x,y] = lonlat2km( origin(1), origin(2), ll(:,1), ll(:,2) );
cc = [x(:),y(:)] / scale;
if nargout <= 1
return
elseif nargout == 2
ux = openMA_modes_interp( cc, nm, dm, bm );
elseif nargout == 3
[ux,uy] = openMA_modes_interp( cc, nm, dm, bm );
else
error( 'Bad number of output arguments.' )
end