0001 function [handle_structure]=antlatlonoverlay(latstep,lonstep,color,resolution,gap)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012 if ((nargin==0) || (nargin~=5) || (nargout~=1)),
0013 help antlatlonoverlay;
0014 return;
0015 end
0016 handle_structure(1).text='';
0017
0018 step=min(latstep,lonstep);
0019
0020
0021 lat=-90:step:0;
0022 lon=0:step:360;
0023
0024 xlimits=xlim;
0025 ylimits=ylim;
0026
0027 found=0;
0028 for i=1:length(lon),
0029 latitudes=lat;
0030 longitude=lon(i);
0031 [x,y]=ll2xy(lat,lon(i));
0032 if length(find(x>xlimits(1) & x<xlimits(2) & y>ylimits(1) & y<ylimits(2))),
0033 found=1;
0034 break;
0035 end
0036 end
0037
0038 if found==0,
0039 handle_structure=antlatlonoverlay(latstep/2,lonstep/2,color,resolution,gap);
0040 end
0041
0042 pos= find(x>xlimits(1) & x<xlimits(2) & y>ylimits(1) & y<ylimits(2));
0043 thislat=latitudes(pos(1));
0044 thislon=longitude;
0045
0046 latprofile.x=0;
0047 latprofile.y=0;
0048 lonprofile.x=0;
0049 lonprofile.y=0;
0050
0051 longitude=(0:(resolution*4):360)';
0052 for i=0:(90/latstep),
0053 [x,y]=ll2xy((thislat+i*latstep)*ones(length(longitude),1),longitude);
0054 if ~length(find(x>xlimits(1) & x<xlimits(2) & y>ylimits(1) & y<ylimits(2))),
0055 break;
0056 else
0057 pos= find(x>xlimits(1) & x<xlimits(2) & y>ylimits(1) & y<ylimits(2));
0058 latprofile(end+1).x=x(pos);
0059 latprofile(end).y=y(pos);
0060 latprofile(end).lat=thislat+i*latstep;
0061 end
0062 end
0063
0064 for i=0:(90/latstep),
0065 [x,y]=ll2xy((thislat-i*latstep)*ones(length(longitude),1),longitude);
0066 if ~length(find(x>xlimits(1) & x<xlimits(2) & y>ylimits(1) & y<ylimits(2))),
0067 break;
0068 else
0069 pos= find(x>xlimits(1) & x<xlimits(2) & y>ylimits(1) & y<ylimits(2));
0070 latprofile(end+1).x=x(pos);
0071 latprofile(end).y=y(pos);
0072 latprofile(end).lat=thislat-i*latstep;
0073 end
0074 end
0075
0076 latitude=(-90:resolution:0)';
0077 for i=0:(180/lonstep),
0078 [x,y]=ll2xy(latitude,(thislon+i*lonstep)*ones(length(latitude),1));
0079 if ~length(find(x>xlimits(1) & x<xlimits(2) & y>ylimits(1) & y<ylimits(2))),
0080 break;
0081 else
0082 pos= find(x>xlimits(1) & x<xlimits(2) & y>ylimits(1) & y<ylimits(2));
0083 lonprofile(end+1).x=x(pos);
0084 lonprofile(end).y=y(pos);
0085 lonprofile(end).lon=thislon+i*lonstep;
0086 end
0087 end
0088 for i=0:(180/lonstep),
0089 [x,y]=ll2xy(latitude,(thislon-i*lonstep)*ones(length(latitude),1));
0090 if ~length(find(x>xlimits(1) & x<xlimits(2) & y>ylimits(1) & y<ylimits(2))),
0091 break;
0092 else
0093 pos= find(x>xlimits(1) & x<xlimits(2) & y>ylimits(1) & y<ylimits(2));
0094 lonprofile(end+1).x=x(pos);
0095 lonprofile(end).y=y(pos);
0096 lonprofile(end).lon=thislon-i*lonstep;
0097 end
0098 end
0099
0100
0101 latprofile=latprofile(2:end);
0102 lonprofile=lonprofile(2:end);
0103
0104
0105
0106 prof=latprofile(1);
0107 for i=2:length(latprofile),
0108 found=0;
0109 for j=1:length(prof),
0110 if (prof(j).lat==latprofile(i).lat),
0111 found=1;
0112 end
0113 end
0114 if length(latprofile(i).x)<10,
0115 found=1;
0116 end
0117 if found==0,
0118 prof(end+1)=latprofile(i);
0119 end
0120 end
0121 latprofile=prof;
0122
0123 prof=lonprofile(1);
0124 for i=2:length(lonprofile),
0125 found=0;
0126 for j=1:length(prof),
0127 if (prof(j).lon==lonprofile(i).lon),
0128 found=1;
0129 end
0130 end
0131 if length(lonprofile(i).x)<10,
0132 found=1;
0133 end
0134 if found==0,
0135 prof(end+1)=lonprofile(i);
0136 end
0137 end
0138 lonprofile=prof;
0139
0140 hold on;
0141 for i=1:length(latprofile),
0142 l=line(latprofile(i).x,latprofile(i).y,'Color',color);
0143 disp(['Specifiy where to put number for latitude ' num2str(latprofile(i).lat)])
0144 [xcorner,ycorner]=ginput(1);
0145
0146
0147 ind=find_point(latprofile(i).x,latprofile(i).y,xcorner,ycorner);
0148 xcorner=latprofile(i).x(ind);
0149 ycorner=latprofile(i).y(ind);
0150
0151 if length(latprofile(i).x(1:ind))>10,
0152 xcorner2=latprofile(i).x(ind-10);
0153 ycorner2=latprofile(i).y(ind-10);
0154 else
0155 xcorner2=latprofile(i).x(ind-1);
0156 ycorner2=latprofile(i).y(ind-1);
0157 end
0158
0159
0160 angle=180/pi*atan2((ycorner2-ycorner),(xcorner2-xcorner));
0161
0162 if (xcorner>xlimits(1) & xcorner<xlimits(2) & ycorner>ylimits(1) & ycorner<ylimits(2)),
0163 handle_structure(end+1).text=text(xcorner,ycorner,[num2str(latprofile(i).lat) '^{\circ}']);set(handle_structure(end).text,'Color',color,'Rotation',angle,'FontSize',14,'HorizontalAlignment','center','VerticalAlignment','middle');
0164
0165
0166 delete(l);
0167 dl=sqrt((latprofile(i).x(1)-latprofile(i).x(10))^2+(latprofile(i).y(1)-latprofile(i).y(10))^2);
0168 indoffset=floor(10*gap/dl);
0169 handle_structure(end+1).line=line(latprofile(i).x(1:(ind-indoffset)),latprofile(i).y(1:(ind-indoffset)),'Color',color);hold on;
0170 handle_structure(end+1).line=line(latprofile(i).x((ind+indoffset):length(latprofile(i).y)),latprofile(i).y((ind+indoffset):length(latprofile(i).y)),'Color',color);
0171 end
0172 latprofile(i).linehandle=l;
0173 end
0174
0175 for i=1:length(lonprofile),
0176 l=line(lonprofile(i).x,lonprofile(i).y,'Color',color);
0177 if lonprofile(i).lon<180,
0178 disp(['Specifiy where to put number for longitude ' num2str(lonprofile(i).lon)])
0179 [xcorner,ycorner]=ginput(1);
0180
0181 ind=find_point(lonprofile(i).x,lonprofile(i).y,xcorner,ycorner);
0182 xcorner=lonprofile(i).x(ind);
0183 ycorner=lonprofile(i).y(ind);
0184 if length(lonprofile(i).x(1:ind))>10,
0185 xcorner2=lonprofile(i).x(ind-10);
0186 ycorner2=lonprofile(i).y(ind-10);
0187 else
0188 xcorner2=lonprofile(i).x(ind-1);
0189 ycorner2=lonprofile(i).y(ind-1);
0190 end
0191
0192 angle=180/pi*atan2((ycorner2-ycorner),(xcorner2-xcorner));
0193
0194
0195 if (xcorner>xlimits(1) & xcorner<xlimits(2) & ycorner>ylimits(1) & ycorner<ylimits(2)),
0196 handle_structure(end+1).text=text(xcorner,ycorner,[num2str(lonprofile(i).lon) '^{\circ}']);set(handle_structure(end).text,'Color',color,'Rotation',angle,'FontSize',14,'HorizontalAlignment','center','VerticalAlignment','middle');
0197
0198 delete(l);
0199 dl=sqrt((lonprofile(i).x(1)-lonprofile(i).x(10))^2+(lonprofile(i).y(1)-lonprofile(i).y(10))^2);
0200 indoffset=floor(10*gap/dl);
0201 handle_structure(end+1).line=line(lonprofile(i).x(1:(ind-indoffset)),lonprofile(i).y(1:(ind-indoffset)),'Color',color);hold on;
0202 handle_structure(end+1).line=line(lonprofile(i).x((ind+indoffset):length(lonprofile(i).y)),lonprofile(i).y((ind+indoffset):length(lonprofile(i).y)),'Color',color);
0203 end
0204 else
0205 disp(['Specifiy where to put number for longitude ' num2str(360-lonprofile(i).lon)])
0206 [xcorner,ycorner]=ginput(1);
0207
0208 ind=find_point(lonprofile(i).x,lonprofile(i).y,xcorner,ycorner);
0209 xcorner=lonprofile(i).x(ind);
0210 ycorner=lonprofile(i).y(ind);
0211 if length(lonprofile(i).x(1:ind))>10,
0212 xcorner2=lonprofile(i).x(ind-10);
0213 ycorner2=lonprofile(i).y(ind-10);
0214 else
0215 xcorner2=lonprofile(i).x(ind-1);
0216 ycorner2=lonprofile(i).y(ind-1);
0217 end
0218 angle=180/pi*atan2((ycorner2-ycorner),(xcorner2-xcorner));
0219
0220 if (xcorner>xlimits(1) & xcorner<xlimits(2) & ycorner>ylimits(1) & ycorner<ylimits(2)),
0221 handle_structure(end+1).text=text(xcorner,ycorner,[num2str(360-lonprofile(i).lon) '^{\circ}']);set(handle_structure(end).text,'Color',color,'Rotation',angle,'FontSize',14,'HorizontalAlignment','center','VerticalAlignment','middle');
0222
0223 delete(l);
0224 dl=sqrt((lonprofile(i).x(1)-lonprofile(i).x(10))^2+(lonprofile(i).y(1)-lonprofile(i).y(10))^2);
0225 indoffset=floor(10*gap/dl);
0226 handle_structure(end+1).line=line(lonprofile(i).x(1:(ind-indoffset)),lonprofile(i).y(1:(ind-indoffset)),'Color',color);hold on;
0227 handle_structure(end+1).line=line(lonprofile(i).x((ind+indoffset):length(lonprofile(i).y)),lonprofile(i).y((ind+indoffset):length(lonprofile(i).y)),'Color',color);
0228 end
0229 end
0230 lonprofile(i).linehandle=l;
0231 end
0232
0233
0234 handle_structure=handle_structure(2:length(handle_structure));