Home > atmlab > geographical > getPredefinedRegions.m

getPredefinedRegions

PURPOSE ^

GETPREDEFINEDRREGIONS Returns lat/lon corner values of predefined regions

SYNOPSIS ^

function [corners,nregions,regionstrlong] = getPredefinedRegions(regionstr)

DESCRIPTION ^

 GETPREDEFINEDRREGIONS Returns lat/lon corner values of predefined regions

 IN:    <none>        If nothing is input the list of currently available 
                      regions are shown. Build on this list in
                      retrieve_reginfo.m if you want other regions 
        regionstr     {'%s'}    Use one or more regions listed in retrieve_reginfo.m

 OUT: corners = [blcorner,trcorner;blcorner,trcorner]
      nregions = number of full regions (not necessarily size(corners,2))
      regionstrlong = a string of the longname of the regions.

 NOTE:
 - Regions, including all of the AR4 IPCC regions (ch 11), can be chosen
   from the set of regions (see list below). The code defining the regions
   is in the subfunction (retrieve_reginfo) to this function. 

 current LIST of regions:
    - Make sure to update this list if you add a region to the subfunction!!
    Allregions = {'earth','global','total','tropics','boreal_trop','austral_trop',...
        'sepdz','seadz','ocean_sub','seapdz_boreal','twp','trop_cont','conv_sa','conv_af',...
        'swl','kurosho','gulfstr','nwl','westerlies','swe','aus','polar',...
        'waf','eaf','saf','sah','neu','sem','nas','cas','tib','eas','sas',...
        'sea','ala','cgi','wna','cna','ena','cam','amz','ssa','nau','sau',...
        'car','ind','med','tne','npa','spa','arc','ant'};


 USAGE      [details,N,regionstrings]  = predefinedRegions   %if you want
                                                               the list of
                                                               regions

            [corners,nregions,regionstrlong] = predefinedRegions(regionstr)
            % regular use to get corners of a region

 Created by Salomon Eliasson
 $Id: getPredefinedRegions.m 7187 2011-10-29 19:46:25Z seliasson $

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

DOWNLOAD ^

getPredefinedRegions.m

SOURCE CODE ^

