PRO uncompress,compressed_file_name,rm=rm,script=script ;+ ; NAME: ; UNCOMPRESS ; PURPOSE: ; Uncompression of compressed Polar Camera image files. ; CATEGORY: ; ; CALLING SEQUENCE: ; UNCOMPRESS, COMPRESSED_FILE_NAME, RM = RM, SCRIPT = SCRIPT ; INPUTS: ; COMPRESSED_FILE_NAME: The full pathname of the file to ; be uncompressed. ; OPTIONAL INPUTS: ; None. ; KEYWORD PARAMETERS: ; /RM: Set this keyword to delete the compressed file ; after it's uncompressed. ; SCRIPT: This keyword returns an operating system command ; sequence to uncompress the specified file, and ; optionally delete the compressed file. It is used ; to generate uncompression scripts that can be ; executed by SPAWNing, thus avoiding the overhead ; of a SPAWN for each compressed file. ; OUTPUTS: ; None. ; OPTIONAL OUTPUTS: ; None. ; COMMON BLOCKS: ; None. ; SIDE EFFECTS: ; An uncompressed image file is created. If /RM is set, the ; compressed version is removed. ; RESTRICTIONS: ; The compressed file must exist. It must be named according ; to the standard Polar Camera file name convention, where ; uncompressed files can begin with one of [abcdfg] and the ; compressed version of a given file begins with the ; corresponding character of [nopqst]. ; PROCEDURE: ; The file name part of the full path name is isolated, and ; the first character is checked to see that it is one of ; [nopqrst]. If not, an error message is printed and nothing ; else happens. Otherwise, the uncompressed file name is ; generated, and an operating system command is created to ; perform the uncompression. If the SCRIPT keyword is ; supplied, the command output is redirected to a file. If ; the RM keyword is set, a further command is supplied to ; remove the compressed file after the uncompression has ; taken place. If the SCRIPT keyword is not supplied, the ; command is then SPAWNed, otherwise it is returned to the ; calling routine via the SCRIPT keyword. ; EXAMPLE: ; uncompress,'/jasper/cnsr3_data1/dk/c0/q0200060.012',/rm $ ; ,script=myscript ; SEE ALSO: ; KIEXPAND.PRO, DUCALL.PRO, UCALL.PRO ; MODIFICATION HISTORY: ; Written by: D P Steele, November 1993. ; Documented by: D P Steele, April 1995. ;- cpfn=STRTRIM(compressed_file_name,2) fc=STRMID(cpfn,STRLEN(cpfn)-12,1) bfc=BYTE(fc) bc=bfc(0) ; Is the first character of the file name between 'n' and 't'? IF (110B LE bc) AND (bc LE 116B) THEN BEGIN ucfn=cpfn STRPUT,ucfn,STRING(bc-13B),STRLEN(ucfn)-12 cmd='/jasper/cnsr3_data1/bin/lz78exp '+cpfn+' '+ucfn IF KEYWORD_SET(script) THEN BEGIN ; Return a line to be added to a script to uncompress all files cmd=cmd+' > /dev/null' IF KEYWORD_SET(rm) THEN cmd=cmd+' ; rm '+cpfn script=cmd ENDIF ELSE BEGIN ; spawn a shell command to uncompress this particular file SPAWN,cmd IF KEYWORD_SET(rm) THEN BEGIN ; spawn another command to remove the compressed file cmd='rm '+cpfn SPAWN,cmd ENDIF ENDELSE ENDIF ELSE BEGIN MESSAGE,'Bad file name :'+cpfn MESSAGE,'Uncompression not attempted' ENDELSE END