Home > atmlab > geoplots > gmt > test_gmt.m

test_gmt

PURPOSE ^

TEST_GMT To test various aspecs of gmt_plot

SYNOPSIS ^

function [info, files] = test_gmt(in)

DESCRIPTION ^

 TEST_GMT To test various aspecs of gmt_plot

 PURPOSE: To test various aspecs of gmt_plot. Especially before commiting
          changes

 USAGE: [info,files] = test_gmt(in)

 IN   structure of arguments to be additionally used
      in the test_gmt call/s. I.e. it will use the default values for each
      test and the addional options added by the user (which have precedence).
      -----------
      in.test: If you only want to run a subset of tests, e.g. in.test =
      [1,3,4] runs tests 1,3,4. The default behaviour is to run all tests ([1:7])

      -----------


 OUT: files = cellarray of paths to created figures
      info  = cellarray of information about each test. The information is
              also displayed at the end of the run.

 created by Salomon Eliasson
 $Id: test_gmt.m 8570 2013-08-10 18:36:48Z seliasson $

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

DOWNLOAD ^

test_gmt.m

SOURCE CODE ^

0001 function [info, files] = test_gmt(in)
0002 % TEST_GMT To test various aspecs of gmt_plot
0003 %
0004 % PURPOSE: To test various aspecs of gmt_plot. Especially before commiting
0005 %          changes
0006 %
0007 % USAGE: [info,files] = test_gmt(in)
0008 %
0009 % IN   structure of arguments to be additionally used
0010 %      in the test_gmt call/s. I.e. it will use the default values for each
0011 %      test and the addional options added by the user (which have precedence).
0012 %      -----------
0013 %      in.test: If you only want to run a subset of tests, e.g. in.test =
0014 %      [1,3,4] runs tests 1,3,4. The default behaviour is to run all tests ([1:7])
0015 %
0016 %      -----------
0017 %
0018 %
0019 % OUT: files = cellarray of paths to created figures
0020 %      info  = cellarray of information about each test. The information is
0021 %              also displayed at the end of the run.
0022 %
0023 % created by Salomon Eliasson
0024 % $Id: test_gmt.m 8570 2013-08-10 18:36:48Z seliasson $
0025 
0026 if ~exist('in','var'); in=struct([]); end
0027 
0028 % SET some defaults
0029 alltests = 1:16;
0030 default.test      = alltests; % which tests to do (default=all)
0031 
0032 in = optargs_struct(in,default);
0033 testDataResolution=1;
0034 [gridded,ungridded] = test_generate_data_sin_cos(testDataResolution);
0035 
0036 [files,info]           = TEST(in,gridded,ungridded);
0037 default.display   = true;
0038 default.filename  = 'all_tests' ;
0039 od = isfield(in,'outdir');
0040 default.outdir    = gmtlab('OUTDIR');
0041 in = optargs_struct(in,default);
0042 
0043 % for the final pdfs
0044 
0045 if isequal(in.test,alltests) % if all tests
0046     default.cols = [3 3 3 2 1 3 1];
0047 else
0048     default.cols = 2;
0049 end
0050 
0051 in = optargs_struct(in,default);
0052 
0053 if ~ischar(in.outdir)
0054     in.outdir = tempdir;
0055     in.outdir = in.outdir(1:end-1);
0056 end
0057 
0058 warning('off','catstruct:DuplicatesFound') %I'm intentially doing this often
0059 
0060 % PUT all figure in one pdf
0061 files{end+1} = combine_pdfs(files,struct('title','GMT plots: testing its functionality','fontsize','1cm','filename',[in.filename,'.pdf'],'cols',in.cols,'valign','b','outdir',in.outdir,'display',in.display));
0062 
0063 % DISPLAY information about the tests
0064 disp(' ')
0065 disp(' ')
0066 cellfun(@fprintf,info,'uniformoutput',false)
0067 disp('Look at help gmt_plot for more detailed descriptions of options ')
0068 disp('specified here. I suggest looking at the call for each test in test_gmt')
0069 disp('if you want to see an example on how to create these figures.')
0070 disp(' ')
0071 disp('All the tests where merged onto one pdf using combine_pdfs.m.')
0072 
0073 warning('on','gmtcatstruct:DuplicatesFound')
0074 
0075 if ~od && ~ischar(gmtlab('OUTDIR'))
0076     a = sprintf('Files are saved in your tempdir (%s)',in.outdir);
0077     in.outdir = in.outdir(1:end-1);
0078     b = 'It is better to set a default directory.';
0079     c = 'I.e by setting gmtlab(''OUTDIR'',''<Somewhere>''), e.g. in startup.m';
0080     d = 'Setting this, or inputting a valid directory: in.outdir will suppress this message.';
0081     fprintf(2,'Warning: %s\n%s\n%s\n%s',a,b,c,d);
0082 end
0083 
0084 if nargout==0
0085     clear info files
0086 end
0087 fprintf('Output file saved at: %s/%s.pdf\n',in.outdir,in.filename)
0088 
0089 end
0090 %%%%%%%%%%%%%%%%%
0091 % SUB FUNCTIONS
0092 %    |||||||
0093 %    vvvvvvv
0094 
0095 function [files,info]           = TEST(in,gridded,ungridded)
0096 
0097 info = cell(1,length(in.test));
0098 files = cell(1,length(in.test));
0099 default.display = false;
0100 in = optargs_struct(in,default);
0101 
0102 ind = 1;
0103 for T = sort(in.test)
0104     switch T
0105         case 1
0106             %% TEST: Difference plot, reference=0, nlevels, sidebar
0107             test.header        = 'gridded: titleĀ² * @~D@~r@+-2@~g@~@+, unit';
0108             test.unit         = 'kg/mĀ²';
0109             test.basemap_axis = 'neSW';
0110             test.legend.tick_spacing = 25;
0111             
0112             in.filename = sprintf('Test%g',T);
0113             files{ind} = gmt_plot(catstruct(gridded,in,test),'data');
0114             
0115             info{ind} = ['Test:' num2str(T) ' demonstrates that you can include some special',...
0116                 'characters in in.header and in.unit. This test uses ',...
0117                 'gridded data, where size(data) = [length(lat),length(lon)]',...
0118                 'Use in.header_offset my shift the title wrt the plot',...
0119                 'You can also change the size and position of the legend',...
0120                 '(''x-displacement/y-displacement/height/width''))',...
0121                 'Here the tick-interval is fixed to every 25th level using in.legend.tick_spacing = 25\n\n'];
0122             
0123         case 2
0124             
0125             test.data = gridded.data-200;  % for difference
0126                         test.lat = gridded.lat;
0127             test.lon = gridded.lon;
0128             test.unit='';
0129             test.xunit='kg/m@+2';
0130             test.ctable = 'mypolar';
0131             test.reference = 0;
0132             test.legend.sidebar = 3; % both above and below
0133             test.basemap_axis = 'neSW';
0134             test.header = 'Diff plot,ref=0,sidebar=3 (above & below)';
0135             test.legend.tick_spacing = 25;
0136             in.filename = sprintf('Test%g',T);
0137             files{ind} = gmt_plot(catstruct(in,test),'data');
0138             
0139             info{ind} = ['Test:' num2str(T) ' demonstrates the mypolar-colortable which is similar to polar.cpt',...
0140                 'Using in.ctable=''mypolar'' you can define where the reference value',...
0141                 'should be (here in.reference = 0). The white color is centered around this value.',...
0142                 'in.basemap_axis = ''nSeW'' is tested, and means that the south (S) and west(W)',...
0143                 'axes are labelled. in.sidebar = 3 is tested and means that triangles',...
0144                 'above and below legend-range are shown to indicate the color of data outside the datarange',...
0145                 'defined by in.datarange = [min max]. The title offset is set to -0.5 here (moving it down)',...
0146                 'using in.header_offset = -0.5; See help gmt_plot for more details on these options\n\n'];
0147             
0148         case 3
0149 
0150             test.data = gridded.data-200;  % for difference
0151             test.lat = gridded.lat;
0152             test.lon = gridded.lon;
0153             test.unit='';
0154             test.xunit='kg/m@+2';
0155             test.ctable = 'mypolar';
0156             test.reference = 0;
0157             test.legend.tick_spacing = 25;
0158             test.legend.sidebar = 2; % above only
0159             test.basemap_axis = 'Nesw';
0160             test.nlevels = 15;
0161             test.nwhite = 6;
0162             test.header_fontsize = '20p';
0163             test.header = 'Diff plot,nlevels=15,nwhite=6,sidebar=2 (above only),header';
0164             in.filename = sprintf('Test%g',T);
0165             
0166             %this puts standardize_geodata.m to the test
0167             test.data=test.data'; test.data = test.data(end:-1:1,end:-1:1);
0168             test.lat = test.lat(end:-1:1);
0169             test.lon = test.lon(end:-1:1);
0170             files{ind} = gmt_plot(catstruct(in,test),'data');
0171             
0172             info{ind} = ['Test:' num2str(T) ' demonstrates that you can change the number of intervals that are',...
0173                 'colored white around the reference value when using the mypolar-colortable,',...
0174                 'here in.nwhite = 6. You can also change the number of data intervals ',...
0175                 '(here in.nlevels = 15), change in.headersize (here in.headersize = 20)',...
0176                 'or decide to only have the sidebar for values above the datarange (here in.sidebar=2)\n\n'];
0177             
0178         case 4
0179             
0180             %% TEST: title, unit (gridded and ungridded)
0181             test.nearneighbor.resolution = 1;
0182             test.unit            = 'kg/m@+2';
0183             test.basemap_axis    = 'nEsW';
0184             test.header          = sprintf('Font: ''Courier'': ungridded: %.0f [deg]',test.nearneighbor.resolution);
0185             test.header_font     = 'Courier';
0186             test.coast.width     = 1;
0187             test.coast.color     = '255/255/255';
0188             test.legend.orientation  = 'h';
0189             in.filename          = sprintf('Test%g',T);
0190             files{ind} = gmt_plot(catstruct(ungridded,test,in),'data');
0191             
0192             info{ind} = ['Test:' num2str(T) ' demonstrates the same data as Test1a except in an ungridded form.',...
0193                 'Test 2a is chosen to show that the user can decide how far to look for the next point',...
0194                 'The search radius, where the values within are used to calculate the grid value,',...
0195                 'is automatically in.nearneighbor * 1.5',...
0196                 'isequal(size(in.data),size(in.lat),size(in.lon))==1. This is e.g. good',...
0197                 'for plotting satellite granule data directly. You can also change the',...
0198                 'color of the coastlines, e.g. in.coast.color = ''255/255/255.''\n\n'];
0199             
0200         case 5
0201             %% test 2b
0202             test.nearneighbor.resolution = 10;
0203             test.unit            = 'kg/m@+2';
0204             test.basemap_axis    = 'nEsW';
0205             test.coast.width     = 1;
0206             test.coast.color     = '255/255/255';
0207             test.legend.orientation  = 'h';
0208             test.header_font   = 8;
0209             test.header        = sprintf('Font: 8. ungridded: %.0f [deg]',test.nearneighbor.resolution);
0210             in.filename        = sprintf('Test%g',T);
0211             files{ind} = gmt_plot(catstruct(ungridded,test,in),'data');
0212             
0213             info{ind} = ['Test:' num2str(T) ' is chosen to show that the user can decide how far to look for the next point',...
0214                 'The search radius, where the values within are used to calculate the grid value,',...
0215                 'is automatically set to in.nearneighbor.resolution * 1.5',...
0216                 'isequal(size(in.data),size(in.lat),size(in.lon))==1. This is e.g. good',...
0217                 'for plotting satellite granule data directly. You can also change the',...
0218                 'color of the coastlines, e.g. in.coast.color = ''255/255/255.''\n\n'];
0219             
0220         case 6
0221             %% test 2c
0222             test.nearneighbor.resolution = 60;
0223             test.unit            = 'kg/m@+2';
0224             test.coast.width     = 1;
0225             test.coast.color     = '255/255/255';
0226             test.legend.orientation  = 'h';
0227             test.header_font   = 'Times-Roman';
0228             test.basemap_axis    = 'neSW';
0229             test.header        = sprintf('ungridded: resolution = %g [deg]',test.nearneighbor.resolution);
0230             test.legend.orientation  = 'v';
0231             in.filename        = sprintf('Test%g',T);
0232             files{ind} = gmt_plot(catstruct(ungridded,test,in),'data');
0233             
0234             info{ind} = ['Test:' num2str(T) ' is chosen to show that the user can decide how far to look for the next point',...
0235                 'The search radius, where the values within are used to calculate the grid value,',...
0236                 'is automatically set to in.nearneighbor.resolution * 1.5',...
0237                 'isequal(size(in.data),size(in.lat),size(in.lon))==1. This is e.g. good',...
0238                 'for plotting satellite granule data directly. You can also change the',...
0239                 'color of the coastlines, e.g. in.coast.color = ''255/255/255.''\n\n'];
0240             
0241         case 7
0242             
0243             %% TEST: sidebar, nan, projection, center
0244             
0245             gridded.data(20:40,20:80) = NaN;
0246             test.datarange = [160,250];
0247             test.nlevels        = 18;
0248             test.header         = 'upper sidebar, NaN, Hammer projection, center=180';
0249             test.legend.orientation = 'h';
0250             test.projection         =  'H';
0251             test.center             = 180;      % Center map at given center longitude
0252             in.filename             = sprintf('Test%g',T);
0253             files{ind} = gmt_plot(catstruct(gridded,test,in),'data');
0254             
0255             info{ind} = ['Test:' num2str(T) ' demonstrates the Hammer, Robinsson and sinusoidal projections ',...
0256                 '(using in.projection = ''H''/''R''/''I''), ',...
0257                 'one of many available projections. The test also demonstrates that you can',...
0258                 'easily change the center of the projection to e.g. 180E using in.center = 180.',...
0259                 'The grey region in the map indicates NaN values, and an extra NaN color box',...
0260                 'is automatically added below the vertical legend. You can suppress the extra',...
0261                 'NaN-legend using in.nanlegend = false. The upper sidebar is automatically shown',...
0262                 'if there are data larger than in.datarange(2), given via in.datarange = [v1,v2].',...
0263                 'The color for these values can be changed using',...
0264                 'in.color_foreground (default is ''255/255/255'' (white))',...
0265                 'Test ' num2str(T) ' also shows the use of in.legend.tick_spacing = default,10,15 for a,b,c respectively.\n\n'];
0266             
0267         case 8
0268             
0269             gridded.data(20:40,20:80) = NaN;
0270             test.datarange = [160,250];
0271             test.nlevels        = 18;
0272             test.legend.orientation = 'h';
0273             test.header               = 'Robinsson projection, center = 0 ';
0274             test.projection          = 'N';
0275             test.center              = 0;
0276             test.legend.tick_spacing = 10;
0277             test.extra_legend        = struct('name','nan','type','nan');
0278             in.filename              = sprintf('Test%g',T);
0279             
0280             files{ind} = gmt_plot(catstruct(gridded,test,in),'data');
0281             
0282             info{ind} = ['Test:' num2str(T) ' demonstrates the Hammer, Robinsson and sinusoidal projections ',...
0283                 '(using in.projection = ''H''/''R''/''I''), ',...
0284                 'one of many available projections. The test also demonstrates that you can',...
0285                 'easily change the center of the projection to e.g. 180E using in.center = 180.',...
0286                 'The grey region in the map indicates NaN values, and an extra NaN color box',...
0287                 'is automatically added below the vertical legend. You can suppress the extra',...
0288                 'NaN-legend using in.nanlegend = false. The upper sidebar is automatically shown',...
0289                 'if there are data larger than in.datarange(2), given via in.datarange = [v1,v2].',...
0290                 'The color for these values can be changed using',...
0291                 'in.color_foreground (default is ''255/255/255'' (white))',...
0292                 'Test ' num2str(T) ' also shows the use of in.legend.tick_spacing = default,10,15 for a,b,c respectively.\n\n'];
0293             
0294         case 9
0295             
0296             gridded.data(20:40,20:80) = NaN;
0297             test.nlevels        = 18;
0298             test.legend.orientation = 'h';
0299             test.datarange          = [160,250];% displayed value range. Sidebar triangles shown for data outside range.
0300             test.extra_legend           = struct('name','nan','type','nan','position','0i/0i/2c/2ch','fontsize','25p');
0301             test.legend.position        = '12c/0c/20c/2ch';
0302             test.legend.font_size       = '20p';
0303             test.legend.tick_spacing    = 15;
0304             test.header                 = 'Sinusoidal projection, center = 90';
0305             test.projection             = 'I';
0306             test.center                 = 90;
0307             in.filename                 = sprintf('Test%g',T);
0308             
0309             files{ind} = gmt_plot(catstruct(gridded,test,in),'data');
0310             
0311             info{ind} = ['Test:' num2str(T) ' demonstrates the Hammer, Robinsson and sinusoidal projections ',...
0312                 '(using in.projection = ''H''/''R''/''I''), ',...
0313                 'one of many available projections. The test also demonstrates that you can',...
0314                 'easily change the center of the projection to e.g. 180E using in.center = 180.',...
0315                 'The grey region in the map indicates NaN values, and an extra NaN color box',...
0316                 'is automatically added below the vertical legend. You can suppress the extra',...
0317                 'NaN-legend using in.nanlegend = false. The upper sidebar is automatically shown',...
0318                 'if there are data larger than in.datarange(2), given via in.datarange = [v1,v2].',...
0319                 'The color for these values can be changed using',...
0320                 'in.color_foreground (default is ''255/255/255'' (white))',...
0321                 'Test ' num2str(T) ' also shows the use of in.legend.tick_spacing = default,10,15 for a,b,c respectively.\n\n'];
0322             
0323         case 10
0324             %% TEST: contours, nlevels, annotation format, xunit
0325             
0326             test.lat = -90+.5:90-.5;
0327             test.lon = -180+.5:180-.5;
0328             for j = test.lat
0329                 for i = test.lon
0330                     test.data(j+90.5,i+180.5) = ((0.1*sin((j+91)/18*pi))+sin((j+91)/180*pi))*(0.1*cos(i/36*pi)+cos(i/360*pi));
0331                 end
0332             end
0333             
0334             test.header = 'contours, HSV colours, horiz. legend';
0335             test.projection = 'H';
0336             test.nlevels = 10;
0337             test.tick_annotation_format = '%g';
0338             test.legend.orientation = 'h';
0339             test.contourline.spacing=0.1;
0340             test.contourline.range=[0 1];
0341             test.contourline.linethick=1;
0342             test.contourline.more='-T1c/0.001c:LH';
0343             test.datarange = [0, 1];
0344             test.color_background = '255/0/0';
0345             test.color_foreground = '255/255/0';
0346             test.colorrange.colors = {{0,'0/1/1'},{1,'60/1/1'}};
0347             test.colorrange.color_model = 'HSV';
0348             test.nlevels = 5;
0349             
0350             % TEST pstext aswell
0351             test.pstext = struct('text',{'Norrland','Australia'},...
0352                 'lat',{67+51/60,-25},'lon',{20+13/60,130},'angle',{0,-15},...
0353                 'color','0/255/0');
0354             
0355             in.filename = sprintf('Test%g',T);
0356             files{ind} = gmt_plot (catstruct(test,in), 'data');
0357             
0358             info{ind} = ['Test:' num2str(T) ' demonstrates contour maps (see contour options in help gmt_plot), ',...
0359                 'where you can optionally choose to show highs and lows in the of the data.',...
0360                 'It also demonstrated that you can have x and y-labels',...
0361                 '(in.xunit=''no unit either'' and in.unit=''no unit'') around the legend',...
0362                 'Using the custom colortable (in.colorrange) you can also use',...
0363                 'in.colorrange.color_model = ''HSV'' instead of the default ''RGB''. I also test'...
0364                 'plotting text on top of the map using pstext\n\n'];
0365             
0366         case 11
0367             
0368             test.lat        = (-30:30)-.5;
0369             test.lon        = (152:240)-.5;
0370             test.data       = gridded.data(...
0371                 gridded.lat>=test.lat(1)&gridded.lat<=test.lat(end),...
0372                 (gridded.lon+180)>=test.lon(1)&(gridded.lon+180)<=test.lon(end));
0373             test.filename     = sprintf('Test%g',T);
0374             test.header       = 'Region that spans the dateline';
0375             test.legend.xpos= 20.7;
0376             files{ind}      = gmt_plot (catstruct(test,in), 'data');
0377             info{ind}       = ['Test:' num2str(T) ' demonstrates data that crosses the dateline, but is not global\n\n'];
0378             
0379             
0380         case 12
0381             %% TEST: custom color table, header_size, map_width, grid lines, region
0382             
0383             % Add some annotations some intervals.
0384             if ~isfield(in,{'stepsize','nlevels'})
0385                 % assuming we have 20 levels, test the following
0386                 tmp = repmat({''},1,20);
0387                 tmp{1} = 'blue'; tmp{6} = 'light blue'; tmp{10} = 'green'; tmp{15} = 'black'; tmp{20} = 'red';
0388                 test.legend.tick_annotations = tmp;
0389             end
0390             test.header = 'custom legend and sub-region';
0391             test.ticks = '30g30/15g15'; % annotations (deg) on major lines (e.g 40 xaxis,20 yaxis)
0392             % and plot minor lines (e.g 20 xaxis & yaxis)
0393             test.head_size = 20;              % (GMT default = 36p)
0394             test.map_width = '17i';              % (default is 9 inches)
0395             test.region    = '-130/130/-30/30'; % 'lonmin/lonmax/latmin/latmax'
0396             test.basemap_axis = 'NeSW';
0397             test.legend.tick_centering = true;
0398             
0399             % CUSTOM COLOR TABLE ---
0400             % For your own custom colortable use in.colorrange.colors (see below). Assign a
0401             % color to a relative value, e.g between 0-1, where 0 is for the minimum of the
0402             % datarange and 1 is for the color of the maximum datarange. For example,
0403             test.colorrange.colors  = {{0,'0/0/255'},...
0404                 {0.3,'255/255/255'},...
0405                 {0.5,'0/255/0'},...
0406                 {.7,'0/0/0'},...
0407                 {1,'255/0/0'}};
0408             test.colorrange.color_model = 'RGB';
0409             % makes a colortable that goes from blue to white to green to black to red in RGB format.
0410             % ------------------------
0411             
0412             in.filename = sprintf('Test%g',T);
0413             files{ind} = gmt_plot(catstruct(gridded,test,in),'data');
0414             
0415             info{ind} = ['Test:' num2str(T) ' demonstrates that you can easily make your own custom colortable using in.colorrange.',...
0416                 'You can also insert your own legend annotations to be used instead of',...
0417                 'data values using in.legend.tick_annotations. You can also change in.mapwidth,',...
0418                 'in.headersize, the tick spacing for the axis using in.ticks,',...
0419                 'and in this test its demonstrated how to confine the figure to certain',...
0420                 'geographical regions using in.region = ''lonmin/lonmax/latmin/latmax''',...
0421                 'The legend is also automatically made horizontal if the base/height > 3',...
0422                 'This can easily be overridden by setting in.orientation.orientation = ''v'' \n\n'];
0423             
0424         case 13
0425             
0426             [names,lats,lons,textcolor,color,textalign,textsize,shape,sze] = satGroupLocations;
0427             
0428             
0429             for i = 1:length(names)
0430                 test.locations(i).lat = lats(i);
0431                 test.locations(i).lon = lons(i);
0432                 test.locations(i).name = names{i};
0433                 test.locations(i).shape = shape{i};
0434                 test.locations(i).size = sze{i};
0435                 test.locations(i).color = color{i};
0436                 test.locations(i).textsize = textsize(i);
0437                 test.locations(i).textcolor= textcolor{i};
0438                 test.locations(i).textalign = textalign{i};
0439             end
0440             test.basemap_axis = 'neSW';
0441             test.header = 'SatGroup locations';
0442             test.nodata = true;
0443             test.region = '-20/160/-30/70';
0444             in.filename = sprintf('Test%g',T);
0445             files{ind} = gmt_plot(catstruct(test,in));
0446             
0447             info{ind} = ['Test' num2str(T) ' demonstrates that you can plot points and text on a map using',...
0448                 'in.locations (see help gmt_plot), and demonstrates that there are',...
0449                 'several map resolutions available.',...
0450                 'The available file types in.figuretype are ''pdf'',''eps'',''png'', and ''tif''\n\n'];
0451             
0452         case 14
0453             
0454             [names,lats,lons,textcolor,color,textalign,~,shape,sze] = satGroupLocations;
0455             
0456             for i = 1:length(names)
0457                 test.locations(i).lat = lats(i);
0458                 test.locations(i).lon = lons(i);
0459                 test.locations(i).name = names{i};
0460                 test.locations(i).shape = shape{i};
0461                 test.locations(i).size = sze{i};
0462                 test.locations(i).color = color{i};
0463                 test.locations(i).textsize = 15;
0464                 test.locations(i).textcolor= textcolor{i};
0465                 test.locations(i).textalign = textalign{i};
0466             end
0467             test.basemap_axis = 'neSW';
0468             test.nodata = true;
0469             test.region     = '-10/30/45/70';
0470             test.header      = 'SatGroup locations: Europe';
0471             test.coast.rivers = 'r';
0472             in.filename = sprintf('Test%g',T);
0473             files{ind}    = gmt_plot(catstruct(test,in));
0474             info{ind} = ['Test' num2str(T) ' demonstrates that you can plot points and text on a map using',...
0475                 'in.locations (see help gmt_plot), and demonstrates that there are',...
0476                 'several map resolutions available.',...
0477                 'The available file types in.figuretype are ''pdf'',''eps'',''png'', and ''tif''\n\n'];
0478             
0479         case 15
0480             
0481             [names,lats,lons,textcolor,color,textalign,~,shape,sze] = satGroupLocations;
0482             
0483             for i = 1:length(names)
0484                 test.locations(i).lat = lats(i);
0485                 test.locations(i).lon = lons(i);
0486                 test.locations(i).name = names{i};
0487                 test.locations(i).shape = shape{i};
0488                 test.locations(i).size = sze{i};
0489                 test.locations(i).color = color{i};
0490                 test.locations(i).textsize = 15;
0491                 test.locations(i).textcolor= textcolor{i};
0492                 test.locations(i).textalign = textalign{i};
0493             end
0494             test.basemap_axis = 'neSW';
0495             test.nodata = true;
0496             
0497             
0498             % TEST: smallregion
0499             test.header = 'SatGroup locations: Kiruna';
0500             test.region = '16/22/66.2/70';
0501             test.coast.rivers = 'a';
0502             in.filename = sprintf('Test%g',T);
0503             files{ind} = gmt_plot(catstruct(test,in));
0504             
0505             
0506             info{ind} = ['Test' num2str(T) ' demonstrates that you can plot points and text on a map using',...
0507                 'in.locations (see help gmt_plot), and demonstrates that there are',...
0508                 'several map resolutions available.',...
0509                 'The available file types in.figuretype are ''pdf'',''eps'',''png'', and ''tif''\n\n'];
0510             
0511         case 16
0512             %% TEST: pspolygon
0513             
0514             % REGIONS FROM eliasson11:assessing_acp
0515             a = [-12    80    16   100;...
0516                 -8   100    14   155;...
0517                 -12   155    10   175;...
0518                 35   -70    45   -40;...
0519                 45   -55    60   -10;...
0520                 33   145    40   180;...
0521                 40   160    50   180;...
0522                 36  -180    50  -160;...
0523                 40  -160    55  -135;...
0524                 -27  -110   -18   -72;...
0525                 -18  -130     2   -82;...
0526                 -30   -15    -5    10;...
0527                 -20   -30    -5   -15;...
0528                 -16    15    -5    30;...
0529                 -5    11     0    33;...
0530                 0     0     8    34;...
0531                 -14   -72    -5   -50;...
0532                 -5   -79     0   -56;...
0533                 0   -80    10   -60];
0534             
0535             reg = polygoninize_regions(a);
0536             
0537             % special for swl
0538             swl = {[-180  -60; -180 -45],[-180  -45; -80 -45],[-80  -45; -80 -60],...
0539                 [-80  -60; -180 -60],[-50  -60; -50 -45],[-50  -45; 60 -45],...
0540                 [60  -45; 180 -45],[180  -45; 180 -60],[180  -60; 60 -60],[60  -60; -50 -60],...
0541                 [-180  -60; -180 -45],[-180  -45; -80 -45],[-80  -45; -80 -60],[-80  -60; -180 -60],...
0542                 [-50  -60; -50 -45],[-50  -45; 60 -45],[60  -45; 180 -45],...
0543                 [180  -45; 180 -60],[180  -60; 60 -60],[60  -60; -50 -60]}';
0544             
0545             test.pspoly = [reg;swl];
0546             swlcols = repmat({'g'},1,length(swl));
0547             test.pspolycolor = {'g' 'k' 'r' 'g' 'k' 'r' 'b' 'g' swlcols{:}};
0548             test.nodata=true;
0549             test.basemap_axis='nWeS';
0550             in.filename = sprintf('Test%g',T);
0551             files{ind} = gmt_plot(catstruct(test,in));
0552             
0553             info{ind} = ['Test:' num2str(T) ' demonstrates that you can draw polygons on a map, using in.pspoly.',...
0554                 'E.g. useful if you want to draw regions of interest on a map\n\n'];
0555             
0556         otherwise
0557             error(['atmlab:' mfilename],'Test %g has no entry',T)
0558     end
0559     ind = ind+1;
0560     clear test
0561 end
0562 
0563 end
0564 
0565 function [names,lats,lons,textcolor,color,textalign,textsize,shape,sze] = satGroupLocations()
0566 % List of home towns for people from the SatGroup
0567 
0568 names    = {'Kiruna','Brisbane','Stuttgart','Bremen','Idukki',...
0569     'Oberstdorf','Amsterdam','Lauchhammer','Freiburg','Hyderabad'};
0570 
0571 % Missing: Eskilstuna, Huskvarna
0572 
0573 lats     = [67.85 -27.48 48.83 53.1 9.9 47.3 52.4 51.5 48 17.36];
0574 lons     = [20.216 153 9.2 8 77 10.22 4.77 13.77 7.85 78.48];
0575 
0576 textcolor= repmat({'black'},1,length(names)); textcolor{1} = 'red';
0577 color    = repmat({'green'},1,length(names)); color{3} = 'yellow';
0578 textalign= {'LM','RB','LM','LB','CB','LT','RM','LM','RM','RM'};
0579 textsize = [15,15,7,7,15,7,7,7,7,7];
0580 shape    = repmat({'c'},1,length(names));shape{3} = 'd';
0581 sze      = repmat({.08},1,length(names)); sze{3} = .1;
0582 
0583 end

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