pro sslcheck,db ;This program searches data base 'db' for instances when there is power drawn ;by the Surface Science Lamp, then prints out the Test Log name and SSL ON Time ;to the screen. ;db is something like '/df3' ;The error log, ~/error.out, keeps track of the programs progress for debugging. ;The detailed dota, suitable for ploting, is output in file: /users/csee/data/sslcheck.out ; and the current, voltage and power are plotted. ;_______________________________________________________________________ ;Setup... cd,'',current=cdir & cd,cdir ;establishes cdir as current directory if n_params() eq 0 then db = cdir ;test for # of input parameters print,string(10b),'The data base is: ',db,string(10b) print,format='(" # Test Log",T54,"SSL ON Time (minutes)")' cd,db spawn,'lsf',testdates,/noshell if testdates(0) eq '' then goto,exit ;quit if no directories are found s=size(testdates) ntestdates=s(1) no_of_testdates=sstr(ntestdates) print,'The number of testdates in ',sstr(db),' is: ',sstr(ntestdates) ;_______________________________________________________________________ ;Setup Error file... openw,1,'~/error.out' ;error log printf,1,'This is the error log for sslcheck.pro for database: ',db printf,1,'Today is: ',systime(0),string(10b) printf,1,' N # Test Date' close,1 month=['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'] siz=0 ; starting size for output array ssl=fltarr(5,300) ; juliday,lamps,mtime,A,V x measurement n=0 ; initial index of valid test logs ;_______________________________________________________________________ for i=0,ntestdates-1 do begin ;i is the test date within the data base ;if the first character is 0 thru 9 assume the directory is a test log. firstchar=byte(strmid(testdates(i),0,1)) if firstchar(0) lt 48b or firstchar(0) gt 57b then goto,next_date ;if not a test date cd,db+'/'+testdates(i)+'Log' logs=findfile(count = nlogs) ;_____________________________________________________________________ for l=0,nlogs-1 do begin ;l is the test log within the test date test=where(findfile(logs(l)+'/DB') eq 'Lamp') ;test if /DB/Lamp exists if test(0) eq -1 then goto,next_log ;skip if not replayed cd,logs(l)+'/DB/Lamp' spawn,'ls',files,/noshell if files(0) eq '' then goto,next_log ;skip if no files found s=size(files) nfiles=s(1) n=0 ; counter for valid datasets (ie with lamp powered) new=fltarr(5,nfiles) ;data collected from this log ;_______________________________________________________________ for j=0,nfiles-1 do begin ;j is the file within the test log d_read,files(j),h,p current=d_value(h,166) voltage=d_value(h,165) if not(current ge .1 and voltage ge .1) then goto,next_file ;threshold values date=d_value(h,15) mtime=d_value(h,88)/60. lamps=float(d_value(h,102)) mo=where(month eq strmid(date,4,3))+1 day=fix(strmid(date,8,2)) yr=fix(strmid(date,20,4)) if yr eq 2024 then yr=1996 ;correction for clock error juliday=julday(mo(0),day,yr) new(*,n)=[juliday,lamps,mtime,current,voltage] n=n+1 ;counts files with lamp powered (in this log) next_file: endfor ;__________________________________________________ ;increase size of ssl and add new data... if n gt 0 then begin ;if there is new data temp=ssl oldsiz=siz siz=siz+n ssl=fltarr(5,siz) if oldsiz gt 0 then ssl(*,0:oldsiz-1)=temp(*,0:oldsiz-1) ssl(*,oldsiz:siz-1)=new(*,0:n-1) print,i,testdates(i),logs(l),sstr(5*n/60.),format='(i4,2x,a,"Log/",a,T54,F14.4)' endif next_log: cd,db+'/'+testdates(i)+'Log' endfor ;__________________________________________________________________ next_date: close,1 openu,1,'~/error.out',/append printf,1,n,i,' of ',no_of_testdates,' ',testdates(i) close,1 endfor ;______________________________________________________________________________ close,1 openu,1,'~/error.out',/append printf,1,'Now, sort list...' close,1 col_sort,ssl,0 ;sorts ssl by juliday in assending order close,1 openu,1,'~/error.out',/append printf,1,'List sorted...' close,1 ;Output data and plot... close,2 again: ans='' read,'Do you want to overwrite the old output file? (y or n): ',ans if ans ne 'y' then goto,again openw,2,'/users/csee/data/sslcheck.out' printf,2,'This is the Surface Science Lamp Power data from: ',db printf,2,'Today is: ',systime(0),string(10b) printf,2,' Julian Day Date Lamps Mission Current Voltage Power' printf,2,' Time (min) Amps Volts Watts',string(10b) Power=fltarr(siz) for i=0,siz-1 do begin caldat,ssl(0,i),M,D,Y ;calendar date from julian date M=month(M-1) Power(i)=ssl(3,i)*ssl(4,i) Lamps=sstr(fix(ssl(1,i))) for k=strlen(Lamps),3 do Lamps='0'+Lamps ;adds leading 0's printf,2,ssl(0,i),D,M,Y,Lamps,ssl(2,i),ssl(3,i),ssl(4,i),Power(i),$ format='(i10,i5,1x,a3,i5,3x,a4,4F10.2)' endfor printf,2,string(10b),'There were ',sstr(siz),' files.' printf,2,'The total powered time for the SSL is: ',sstr(5*siz/60.),' minutes.' close,2 !x.title='Date' dummy=LABEL_DATE(DATE_FORMAT='%D%M%Y') plot,ssl(0,*),ssl(3,*),title='Surface Science Lamp Current',ytitle='Amps',/ynoz,xtickformat='LABEL_DATE' read,'Plot of Lamp Current, Hit return to continue. ',ans plot,ssl(0,*),ssl(4,*),title='Surface Science Lamp Voltage',ytitle='Volts',/ynoz,xtickformat='LABEL_DATE' read,'Plot of Lamp Voltage, Hit return to continue. ',ans plot,ssl(0,*),power,title='Surface Science Lamp Power',ytitle='Watts',/ynoz,xtickformat='LABEL_DATE' read,'Plot of Lamp Power, Hit return to continue. ',ans plot,ssl(0,*),ssl(3,*)/mean(ssl(3,*)),title='Normalized Surface Science Lamp Current',ytitle='Amps/Mean Amps',/ynoz,xtickformat='LABEL_DATE' read,'Normalized Lamp Current, Hit return to continue. ',ans plot,ssl(0,*),ssl(4,*)/mean(ssl(4,*)),title='Normalized Surface Science Lamp Voltage',ytitle='Volts/Mean Volts',/ynoz,xtickformat='LABEL_DATE' read,'Normalized Lamp Voltage, Hit return to continue. ',ans plot,ssl(0,*),power/mean(power),title='Normalized Surface Science Lamp Power',ytitle='Watts/Mean Watts',/ynoz,xtickformat='LABEL_DATE' read,'Normalized Lamp Power, Hit return to continue. ',ans Print,'The output in file: /users/csee/data/sslcheck.out' ;stop exit: cd,cdir close,/all end