pro rotat2,u,v,w,theta,phi,badval,ur,vr,wr ; ROTAT2 takes previously computed rotation angles (theta, phi) and ; applies them to u,v,w data. Works with ANGLES.PRO which computes ; the rotation angles, theta and phi. Separating rotation from computing ; the rotation angles allows angles to be computed from a long-term ; data set, and rotation to be applied to hourly (or other short) time series. ; Ken Davis, June, 1996, taken from ROTATED.PRO. ; ;Written from rotat.pro by BWBerger 7/28/99 to make output separate from ;input. u,v,w used to come in un-rotated and ;go out rotated (i.e., rotated u,v,w used to overwrite un-rotated u,v,w). ; Get indices of good data points g = where(u ne badval, gn) h = where(v ne badval, hn) k = where(w ne badval, kn) if ((theta eq badval) or (phi eq badval) or (gn eq 0) or (hn eq 0) or (kn eq 0)) then begin print,'ANGLES AND/OR VELOCITIES BAD - NO ROTATION DONE' printf,8,'ANGLES AND/OR VELOCITIES BAD - NO ROTATION DONE' ur=u*0.-999. vr=u*0.-999. wr=u*0.-999. endif else begin if ((theta ne badval) and (phi ne badval)) then begin ; Initialize rotation matrix r = dblarr(3,3,/NOZERO) r(0,0) = cos(theta) * cos(phi) r(0,1) = -sin(phi) r(0,2) = -sin(theta) * cos(phi) r(1,0) = cos(theta) * sin(phi) r(1,1) = cos(phi) r(1,2) = -sin(theta) * sin(phi) r(2,0) = sin(theta) r(2,1) = 0 r(2,2) = cos(theta) ; Rotate winds ur = u vr = v wr = w a = [[u],[v],[w]] # r if (gn gt 0) then ur(g) = float(a(g,0)) if (hn gt 0) then vr(h) = float(a(h,1)) if (kn gt 0) then wr(k) = float(a(k,2)) a = 0 endif endelse return end