function sza,log,mtime ; Test a given test log and mission time, calculate the current rotation period ; and solar zenith angle (using Marty Tomasko's formulas) ; For DISR#2. common already_done,doneit,t,t2,in_lock_time,out_of_lock_time,lock_group,oldlog if n_elements(oldlog) eq 0 then goto,initialize if log ne oldlog then goto,initialize if n_elements(doneit) ne 0 then goto,process initialize: ; Does the sun pulse file already exist? fn=findfile(log+'/post/anal_results/sun_pulses') if fn(0) eq '' then list_sun_pulses,log str='' t=dblarr(3,2000) ttemp=dblarr(3) openr,unit,log+'/post/anal_results/sun_pulses',/get_lun readf,unit,str i=0 while not eof(unit) do begin readf,unit,ttemp t(*,i)=ttemp i=i+1 endwhile free_lun,unit t=t(*,0:i-1) t2=reform(t(1,*)) ; Read the message_log to find in-lock and out-of-lock times in_lock_time=dblarr(100) out_of_lock_time=dblarr(100) cmd=string(log+'/message_log',format='("grep using_sun_pulses ",a)') spawn,cmd,results n_usings=n_elements(results) for i=0,n_elements(results)-1 do begin reads,results(i),hr,min,sec,format='(56x,f2.0,1x,f2.0,1x,f7.4)' in_lock_time(i)=3600.D0*double(hr)+60.D0*double(min)+double(sec) endfor in_lock_time=in_lock_time(0:i-1) cmd=string(log,format='("tail -n1 ",a,"/post/anal_results/sun_pulses")') spawn,cmd,results reads,results,o_time,format='(13x,f12.0)' last_time=o_time+0.01 cmd=string(log+'/message_log',format='("grep SunSensor_sig_lost ",a)') spawn,cmd,results n_lost=n_elements(results) if results(0) ne '' then begin k=0 for j=0,(n_usings