0001 function [h]=timeplt(jd,u,istack,ylims);
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050 yearcut=250;
0051 moncut=20;
0052 daycut=.2;
0053 mincut=0.05;
0054
0055 if strcmp(jd,'demo')
0056 help timeplt
0057 start=[1990 11 1 0 0 0];
0058 stop=[1991 2 1 0 0 0];
0059 jd=julian(start):julian(stop);
0060 u=sin(.1*jd(:)).^2-.5;
0061 v=cos(.1*jd(:));
0062 w=u+i*v;
0063
0064 h=timeplt(jd,[u v abs(w) w],[1 1 2 3]);
0065 title('Demo of Timeplt')
0066 stacklbl(h(1),'East + North velocity','m/s');
0067 stacklbl(h(2),'Speed','m/s');
0068 stacklbl(h(3),'Velocity Sticks','m/s');
0069 return
0070 end
0071
0072
0073
0074
0075 set(0,'DefaultLineclipping','off')
0076
0077 [m,n]=size(u);
0078 if(m==1),u=u(:);m=n;n=1;end;
0079 clf
0080 if(~exist('istack')),
0081 istack=ones(n,1);
0082 end
0083 njd=length(jd);
0084 jd0=jd(1);
0085 jd1=jd(njd);
0086 ndays=jd1-jd0;
0087
0088
0089
0090 nstack=max(istack);
0091
0092 hstack=.70/nstack;
0093 xmin=.13;
0094 ymin=.15;
0095 width=0.77;
0096 h(1)=axes('position',[xmin ymin width hstack]);
0097 set(gca,'units','pixels');...
0098 pos=get(gca,'pos');
0099 xlen=pos(3);
0100 ylen=pos(4);...
0101 font=get(gca,'fontsize');...
0102 label_width=5*font;
0103 nlabel=floor(xlen/label_width);
0104 set(gca,'units','normalized');
0105 fac=ndays/nlabel;
0106
0107 if( fac > yearcut),
0108 xlim=[jd0-180 jd1+180];
0109 elseif(yearcut > fac & fac > moncut),
0110 xlim=[jd0-15 jd1+15];
0111 elseif(moncut > fac & fac > daycut),
0112 xlim=[floor(jd0)-.5 ceil(jd1)+.5];
0113 elseif(daycut > fac & fac > mincut);
0114 xlim=[jd0-1/48 jd1+1/48];
0115 elseif(mincut > fac);
0116
0117
0118
0119 time_offset = (jd1-jd0)*0.025;
0120 xlim=[jd0-time_offset jd1+time_offset];
0121 end
0122 up=u(:,find(istack==1));
0123 if(isreal(up)),
0124 h2=plot(jd,up);...
0125 if(exist('ylims')),
0126 set(gca,'ylim',ylims(1,:));...
0127 end
0128 else
0129 if(exist('ylims')),
0130 ylim=ylims(1,:);
0131 else
0132 y0=min(gmin(imag(up(:))),0);
0133 y1=max(gmax(imag(up(:))),0);
0134 ylim=[y0 y1];
0135 end
0136 set(gca,'units','pixels');
0137 ppos=get(gca,'position');
0138 set(gca,'units','norm');
0139 d=diff(xlim);
0140 uscale=(diff(xlim)/diff(ylim))*(ppos(4)/ppos(3));
0141 vp=imag(up);
0142 up=uscale.*real(up);
0143 x=jd;
0144 xp=x;
0145 yp=zeros(size(xp));
0146 xplot=ones(length(xp),2);
0147 yplot=xplot;
0148 xplot(:,1)=x(:);
0149 xplot(:,2)=xp(:)+up(:);
0150 xplot(:,3)=x(:);
0151 yplot(:,1)=yp(:);
0152 yplot(:,2)=yp(:)+vp(:);
0153 yplot(:,3)=yp(:)*nan;
0154 xplot=xplot';
0155 yplot=yplot';
0156 if(~isempty(find(finite(up(:))))),
0157 plot([jd0 jd1],[0 0],'r-',xplot(:),yplot(:),'r-');...
0158 set(gca,'ylim',ylim);
0159 end
0160 end
0161 set(gca,'xlim',xlim);
0162 if( fac > yearcut),
0163 gregaxy(jd,floor(fac/yearcut));
0164 elseif(yearcut >= fac & fac>moncut),
0165 gregaxm(jd,floor(fac/moncut));
0166 elseif(moncut >= fac & fac>daycut),
0167 gregaxd(jd,ceil(fac));
0168 elseif(daycut >= fac & fac> mincut);
0169 gregaxh(jd,max(1,floor(fac*48)));
0170 elseif(mincut >= fac);
0171 gregaxmi(jd,max(1,floor(fac*120*24)));
0172 end
0173 if(nstack==1),return,end
0174 pos_norm=get(gca,'position');
0175 vsep=1.3*font*pos_norm(4)/pos(4);
0176 for iplot=2:nstack,
0177 h(iplot)=axes('position',[xmin ymin+(hstack+vsep)*(iplot-1) width hstack]);
0178 up=u(:,find(istack==iplot));
0179 if(isreal(up)),
0180 plot(jd,up);
0181 if(exist('ylims')),
0182 set(gca,'ylim',ylims(iplot,:))
0183 end
0184 else
0185 if(exist('ylims')),
0186 ylim=ylims(iplot,:);
0187 else
0188 y0=min(0,gmin(imag(up(:))));
0189 y1=max(0,gmax(imag(up(:))));
0190 ylim=[y0 y1];
0191 end
0192 set(gca,'units','pixels');
0193 ppos=get(gca,'position');
0194 set(gca,'units','norm');
0195 d=diff(xlim);
0196 uscale=(diff(xlim)/diff(ylim))*(ppos(4)/ppos(3));
0197 vp=imag(up);
0198 up=uscale.*real(up);
0199 x=jd;
0200 xp=x;
0201 yp=zeros(size(xp));
0202 xplot=ones(length(xp),2);
0203 yplot=xplot;
0204 xplot(:,1)=x(:);
0205 xplot(:,2)=xp(:)+up(:);
0206 xplot(:,3)=x(:);
0207 yplot(:,1)=yp(:);
0208 yplot(:,2)=yp(:)+vp(:);
0209 yplot(:,3)=yp(:)*nan;
0210 xplot=xplot';
0211 yplot=yplot';
0212 if(~isempty(find(finite(up(:))))),
0213 plot([jd0 jd1],[0 0],'r-',xplot(:),yplot(:),'r-');...
0214 set(gca,'ylim',ylim);
0215 end
0216 end
0217 set(gca,'xlim',xlim,'xtick',get(h(1),'xtick'),'xticklabels',[]);
0218 end
0219 set(0,'DefaultLineclipping','on')