source: Roms_tools/m_map/m_quiver.m @ 1

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

import Roms_Agrif

File size: 2.9 KB
Line 
1function h=m_quiver(long,lat,u,v,varargin);
2% M_QUIVER Makes a quiverplot on a map (QUIVER-style)
3%    M_QUIVER(LONG,LAT,U,V) plots velocity vectors as arrows with components
4%    (U,V) at the points (LONG,LAT) on the currently defined map.  The
5%    matrices LONG,LAT,U,V must all be the same size. U and V contain the
6%    eastward and northward components of velocity. Arrow scaling is automatic.
7%
8%    M_QUIVER(X,Y,U,V,S) automatically scales the arrows to fit within the
9%    grid and then stretches them by S.  Use S=0 to plot the arrows without
10%    the automatic scaling; In this case the scaling is 1 unit/degree
11%    latitude. Note that we do not scale arrows with respect to map
12%    coordinates! Instead, the arrows will correspond better to actual motions
13%    over some time step. The tradeoff is that a single scale arrow cannot
14%    be accurate for the entire map (M_VEC scales arrows according to
15%    map coordinates).
16%
17%    M_QUIVER(...,LINESPEC) uses the plot linestyle specified for
18%    the velocity vectors.  Any marker in LINESPEC is drawn at the base
19%    instead of an arrow on the tip.  Use a marker of '.' to specify
20%    no marker at all.  See PLOT for other possibilities. M_QUIVER is a wrapper
21%    for QUIVER - for fancier arrows it is possible to replace the call to
22%    QUIVER with one to another routine that draws fancy arrows, e.g.
23%    ARROW (from TMW user-contrib software archive), or to use M_VEC.
24%
25%    M_QUIVER(...,'filled') fills any markers specified.
26%
27%    H = M_QUIVER(...) returns a vector of line handles.
28%
29%    See also QUIVER, M_VEC
30
31% Rich Pawlowicz (rich@ocgy.ubc.ca) 20/Jan/97
32%
33% This software is provided "as is" without warranty of any kind. But
34% it's mine, so you can't sell it.
35%
36
37% 6/Nov/00 - eliminate returned stuff if ';' neglected (thx to D Byrne)
38% 7/jul/06 - changed angle calc to work correctly very near boundaries.
39% 12/jul/06 - fixed a factor of 10 error that crept into the length of unscaled
40%             arrows between version 1.3f and 1.4a (pointed out D. Kaplan).
41
42global MAP_PROJECTION MAP_VAR_LIST
43
44% Have to have initialized a map first
45
46if isempty(MAP_PROJECTION),
47  disp('No Map Projection initialized - call M_PROJ first!');
48  return;
49end;
50
51
52
53[X,Y]=m_ll2xy(long,lat,'clip','point');
54
55% This is the old way, now replaced  - RP 7/jun/06
56%[XN,YN]=m_ll2xy(long,lat+.001,'clip','point');
57%[XE,YE]=m_ll2xy(long+(.001)./cos(lat*pi/180),lat,'clip','point');
58
59%mU=u.*(XE-X)*100 + v.*(XN-X)*100;
60%mV=u.*(YE-Y)*100 + v.*(YN-Y)*100;
61
62[XN ,YN ]=m_ll2xy([long(:) long(:)]',[lat(:) lat(:)+.001]','clip','off');
63[XE ,YE ]=m_ll2xy([long(:) long(:)+(.001)./cos(lat(:)*pi/180)]',[lat(:) lat(:)]','clip','off');
64mU=u.*reshape(diff(XE),size(lat))*1000 + v.*reshape(diff(XN),size(lat))*1000;
65mV=u.*reshape(diff(YE),size(lat))*1000 + v.*reshape(diff(YN),size(lat))*1000;
66
67
68h=quiver(X,Y,mU,mV,varargin{:});
69set(h,'tag','m_quiver');
70
71if nargout==0,,
72 clear h
73end;
Note: See TracBrowser for help on using the repository browser.