source: trunk/toolbox/whorldmap.m @ 33

Last change on this file since 33 was 33, checked in by jmignot, 15 years ago

repertoire toolbox/

  • Property svn:keywords set to Id
File size: 6.1 KB
Line 
1% WORLDMAP makes map of the world.
2function worldmap(axes,maxlat)
3%
4%        WORLDMAP([LONG_MIN LONG_MAX LAT_MIN LAT_MAX]) draws a
5%        coastline map of the world at about 1/2 degree
6%        resolution. WORLDMAP (called without arguments) draws
7%        the whole world with the Pacific in the center.
8%
9%        WORLDMAP('north',MAXLAT) draws a polar projection from the North
10%        pole out to latitude MAXLAT. MAP('south') does the same for
11%        the South pole (MAXLAT is optional in both cases, but is taken
12%        to lie in the same hemisphere as the pole).
13%       
14
15%Notes: RP (WHOI) 6/Dec/91
16%                 7/Nov/92  Changed for matlab4.0
17%                 17/Oct/93 New outline file.
18%                 14/Mar/94 Fixed polar projections, and changed name
19%                           to 'worldmap'.
20%             
21
22%+
23%
24% KNOWN PROBLEMS
25% ==============
26%
27% Following message appears :
28% ::
29%
30%  warning: function name `worldmap' does not agree with function file name `/.autofs/home/fplod/incas/tpoctave/tpacpandreg_ws/PROGRAMMES/whorldmap.m'
31%
32% function name unchanged because we are not original writer of this function
33%
34%
35% big output from mlint('whorldmap') !!
36%
37%
38% EVOLUTIONS
39% ==========
40%
41% $Id$
42%
43% - fplod 2009-08-26T09:02:22Z aedon.locean-ipsl.upmc.fr (Darwin)
44%
45%   * add missing octave warning on Erasemode
46%
47% - fplod 2009-08-25T09:32:28Z aedon.locean-ipsl.upmc.fr (Darwin)
48%
49%   * add missing octave warning on Erasemode
50%
51% - fplod 2009-08-21T13:34:38Z aedon.locean-ipsl.upmc.fr (Darwin)
52%
53%   * add ReStructured Text header
54%   * add octave warning on Erasemode
55%   * replace ``isstr`` by ``ischar`` to avoid following message :
56%     ::
57%
58%     warning: isstr is obsolete and will be removed from a future version of Octave, please use ischar instead
59%
60%   * preallocating nxl and nyl because undefined if octave is running
61%
62%-
63
64% change this line (if map.m is not in your default directory) to
65% "load <path>/coasts".
66load coasts
67
68
69shiftx=0;
70drawtwice=0;
71proj='rec';
72if (nargin<2), maxlat=40; else maxlat=abs(maxlat); end;
73
74if (maxlat>90); error('MAXLAT greater than 90!'); end;
75
76if (nargin>0),
77   if (ischar(axes)),
78      if (axes(1:3)=='nor'),
79         proj='npl';
80         axes=(90-maxlat)*[-1 1 -1 1];
81      elseif (axes(1:3)=='sou'),
82         proj='spl';
83         axes=(90-maxlat)*[-1 1 -1 1];
84      else
85         error('map: Unrecognized projection!');
86      end;
87   else         
88      axes=axes(:)';
89      if (max(size(axes)) ~= 4),
90         error('map: wrong number of limit args!');
91      end;
92      if ( (axes(4)-axes(3))>180. ),
93         error('map: Lat range greater than 180 degrees');
94      end;
95      if ( (axes(2)-axes(1))>360. ),
96         error('map: Long range greater than 360 degrees');
97      else
98         if (axes(1)<=-180. ),
99            shiftx=-360;
100            drawtwice=1;
101         elseif (axes(2)>180.),
102            shiftx=360;
103            drawtwice=1;
104         else
105            shiftx=0;
106            drawtwice=0;
107         end;
108      end;
109   end;
110else
111   axes=[-334 25 -90 90];
112   shiftx=-360;
113   drawtwice=1;
114end;
115     
116if (proj=='rec'),
117   lh=plot(coastlines(1,:)+shiftx,coastlines(2,:),'-');
118   if ~ exist('OCTAVE_VERSION','builtin')
119    set(lh,'Erasemode','none');
120   else
121    warning('www : octave do not know Erasemode property')
122   end
123elseif (proj=='npl'),
124   kk=find(coastlines(2,:)<maxlat);
125   xx=(90-coastlines(2,:)).*cos(coastlines(1,:)*pi/180-pi/2);
126   yy=(90-coastlines(2,:)).*sin(coastlines(1,:)*pi/180-pi/2);
127   xx(kk)=NaN*kk;
128   lh=plot(xx,yy,'-');
129   if ~ exist('OCTAVE_VERSION','builtin')
130    set(lh,'Erasemode','none');
131   else
132    warning('www : octave do not know Erasemode property')
133   end
134   set(gca,'aspect',[1 1]);
135
136elseif (proj=='spl'),
137   kk=find(coastlines(2,:)>-maxlat);
138   xx=(90+coastlines(2,:)).*cos(-coastlines(1,:)*pi/180+pi/2);
139   yy=(90+coastlines(2,:)).*sin(-coastlines(1,:)*pi/180+pi/2);
140   xx(kk)=NaN*kk;
141   lh=plot(xx,yy,'-');
142   if ~ exist('OCTAVE_VERSION','builtin')
143    set(lh,'Erasemode','none');
144   else
145    warning('www : octave do not know Erasemode property');
146   end
147   set(gca,'aspect',[1 1]);
148end;
149
150if (drawtwice),
151   if ~ exist('OCTAVE_VERSION','builtin')
152    line(coastlines(1,:),coastlines(2,:),'Linestyle','-',...
153    'Erasemode','none');
154   else
155    warning('www : octave do not know Erasemode property');
156    line(coastlines(1,:),coastlines(2,:),'Linestyle','-')
157   end
158end;
159
160
161if (proj=='rec'),
162 axis(axes);
163 xlb=get(gca,'Xticklabel');
164 [Nn,Mm]=size(xlb);
165 Mf=int2str(Mm);
166 nxl=zeros(Nn,Mm+1);
167 for kk=1:Nn,
168   zz=rem(str2num(xlb(kk,:))+540,360)-180;
169   if (zz<0), nxl(kk,:)=sprintf(['%' Mf '.0fW'],abs(zz));
170   elseif (zz>0)  nxl(kk,:)=sprintf(['%' Mf '.0fE'],(zz));
171   else nxl(kk,:)=sprintf(['%' Mf '.0f '],(zz));
172   end;
173 end;
174 set(gca,'Xticklabel',nxl)
175
176 yx=get(gca,'Ytick');
177 ylb=get(gca,'Yticklabel');
178 [Nn,Mm]=size(ylb);
179 Mf=int2str(Mm);
180 nyl=zeros(Nn,Mm+1);
181 for kk=1:Nn,
182   zz=str2num(ylb(kk,:));
183   if (zz<0), nyl(kk,:)=sprintf(['%' Mf '.0fS'],abs(zz));
184   elseif (zz>0)  nyl(kk,:)=sprintf(['%' Mf '.0fN'],(zz));
185   else nyl(kk,:)=sprintf(['%' Mf '.0f '],(zz));
186   end;
187 end;
188 set(gca,'Yticklabel',nyl)
189 set(gca,'Ytick',yx);  % Need this to reset position limits
190else  % polar projection
191  axis(axes);
192  set(gca,'visible','off');
193  for kk=10:10:(90-maxlat),
194    xx=kk*cos([0:10:360]*pi/180);
195    yy=kk*sin([0:10:360]*pi/180);
196    line(xx,yy,'color','w','linestyle',':');
197  end;
198  xx=(90-maxlat)*cos([0:5:360]*pi/180);
199  yy=(90-maxlat)*sin([0:5:360]*pi/180);
200  line(xx,yy,'color','w','linestyle','-');
201  for kk=10:10:(90-maxlat-2),
202    if (proj=='npl'),
203       text(0,kk,sprintf('%2.0fN',90-kk),'horizontal','center');
204    else
205       text(0,kk,sprintf('%2.0fS',90-kk),'horizontal','center');
206    end;
207  end;
208  for kk=0:30:359,
209    xx=[10 90-maxlat]*cos(kk*pi/180);
210    yy=[10 90-maxlat]*sin(kk*pi/180);
211    line(xx,yy,'color','w','linestyle',':');
212    if (kk<=180),nyl=sprintf('%3.0fE',kk);
213    else nyl=sprintf('%3.0fW',abs(360-kk)); end;
214    if (proj=='npl'),
215text(yy(2),-xx(2),nyl,'rotation',kk,'horizontal','center','vertical','top');
216    else
217text(yy(2),xx(2),nyl,'rotation',-kk,'horizontal','center','vertical','bottom');
218    end;
219  end;
220end;
221
222
223if (proj=='rec'), grid; end;
224
Note: See TracBrowser for help on using the repository browser.