source: issm/trunk/src/m/utils/Basins/showbasins.m@ 7245

Last change on this file since 7245 was 7245, checked in by Eric.Larour, 14 years ago

Not embedded inside applyoptions.m anymore

File size: 2.0 KB
RevLine 
[7140]1function 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
[7245]13%is varargin an options database already?
14if nargin==0,
15 options=pairoptions(varargin{:});
16elseif (isa(varargin{1},'plotoptions') | isa(varargin{1},'pairoptions')),
17 %do nothing to the varargin:
18 options=varargin{1};
19else
20 %process varargin for options:
21 options=pairoptions(varargin{:});
22end
[7140]23
[7245]24
[7140]25%recover some options, and set defaults
26unitmultiplier=getfieldvalue(options,'unit',1);
27fontsize=getfieldvalue(options,'fontsize',12);
[7245]28hemisphere=getfieldvalue(options,'hemisphere');
[7140]29
[7245]30if strcmpi(hemisphere,'s'),
31 hemisphere=-1;
32elseif strcmpi(hemisphere,'n'),
33 hemisphere=+1;
34else
35 error('showbasins error message: hemispehre should be either ''n'' or ''s''');
36 end
37
[7140]38if hemisphere==+1,
39 central_meridian=getfieldvalue(options,'central_meridian',45);
40 standard_parallel=getfieldvalue(options,'standard_parallel',70);
41else
42 central_meridian=getfieldvalue(options,'central_meridian',0);
43 standard_parallel=getfieldvalue(options,'standard_parallel',71);
44end
45
46%Ok, find basin we are talking about:
47load([issmdir '/projects/ModelData/Names/Names.mat']);
48
49%Get xlim and ylim, and convert into lat,long:
50xlimits=xlim; x0=xlimits(1); x1=xlimits(2);
51ylimits=ylim; y0=ylimits(1); y1=ylimits(2);
52
53%Convert names lat and long into x,y:
54lat=cell2mat(names(:,3));
55long=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:
61locations=find(x>x0 & x<x1 & y>y0 & y<y1);
62
63%Go through locations, and display the names:
64for 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);
69end
Note: See TracBrowser for help on using the repository browser.