;+
; NAME:
;	FIX_HT_SCALE
;
; PURPOSE:
;	This procedure is used to fix the scaling of the HT files
;
; CATEGORY:
;	MOVIE
;
; CALLING SEQUENCE:
;	FIX_HT_SCALE,Fname
;
; INPUTS:
;	Fname:	String containing the filename to be fixed
;
; OUTPUTS:
;	This routine renames the filename to Fname.old and copies the 
;	information to a new file, correcting the scaling factors.
;
; COMMON BLOCKS:
;	None
;
; RESTRICTIONS:
;	The file should not have any blank lines.
;
; PROCEDURE:
;
; MODIFICATION HISTORY:
; 	Written by:	RAH, 9 May 97
;
; @(#)fix_ht_scale.pro	1.1 05/14/97 :NRL Solar Physics
;
;-
;
pro fix_ht_scale,fname
;
  SPAWN,'mv '+fname+' '+fname+'.old
  OPENR,lu,fname+'.old',/get_lun
  OPENW,luout,fname,/get_lun
  PRINTF,luout,'#VERSION=2'
  instr = ''
  version = 1
  WHILE (not eof(lu)) DO BEGIN
     READF,lu,instr
     IF (strmid(instr,0,1) ne '#') THEN BEGIN
        t=''
        f=0
        x=0
        y=0
        dates=''
        timestr=''
        times=''
        CASE version OF
        1:  READS,instr,temp,timestr,p,FORMAT='(F6.2,A20,f6.0)'
        2:  READS,instr,temp,timestr,p,t,f,x,y, $
                  FORMAT='(F6.2,A20,f6.0,a3,i3,2f6.2)'
        ENDCASE
        CASE detector OF
        'C2':  rs = temp*SUBTENSE('C2')/11.2
        'C3':  rs = temp*SUBTENSE('C3')/56.
        else:  rs = temp
        ENDCASE
        IF (t eq '') THEN tel=detector ELSE tel=t
        IF (f eq 0) THEN feat=nfeat ELSE feat=f
        PRINTF,luout,rs,timestr,p,tel,feat,x,y,$
                  FORMAT='(F6.2,A20,f6.1,a3,i3,2f6.2)'
     ENDIF ELSE BEGIN
        pflag = 1
        IF (STRMID(instr,0,8)  eq '#VERSION') $
           THEN version=FIX(STRMID(instr,9,2))
        IF (STRMID(instr,0,14) eq '#FEATURE_CODE:') THEN BEGIN
           IF (version EQ 1) THEN BEGIN
              feature=STRMID(instr,15,strlen(instr))
              PRINT,feature
              nfeat = 99
              IF (STRPOS(feature,'LE') GE 0)  THEN $
                  IF (STRTRIM(feature,2) EQ 'LE') nfeat=1 ELSE nfeat=7
              IF (STRPOS(feature,'LB') GE 0)  THEN nfeat=2
              IF (STRPOS(feature,'RB') GE 0)  THEN nfeat=3
              IF (STRPOS(feature,'BW') GE 0)  THEN nfeat=4
              IF (STRPOS(feature,'CORE') GE 0)  THEN nfeat=5
              IF (STRPOS(feature,'BOTH') GE 0)  THEN nfeat=6
              IF (STRPOS(feature,'BLACK') GE 0)  THEN nfeat=8
              IF (STRPOS(feature,'CENTER') GE 0)  THEN nfeat=9
              PRINTF,luout,'#FEATURE_CODE: '+string(nfeat,format='(i2.2)')+'='+feature
              pflag = 0
           ENDIF ELSE BEGIN
              nfeat=fix(STRMID(instr,15,2)) 
           ENDELSE
        ENDIF
        IF (STRMID(instr,0,10) eq '#DETECTOR:') $
           THEN detector=STRMID(instr,11,strlen(instr))
        IF (pflag EQ 1)  THEN PRINTF,luout,instr
     ENDELSE
  ENDWHILE
  FREE_LUN,lu
  FREE_LUN,luout
RETURN
END
