pro plot_rate,logname,outfile,tmin,tmax ; This is a modified version of telemetry_rate.pro ; Last modified 20 Jun 00 by CSee (added status flag) ; Compute the telemetry rate (packets per unit time) in a test log. @c_system.inc @c_header.inc !p.font=-1 ;vector drawn fonts ymin=0 ymax=0 xmin=0 xmax=0 STATUS=STRARR(4) ;standard status flag (for d_rhead) ans='' read,' Do you want to set the axes scale? (y or n): ',ans if ans eq 'y' then read,'Input (packets/cycle) ymin,ymax: ',ymin,ymax if ans eq 'y' then read,'Input Mission Time (minutes) xmin,xmax: ',xmin,xmax !y.range=[ymin,ymax] !x.range=[xmin,xmax] ;!x.tickv=[30,60,90,120,150,180,210] cd,'',current=cdir & cd,cdir ;csee 6/6/97 if n_params() eq 0 then logname = cdir ;csee 6/6/97 if n_params() le 1 then outfile =logname+'/telem_rate.out' ;csee 6/6/97 cd,logname spawn,'grep "Telem A" idx',chana ;chana = string array of Ch A idx entries spawn,'grep "Telem B" idx',chanb ;chanb = string array of Ch B idx entries hours=0L mins=0L secs=0L i=0L ans=' ' sa=size(chana) sb=size(chanb) sizea=0L if sa(0) ne 0 then sizea=sa(1) sizeb=0L if sb(0) ne 0 then sizeb=sb(1) if sa(0) ne 0 then timea=lonarr(sizea) else timea=0 ;csee 6/5/97 if sb(0) ne 0 then timeb=lonarr(sizeb) else timeb=0 ;csee 6/6/97 print, ' #1 Read in IDX data' for i=0L,sizea-1 do begin reads,chana(i),hours,mins,secs,format='(9x,i2,1x,i2,1x,i2)' timea(i)=3600L*hours+60L*mins+secs If timea(i) lt timea(0) then timea(i)=timea(i)+86400 ;correct for runs that carry past midnight endfor ;rollover=where(timea lt timea(0)) ;correct for runs that carry past midnight ;if rollover(0) ne -1 then timea(rollover)=timea(rollover)+86400 print, ' #2 Created Ch A time array' for i=0L,sizeb-1 do begin reads,chanb(i),hours,mins,secs,format='(9x,i2,1x,i2,1x,i2)' timeb(i)=3600L*hours+60L*mins+secs If timeb(i) lt timeb(0) then timeb(i)=timeb(i)+86400 ;correct for runs that carry past midnight endfor ;rollover=where(timeb lt timeb(0)) ;correct for runs that carry past midnight ;if rollover(0) ne -1 then timeb(rollover)=timeb(rollover)+86400 print, ' #3 Created Ch B time array' cd,'DB/Time' f=t_getfil() sort_by_mission_time,f,files d_read,files(0),h,p delta_t=p(0,0)/10000. ;mission time of first DDB cd,'../..' print, ' #4 Found offset to first packet' printing: ans = '' filename = '' read, 'Window (w), Printer (p) or EPS (e)? ', ans case ans of 'p': begin set_plot,'ps' !p.font=0 device,filename='~/plot_rate.ps',xoffset=1.0,yoffset=10.01,xsize=9.17,ysize=7.0, $ /landscape,/inches end 'w': window,1,xsize=800,ysize=600 'e': begin set_plot,'ps' !p.font=0 read,'Enter EPS filenome or return to use ~/plot_rate_eps.ps: ',filename if filename eq '' then filename = '~/plot_rate_eps.ps' device,/encapsulated,/preview,filename=filename,xsize=6,ysize=2.5, $ /landscape,/inches end else: goto,printing endcase print, ' #5 Creating A side histogram & timelist' !p.multi=[0,1,2] ;if !d.name eq 'X' then begin ;window,1,xsize=800,ysize=600 ;endif ;if !d.name eq 'PS' then begin ;device,filename='~/plot_rate.ps',xoffset=1.0,yoffset=10.01,xsize=9.17,ysize=7.0, $ ; /landscape,/inches ;endif if sa(0) eq 0 then goto, bside ;cls 6/5/97 ha=histogram(timea,binsize=15L) s=size(ha) numtimes=s(1) t=findgen(numtimes)*15.0+delta_t+7.5 print,'First packet, t(0) = ',t(0),' seconds' print, ' #6 Plotting A side Data' if n_params() ge 3 then begin s=size(tmin) if s(1) eq 7 then begin reads,tmin,hr,min,sec,format='(i2,1x,i2,1x,i2)' t1=3600.*hr+60.*min+sec reads,tmax,hr,min,sec,format='(i2,1x,i2,1x,i2)' t2=3600.*hr+60.*min+sec endif else begin t1=tmin t2=tmax endelse plot,t/60.,ha,psym=10,title=logname+' Channel A',xtitle='Time (min)', $ ytitle='Packets/15sec',charsize=1,color=0,background=255,xrange=[t1,t2] endif else begin plot,t/60.,ha,psym=10,title=logname+' Channel A',xtitle='Time (min)', $ ytitle='Packets/15sec',charsize=1,color=0,background=255 endelse bside: ;cls 6/5/97 if sb(0) eq 0 then goto, printset ;cls 6/6/97 print, ' #7 Creating B side histogram & timelist' help,timeb print,'sizeb = ',sizeb hb=histogram(timeb,binsize=15L) s=size(hb) numtimes=s(1) t=findgen(numtimes)*15.0+delta_t+7.5 print, ' #8 Plotting B side Data' if n_params() ge 3 then begin plot,t/60.,hb,psym=10,title=logname+' Channel B',xtitle='Time (min)', $ ytitle='Packets/15sec',charsize=1,color=0,background=255,xrange=[t1,t2] endif else begin plot,t/60.,hb,psym=10,title=logname+' Channel B',xtitle='Time (min)', $ ytitle='Packets/15sec',charsize=1,color=0,background=255 endelse printset: ;csee 6/6/97 print, ' #9 Cleanup and Output file' if !d.name eq 'PS' then begin device,/close set_plot,'x' spawn,'lp ~/plot_rate.ps' !p.multi=0 endif ;for a descent, you can read the DDB info... flag=0 ans='' Descent=findfile(logname+'/DB/Descent') ;test if data exists if Descent(0) ne '' then $ read,"Do you want to plot the Descent Dataset's information? (y or n): ",ans if ans eq 'y' then begin !y.range=[0,0] ;autorange flag=1 ;Descent data exists cd,'DB/Descent' files=t_getfil() n=0 s=size(files) if s(0) ne 0 then n=s(1) ;n=number of Descent files d_t=fltarr(n) altitude=fltarr(n) spin=fltarr(n) cycle=bytarr(n) for i=0,n-1 do begin next_header: d_rhead,files(i),h,status ;this line checks the status flag... if status(0) eq 'F' then print,'*** Error reading header of file: ',files(i) d_t(i)=d_value(h,h_mission_time) altitude(i)=d_value(h,h_altitude)/1000.0 spin(i)=d_value(h,99) cycle(i)=d_value(h,h_cycle_type) endfor plot_descent: !P.MULTI=[0,1,1] plot,d_t/60.,altitude,psym=10,title=logname+' Altitude',xtitle='Time (min)', $ ytitle='Altitude (KM)',charsize=1,color=0,background=255 read,'Hit return to continue',ans plot,d_t/60.,spin,psym=10,title=logname+' Spin Rate',xtitle='Time (min)', $ ytitle='Spin (RPM)',charsize=1,color=0,background=255 ;Print out Descent data... ans='' read,'Do you want printouts of the Descent Data? (y or n): ',ans if ans eq 'y' then begin !y.range=[0,0] ;autorange set_plot,'ps' !p.font=0 device,filename='~/idl.ps',xoffset=1.0,yoffset=10.01,xsize=9.17,ysize=7.0, $ /landscape,/inches plot,d_t/60.,altitude,psym=10,title=logname+' Altitude',xtitle='Time (min)', $ ytitle='Altitude (KM)',charsize=1,color=0,background=255 plot,d_t/60.,spin,psym=10,title=logname+' Spin Rate',xtitle='Time (min)', $ ytitle='Spin (RPM)',charsize=1,color=0,background=255 device,/close_file spawn,'lp ~/idl.ps' set_plot,'x' endif endif ;Create output file... ans='' read,'Do you want to create an output file? (y or n): ',ans if ans eq 'y' then begin print,'The output file is: ',outfile cd,logname ;csee 7/17/97 close,2 openw,2,outfile printf,2,' Mission Time # A Packets # B Packets' for i=0,numtimes-1 do printf,2,t(i),ha(i),hb(i) c_type=[1,2,3,4,5,6,8,9,10,11,12,13,14] if flag eq 1 then begin ;if descent data exists printf,2,string(10b),' Mission Time Altitude (KM) Spin (RPM) Cycle Type' for j=0,12 do begin printf,2,'' index=where(cycle eq c_type(j),count) for i=0,count-1 do printf,2,d_t(index(i)),altitude(index(i)),spin(index(i)),cycle(index(i)) endfor endif close,2 endif done: print, ' #10 Done!' cd, cdir ;csee 6/9/97 close,/all !P.MULTI=[0,1,1] ;1x1 window !y.range=[0,0] ;autorange !x.range=[0,0] ;autorange !p.font=-1 ;vector drawn fonts end