1 | function showbasins(varargin)
|
---|
2 | %SHOWBASINS - return basins that are within the xlim and ylim
|
---|
3 | %
|
---|
4 | % Usage:
|
---|
5 | % names=showbasins(options);
|
---|
6 | % Options:
|
---|
7 | % 'unit' default 1
|
---|
8 | % 'hemisphere': default +1;
|
---|
9 | % 'central_meridian: 45 for Greenland and 0 for Antarctica
|
---|
10 | % 'standard_parallel: 70 for Greenland and 71 for Antarctica
|
---|
11 | %
|
---|
12 |
|
---|
13 | %is varargin an options database already?
|
---|
14 | if nargin==0,
|
---|
15 | options=pairoptions(varargin{:});
|
---|
16 | elseif (isa(varargin{1},'plotoptions') | isa(varargin{1},'pairoptions')),
|
---|
17 | %do nothing to the varargin:
|
---|
18 | options=varargin{1};
|
---|
19 | else
|
---|
20 | %process varargin for options:
|
---|
21 | options=pairoptions(varargin{:});
|
---|
22 | end
|
---|
23 |
|
---|
24 |
|
---|
25 | %recover some options, and set defaults
|
---|
26 | unitmultiplier=getfieldvalue(options,'unit',1);
|
---|
27 | fontsize=getfieldvalue(options,'fontsize',12);
|
---|
28 | hemisphere=getfieldvalue(options,'hemisphere');
|
---|
29 |
|
---|
30 | if strcmpi(hemisphere,'s'),
|
---|
31 | hemisphere=-1;
|
---|
32 | elseif strcmpi(hemisphere,'n'),
|
---|
33 | hemisphere=+1;
|
---|
34 | else
|
---|
35 | error('showbasins error message: hemispehre should be either ''n'' or ''s''');
|
---|
36 | end
|
---|
37 |
|
---|
38 | if hemisphere==+1,
|
---|
39 | central_meridian=getfieldvalue(options,'central_meridian',45);
|
---|
40 | standard_parallel=getfieldvalue(options,'standard_parallel',70);
|
---|
41 | else
|
---|
42 | central_meridian=getfieldvalue(options,'central_meridian',0);
|
---|
43 | standard_parallel=getfieldvalue(options,'standard_parallel',71);
|
---|
44 | end
|
---|
45 |
|
---|
46 | %Ok, find basin we are talking about:
|
---|
47 | load([jplsvn '/projects/ModelData/Names/Names.mat']);
|
---|
48 |
|
---|
49 | %Get xlim and ylim, and convert into lat,long:
|
---|
50 | xlimits=xlim; x0=xlimits(1); x1=xlimits(2);
|
---|
51 | ylimits=ylim; y0=ylimits(1); y1=ylimits(2);
|
---|
52 |
|
---|
53 | %Convert names lat and long into x,y:
|
---|
54 | lat=cell2mat(names(:,3));
|
---|
55 | long=cell2mat(names(:,2));
|
---|
56 |
|
---|
57 | %Now, convert lat,long into x,y:
|
---|
58 | [x,y]=ll2xy(lat,long,hemisphere,central_meridian,standard_parallel);
|
---|
59 |
|
---|
60 | %Find x,y within xlimits and ylimits:
|
---|
61 | locations=find(x>x0 & x<x1 & y>y0 & y<y1);
|
---|
62 |
|
---|
63 | %Go through locations, and display the names:
|
---|
64 | for i=1:size(locations,1),
|
---|
65 | hold on,
|
---|
66 | plot(x(locations(i)),y(locations(i)),'r.');
|
---|
67 | t=text(x(locations(i)),y(locations(i)),names{locations(i),1});
|
---|
68 | set(t,'FontSize',fontsize);
|
---|
69 | end
|
---|