0001 function [corners,nregions,regionstrlong] = getPredefinedRegions(regionstr)
0002 % GETPREDEFINEDRREGIONS Returns lat/lon corner values of predefined regions
0003 %
0004 % IN:    <none>        If nothing is input the list of currently available
0005 %                      regions are shown. Build on this list in
0006 %                      retrieve_reginfo.m if you want other regions
0007 %        regionstr     {'%s'}    Use one or more regions listed in retrieve_reginfo.m
0008 %
0009 % OUT: corners = [blcorner,trcorner;blcorner,trcorner]
0010 %      nregions = number of full regions (not necessarily size(corners,2))
0011 %      regionstrlong = a string of the longname of the regions.
0012 %
0013 % NOTE:
0014 % - Regions, including all of the AR4 IPCC regions (ch 11), can be chosen
0015 %   from the set of regions (see list below). The code defining the regions
0016 %   is in the subfunction (retrieve_reginfo) to this function.
0017 %
0018 % current LIST of regions:
0019 %    - Make sure to update this list if you add a region to the subfunction!!
0020 %    Allregions = {'earth','global','total','tropics','boreal_trop','austral_trop',...
0021 %        'sepdz','seadz','ocean_sub','seapdz_boreal','twp','trop_cont','conv_sa','conv_af',...
0022 %        'swl','kurosho','gulfstr','nwl','westerlies','swe','aus','polar',...
0023 %        'waf','eaf','saf','sah','neu','sem','nas','cas','tib','eas','sas',...
0024 %        'sea','ala','cgi','wna','cna','ena','cam','amz','ssa','nau','sau',...
0025 %        'car','ind','med','tne','npa','spa','arc','ant'};
0026 %
0027 %
0028 % USAGE      [details,N,regionstrings]  = predefinedRegions   %if you want
0029 %                                                               the list of
0030 %                                                               regions
0031 %
0032 %            [corners,nregions,regionstrlong] = predefinedRegions(regionstr)
0033 %            % regular use to get corners of a region
0034 %
0035 % Created by Salomon Eliasson
0036 % $Id: getPredefinedRegions.m 7187 2011-10-29 19:46:25Z seliasson $
0037 
0038 if ~nargin
0039     corners       = retrieve_reginfo('list');
0040     fn            = fieldnames(corners);
0041     nregions      = length(fn);
0042     regionstrlong = cell(1,length(fn)); i =1;
0043     for F = fn'
0044         regionstrlong{i} = corners.(F{1}).longname;
0045         i = i+1;
0046     end
0047     return
0048 end
0049 assert(iscell(regionstr)||ischar(regionstr),...
0050     'atmlab:predefinedRegions:badInput','input must be a cell of strings (region names)')
0051 
0052 if ~iscell(regionstr)
0053     regionstr = {regionstr};
0054 end
0055 
0056 k=1;
0057 corners       = zeros(10*length(regionstr),4);
0058 regionstrlong = cell(1,length(regionstr));
0059 nregions      = zeros(1,length(regionstr));
0060 
0061 b = [];
0062 for i = 1:length(regionstr) % loop over regionstrings
0063     test = regexp(regionstr,'/');
0064     if length(test{1})==3
0065         x            = sscanf(regionstr{1},'%f/%f/%f/%f');
0066         corners(i,1) = x(3); 
0067         corners(i,2) = x(1); 
0068         corners(i,3) = x(4);
0069         corners(i,4) = x(2);
0070         regionstrlong{i} = '';
0071         nregions(k)      = 1;
0072         k = k+1;
0073         continue
0074     end
0075     
0076     assert(ismember(regionstr{i},fieldnames(retrieve_reginfo('list'))),...
0077     'atmlab:predefinedRegions:notFound','region: %s is not in list',regionstr{i})
0078 
0079     [blcorner,trcorner,regionstrlong{i}]=retrieve_reginfo(regionstr{i});
0080     len = size(blcorner,1);
0081     
0082     corners(k:k+len-1,1:2) = blcorner;
0083     corners(k:k+len-1,3:4) = trcorner;
0084     nregions(i) = size(b,1)+size(blcorner,1);b=blcorner; % index of the last box in one region
0085     k = k+len;
0086 end
0087 
0088 corners = corners(1:k-1,:,:,:);
0089 
0090 %%%%%%%%%%%%%%%%%
0091 % SUBFUNCTIONS
0092 % ||||||||
0093 % VVVVVVVV
0094 
0095 function [blcorner,trcorner,regionstrlong]=retrieve_reginfo(regionstr)
0096 %% RETRIEVE_REGINFO returns infor required to work with predefined regions
0097 %
0098 % IN: regionstr   %s       Stringname of region. Check list of regions in
0099 %                          Allregions (further down). If regionstr =
0100 %                          'list', the function will list all configured
0101 %                          regions
0102 %
0103 % OUT: 1) bottom left corners of boxes [lat,lon]
0104 %      2) top right corners of boxes   [lat,lon]
0105 %      3) long stringname of the region
0106 %
0107 % Created by Salomon Eliasson
0108 % $Id: getPredefinedRegions.m 7187 2011-10-29 19:46:25Z seliasson $
0109 
0110 assert(nargin==1,'atmlab:retrieve_reginfo:badInput','needs input')
0111 if strcmp(regionstr,'list')
0112     % Make sure to update this list if you add a region!!
0113     Allregions = {'earth','global','total','tropics','boreal_trop','austral_trop',...
0114         'sepdz','seadz','ocean_sub','seadz_boreal','sepdz_boreal','twp','trop_cont','conv_sa','conv_af',...
0115         'swl','kurosho','gulfstr','ocean_sub_boreal','nwl','westerlies','swe','aus','polar',...
0116         'waf','eaf','saf','sah','neu','sem','nas','cas','tib','eas','sas',...
0117         'sea','ala','cgi','wna','cna','ena','cam','amz','ssa','nau','sau',...
0118         'car','ind','med','tne','npa','spa','arc','ant'};
0119     for A = Allregions
0120         [blcorner,trcorner,regionstrlong]=retrieve_reginfo(A{1});
0121         Allreg.(A{1}).shortname = A{1};
0122         Allreg.(A{1}).longname  = regionstrlong;
0123         Allreg.(A{1}).corners   = [blcorner, trcorner];
0124     end
0125     blcorner=Allreg;trcorner=[];regionstrlong='';
0126     return
0127 end
0128 
0129 switch lower(regionstr)
0130     case {'earth','global'}
0131         regionstrlong='earth';
0132         blcorner = [-90,-180]; trcorner = [90,180];
0133     case 'total'
0134         regionstrlong='total';
0135         blcorner = [-60,-180]; trcorner = [60,180];
0136     case 'tropics'
0137         regionstrlong='tropics';
0138         blcorner = [-30,-180]; trcorner = [30,180];
0139     case 'boreal_trop'
0140         regionstrlong='Tropical Northern half';
0141         blcorner = [0,-180]; trcorner = [30,180];
0142     case 'austral_trop'
0143         regionstrlong='Tropical Southern half';
0144         blcorner = [-30,-180]; trcorner = [0,180];
0145     case 'sepdz'
0146         regionstrlong ='South East Pacific Dry Zone';
0147         blcorner = [-27,-110;-18,-130]; trcorner = [-18,-72;2,-82];
0148     case 'seadz'
0149         regionstrlong ='South East Atlantic Dry zone';
0150         blcorner = [-30,-15;-20,-30]; trcorner = [-5,10;-5,-15];
0151     case 'sepdz_boreal'
0152         regionstrlong ='South East Pacific boreal Dry zone';
0153         blcorner = [-15,-180]; trcorner = [0,-80];
0154     case 'seadz_boreal'
0155         regionstrlong ='South East Atlantic boreal Dry zone';
0156         blcorner = [-23.5,-30]; trcorner = [-5,10];
0157     case 'ocean_sub'
0158         % this is both seadz and sepdz merged
0159         regionstrlong ='Subsidence zones of the South East Pacific and South East Atlantic';
0160         [a,b] = retrieve_reginfo('sepdz');
0161         [c,d] = retrieve_reginfo('seadz');
0162         blcorner = cat(1,a,c);
0163         trcorner = cat(1,b,d);
0164     case 'ocean_sub_boreal'
0165         % this is both seadz and sepdz merged
0166         regionstrlong ='Subsidence zones boreal of the South East Pacific and South East Atlantic';
0167         [a,b] = retrieve_reginfo('sepdz_boreal');
0168         [c,d] = retrieve_reginfo('seadz_boreal');
0169         blcorner = cat(1,a,c);
0170         trcorner = cat(1,b,d);
0171     case 'conv_sa'
0172         regionstrlong ='Continental convection area (South America)';
0173         blcorner = [-14,-71.9;-5,-79;0,-80];
0174         trcorner = [-5,-50;0,-56;10,-60];
0175     case 'conv_af'
0176         regionstrlong ='Continental convection area (Africa)';
0177         blcorner = [-16,15;-5,11;0,0];
0178         trcorner = [-5,30;0,33;8,34];
0179     case 'trop_cont'
0180         % this is conv_af and conv_sa merged
0181         regionstrlong ='Tropical Convention Continents';
0182         [a,b] = retrieve_reginfo('conv_af');
0183         [c,d] = retrieve_reginfo('conv_sa');
0184         blcorner = cat(1,a,c);
0185         trcorner = cat(1,b,d);
0186     case 'twp'
0187         regionstrlong ='Tropical Warm pool';
0188         blcorner = [-12 80;-8 100;-12 155];
0189         trcorner = [16 100;14 155;10 175];
0190     case 'swl'
0191         regionstrlong ='Southern midlatitude Westerlies';
0192         blcorner = [-60,-180;-60,-50];
0193         trcorner = [-45,-80;-45,180];
0194     case 'kurosho'
0195         regionstrlong ='The region surrounding the Kurosho Current';
0196         % need extra region as passing the dateline causes problems
0197         blcorner = [33,145;40,160;36,-180;40,-160];
0198         trcorner = [40,180;50,180;50,-160;55,-135];
0199     case 'gulfstr'
0200         regionstrlong ='The region surrounding the Gulfstream';
0201         blcorner=[35,-70;45,-55;];
0202         trcorner=[45,-40;60,-10;];
0203     case 'nwl'
0204         regionstrlong ='Northern midlatitude Westerlies';
0205         [a,b] = retrieve_reginfo('gulfstr');
0206         [c,d] = retrieve_reginfo('kurosho');
0207         blcorner = cat(1,a,c);
0208         trcorner = cat(1,b,d);
0209     case 'westerlies'
0210         % this is swl and nwl merged
0211         regionstrlong ='Northern and Southern hemisphere midlatitude Westerlies';
0212         [a,b] = retrieve_reginfo('gulfstr');
0213         [c,d] = retrieve_reginfo('kurosho');
0214         [e,f] = retrieve_reginfo('swl');
0215         blcorner = cat(1,a,c,e);
0216         trcorner = cat(1,b,d,f);
0217     case 'aus'
0218         regionstrlong ='Australia';
0219         blcorner = [-45,100]; trcorner = [0,170];
0220     case 'swe'
0221         regionstrlong='Sweden';
0222         blcorner = [54,4];trcorner = [72,32];
0223     case 'polar'
0224         regionstrlong = 'Polar regions';
0225         [a,b] = retrieve_reginfo('ant');
0226         [c,d] = retrieve_reginfo('arc');
0227         blcorner = cat(1,a,c);
0228         trcorner = cat(1,b,d);
0229     otherwise
0230         switch regionstr
0231             
0232             %%%%%%%%%%%%%%%%%%%%
0233             % Regions below this line are reserved for AR4 IPCC regions (Ch. 11)
0234             %{'waf','eaf','saf','sah','neu','sem','nas','cas','tib','eas','sas',...
0235             % 'sea','ala','cgi','wna','cna','ena','cam','amz','ssa','nau','sau',...
0236             %'car','ind','med','tne','npa','spa','arc','ant'}
0237             
0238             % Africa
0239             case 'waf'
0240                 regionstrlong ='West Africa';
0241                 blcorner = [-12,-20]; trcorner = [22,18];
0242             case 'eaf'
0243                 regionstrlong ='East Africa';
0244                 blcorner = [-12,22]; trcorner = [18,52];
0245             case 'saf'
0246                 regionstrlong ='South Africa';
0247 %                 disp('WARNING: hard-coded bounding corners dont ')
0248 %                 disp('         correspond to those on p856 in AR4 IPCC rapport')
0249 %                 disp('         and have been adjusted to figure 11.26 p923')
0250 %                 disp('i.e. 35S,10E - 12S,52E has been adjusted to 35S,-10E - 12S,52E')
0251                 blcorner = [-35,-10]; trcorner = [-12,52];
0252             case 'sah'
0253                 regionstrlong ='Sahara';
0254 %                 disp('WARNING: hard-coded bounding corners dont ')
0255 %                 disp('         correspond to those on p856 in AR4 IPCC rapport')
0256 %                 disp('         and have been adjusted to figure 11.26 p923')
0257 %                 disp('i.e. 18N,20E - 30N,65E has been adjusted to 18N,20W - 30N,65E')
0258                 blcorner = [18,-20]; trcorner = [30,65];
0259                 
0260                 %Europe
0261             case 'neu'
0262                 regionstrlong ='Northern Europe';
0263                 blcorner = [48,-10]; trcorner = [75,40];
0264             case 'sem'
0265                 regionstrlong ='Southern Europe and Mediterranean';
0266                 blcorner = [30,-10]; trcorner = [48,40];
0267                 
0268                 %Asia
0269             case 'nas'
0270                 regionstrlong ='Nothern Asia';
0271                 blcorner = [50,40]; trcorner = [70,180];
0272             case 'cas'
0273                 regionstrlong ='Central Asia';
0274                 blcorner = [30,40]; trcorner = [50,75];
0275             case 'tib'
0276                 regionstrlong ='Tibetan Plateau';
0277 %                 disp('WARNING: hard-coded bounding corners dont ')
0278 %                 disp('         correspond to those on p856 in AR4 IPCC rapport')
0279 %                 disp('         and have been adjusted to figure 11.26 p923')
0280 %                 disp('i.e. 30N,50E - 75N,100E has been adjusted to 30N,75E - 50N,100E')
0281                 blcorner = [30,75]; trcorner = [50,100];
0282             case 'eas'
0283                 regionstrlong ='East Asia';
0284                 blcorner = [20,100]; trcorner = [50,145];
0285             case 'sas'
0286                 regionstrlong ='South Asia';
0287                 %                         disp('         correspond to those on p856 in AR4 IPCC rapport')
0288                 %                         disp('         and have been adjusted to figure 11.26 p923')
0289                 %                         disp('i.e. 5N,64E - 50N,100E has been adjusted to 5N,64E - 30N,100E')
0290                 blcorner = [5,64]; trcorner = [30,100];
0291             case 'sea'
0292                 regionstrlong ='South East Asia';
0293 %                 disp('         correspond to those on p856 in AR4 IPCC rapport')
0294 %                 disp('         and have been adjusted to figure 11.26 p923')
0295 %                 disp('i.e. 11S,95E - 20N,115E has been adjusted to 11S,95E - 20N,')
0296                 blcorner = [-11,95]; trcorner = [20,155];
0297                 
0298                 % North America
0299             case 'ala'
0300                 regionstrlong ='Alaska';
0301                 blcorner = [60,-170]; trcorner = [72,-103];
0302             case 'cgi'
0303                 regionstrlong ='East Canada, Greenland, Iceland';
0304                 blcorner = [50,-103]; trcorner = [85,-10];
0305             case 'wna'
0306                 regionstrlong ='Western North America';
0307 %                 disp('WARNING: hard-coded bounding corners dont ')
0308 %                 disp('         correspond to those on p856 in AR4 IPCC rapport')
0309 %                 disp('         and have been adjusted to figure 11.26 p923')
0310 %                 disp('i.e. 30N,50E - 75N,100E has been adjusted to 30N,130W - 60N,103W')
0311                 blcorner = [30,-130]; trcorner = [60,-103];
0312             case 'cna'
0313                 regionstrlong ='Central North America';
0314                 blcorner = [30,-103]; trcorner = [50,-85];
0315             case 'ena'
0316                 regionstrlong ='Eastern North America';
0317 %                 disp('WARNING: hard-coded bounding corners dont ')
0318 %                 disp('         correspond to those on p856 in AR4 IPCC rapport')
0319 %                 disp('         and have been adjusted to figure 11.26 p923')
0320 %                 disp('i.e. 25N,85W - 50N,50W has been adjusted to 25N,85W - 50N,60W')
0321                 blcorner = [25,-85]; trcorner = [50,-60];
0322                 % Central and South America
0323             case 'cam'
0324                 regionstrlong ='Central America';
0325                 blcorner = [10,-116]; trcorner = [30,-83];
0326             case 'amz'
0327                 regionstrlong ='Amazonia';
0328                 blcorner = [-20,-82]; trcorner = [12,-34];
0329             case 'ssa'
0330                 regionstrlong ='Southern South America';
0331                 blcorner = [-56,-76]; trcorner = [-20,-40];
0332                 
0333                 %Australia and New Zealand
0334             case 'nau'
0335                 regionstrlong ='North Australia';
0336                 blcorner = [-30,110]; trcorner = [-11,155];
0337             case 'sau'
0338                 regionstrlong ='South Australia';
0339                 blcorner = [-45,110]; trcorner = [-30,155];
0340                 %Small islands and oceans
0341             case 'car'
0342                 regionstrlong ='Caribbean';
0343                 blcorner = [10,-85]; trcorner = [25,-60];
0344             case 'ind'
0345                 regionstrlong ='Indian Ocean';
0346                 blcorner = [-35,50]; trcorner = [17.5,100];
0347             case 'med'
0348                 regionstrlong ='Mediterranean Basen';
0349                 blcorner = [30,-5]; trcorner = [45,35];
0350             case 'tne'
0351                 regionstrlong ='Tropical North East Atlantic';
0352                 blcorner = [0,-30]; trcorner = [40,-10];
0353             case 'npa'
0354                 regionstrlong ='North Pacific Ocean';
0355                 blcorner = [0,150]; trcorner = [40,360-120];
0356             case 'spa'
0357                 regionstrlong ='South Pacific Ocean';
0358                 blcorner = [-55,150]; trcorner = [0,360-80];
0359             case 'arc'
0360                 regionstrlong ='Arctic';
0361                 blcorner = [60,-180]; trcorner = [90,180];
0362             case 'ant'
0363                 regionstrlong ='Antarctica';
0364                 blcorner = [-90,-180]; trcorner = [-60,180];
0365         end
0366 end

Generated on Mon 15-Sep-2014 13:31:28 by m2html © 2005