function nom_fits,fname ;+ ; NAME: ; NOM_FITS ;PURPOSE: ; Seeks the termination of the name of an unknown S055 FITS file ;EXPLANATION: ; Trial/error method: only 'R.fits', 'G.fits, 'L.fits' and 'S.fits' are possible ;CALLING SEQUENCE: ; Result = NOM_FITS (fname) ;INPUTS: ; fname = beginning of the name of the FITS file ;OUTPUT: ; result = the name of the FITS file ;- close,40 openr,40,fname+'.R.fits',ERROR=err2 if (err2 eq 0) then begin return, fname+'.R.fits' endif else begin close,40 openr,40,fname+'.S.fits',ERROR=err2 if (err2 eq 0) then return,fname+'.S.fits' else begin close,40 openr,40,fname+'.L.fits',ERROR=err2 if (err2 eq 0) then return,fname+'.L.fits' else return,fname+'.G.fits' endelse endelse close,40 end pro creation_list,move ;+ ; NAME: ; CREATION_LIST ;PURPOSE: ; Creates an index of all the S055 FITS files in the current directory ;EXPLANATION: ; Reads a predeterminate list of parameters in every FITS file it founds. ; Can rename the temporary FITS with a more suitable name ;CALLING SEQUENCE: ; CREATION_LIST, [move] ;INPUTS: ; move = 'y' or 'n' The default value is 'n' ;OUTPUT: ; none ;- if N_params() eq 0 then move='n' for ind=0,3,1 do begin case ind of 0:choice='S' 1:choice='L' 2:choice='G' 3:choice='R' endcase print,'Looking for '+choice+' mode files' spawn,'ls *'+choice+'.fits >toto' spawn,/noshell,['wc','-l','toto'],nblin liste_fname=strarr(nblin(0)) close,11,19 openr,11,'toto' readf,11,liste_fname openw,19,'new_list'+choice+'.txt' printf,19,'Name (.fits) tTT.fFFF IDcode HH:mm:SS:fff DetON DATE DOY DLC SL# RLSUN UDSUN GAMR NVALID/NTOTAL Start GRATPOS IBAR1 SDI1 IBAR2 SDI2 IBAR3 SDI3 IBAR4 SDI4 IBAR5 SDI5 IBAR6 SDI6 IBAR7 SDI7 ' for i=0,nblin(0)-1,1 do begin close,10 fname2=liste_fname(i) openr,10,fname2,ERROR=err if (err eq 0) then begin print,'Reading '+liste_fname(i) h=headfits(fname2) DOY=string(fxpar(h,'DOY'),format='(i3)') DLC=string(fxpar(h,'DLC'),format='(i4)') SLnb=string(fxpar(h,'SL#'),format='(i1)') DATEDATA=fxpar(h,'DATEDATA') GRATPOS=string(fxpar(h,'GRATPOS'),format='(i4)') TIMEDATA=fxpar(h,'TIMEDATA') FILECODE=fxpar(h,'FILECODE') DETECTON=fxpar(h,'DETECTON') GAMX=string(fxpar(h,'RLSUN'),format='(f8.2)') GAMY=string(fxpar(h,'UDSUN'),format='(f8.2)') GAMR=string(fxpar(h,'GAMRAVG'),format='(f8.1)') STARTPNT=string(fxpar(h,'STARTPNT'),format='(i4)') NVALID=string(fxpar(h,'NVALID'),format='(i4)') NTOTAL=string(fxpar(h,'NTOTAL'),format='(i4)') IBAR=strarr(7) for j=0,6,1 do begin IBAR(j)=string(fxpar(h,'IBAR'+string(j+1,format='(i1)')),format='(f7.1)') IBAR(j)=IBAR(j)+' '+string(fxpar(h,'SDI'+string(j+1,format='(i1)')),format='(f6.2)') endfor fname3='ATM.'+strmid(DATEDATA,2,2) fname3=fname3+strmid(DATEDATA,5,2) fname3=fname3+strmid(DATEDATA,8,2)+'.' fname3=fname3+strmid(TIMEDATA,0,2) fname3=fname3+strmid(TIMEDATA,3,2) fname3=fname3+strmid(TIMEDATA,6,2)+'.' fname3=fname3+strmid(fname2,15,1) finale=fname3+' '+strmid(fname2,6,8)+' '+FILECODE finale=finale+' '+TIMEDATA+' '+DETECTON finale=finale+' '+DATEDATA+' '+DOY+' '+DLC+' '+SLnb finale=finale+' '+GAMX+' '+GAMY finale=finale+' '+GAMR+' '+NVALID+'/'+NTOTAL+' '+STARTPNT+ ' '+GRATPOS+' ' for j=0,6,1 do finale=finale+string(IBAR(j))+' ' printf,19,finale if (move eq 'y') then spawn,/noshell,['mv',fname2,'/data/mhirtzig2/'+DOY+'/'+fname3+'.fits'] endif endfor spawn,/noshell,['rm','toto'] for i=0,2000,1 do begin printf,19,'...' endfor close,19 endfor end pro automate_S055 ;+ ; NAME: ; AUTOMATE_S055 ;PURPOSE: ; Transforms all the S055 raw data files it founds into FITS files ;EXPLANATION: ; Creates a list of all the image.tTT.fFFF (compressed or not) ; Either transforms them into FITS files, overwriting the existing files, ; or only creates the FITS files that do not fit its list. ; Can create an index of every FITS file in the current directory ; If the index was asked, it can rename the temporary FITS with a more suitable name ;CALLING SEQUENCE: ; AUTOMATE_S055 ;INPUTS: ; none ;OUTPUT: ; none ;- !p.multi=0 close,10,11,12,21,22,30 openw,21,'controle_fits.txt' reponse=' ' liste=' ' move=' ' remplace=0 totalite=0 spawn,/noshell,'clear' print,'Replace existing FITS files ? y/n ' read,reponse if (reponse EQ 'y') then remplace=1 print,'Create a list of the FITS files ? y/n ' read,liste if liste eq 'y' then begin print,'Rename the FITS files ? y/n ' read,move endif spawn,'ls i*.t*.f*.gz i*.t*.f*.Z i*.t*.f*0 i*.t*.f*1 i*.t*.f*2 i*.t*.f*3 i*.t*.f*4 i*.t*.f*5 i*.t*.f*6 i*.t*.f*7 i*.t*.f*8 i*.t*.f*9 >toto' spawn,/noshell,['wc','-l','toto'],nblin print,string(nblin(0),format='(i5)')+' files detected' liste_fname=strarr(nblin(0)) close,11,19 openr,11,'toto' readf,11,liste_fname for i=0,nblin(0)-1,1 do begin fname=strmid(liste_fname(i),0,14) fname2=nom_fits(fname) openr,11,fname2,ERROR=err1 if NOT((err1 EQ 0) AND (remplace EQ 0)) then begin ;If the file has been compressed, must decompress it first openr,10,fname,ERROR=err0 if (err0 NE 0) then begin openr,30,fname+'.Z',ERROR=err0b if(err0b EQ 0) then spawn,/noshell,['uncompress',fname+'.Z'] close,30 openr,30,fname+'.gz',ERROR=err0b if(err0b EQ 0) then spawn,/noshell,['gunzip',fname+'.gz'] close,30 endif ;Creation of the related FITS file fname2=making_fits_from_tape(fname) if(fname2 eq 'X') then begin printf,21,'! File '+fname+' has a problem !' endif else begin printf,21,'File '+fname2+' created ' totalite=totalite+1 endelse ;spawn,/noshell,['gzip',fname] endif else begin fname2=nom_fits(fname) printf,21,'File '+fname2+' already exists ' print,'File '+fname2+' already exists ' endelse close,10,11,22 endfor for i=0,2000,1 do begin printf,21,'...' endfor spawn,'rm bidul* toto' spawn,/noshell,'clear' if (liste eq 'y') then begin print,'Creation of the list' creation_list,move print,' ' soluce_list=': List created)' endif else begin soluce_list=')' endelse print,'Program complete : '+string(totalite,format='(i5)')+' files created ('+strmid(nblin(0),1,7)+' files detected'+soluce_list end