procedure rdfits (ffiles,ifiles) string ffiles ="" {prompt="FITS files to read"} string ifiles ="" {prompt="IRAF files to write"} bool oldname =yes {prompt="Use old IRAF name in place of ifiles?"} bool delfits =yes {prompt="Delete FITS files after reading to IRAF?"} bool verbose =yes {prompt="Print short header?"} # @(#) task rdfits Author: R.A. Jansen -- Feb 20 1997 # @(#) # @(#) task to read FITS files on disk into IRAF files. Pixel type of # @(#) the IRAF file will be 'real'. Default action is to delete the # @(#) FITS file after it has been read into IRAF, and to restore the # @(#) file name to its original IRAF name. A short header is printed. # @(#) This task is merely a user interface to task 'rfits', but may be # @(#) convenient if available diskspace is limited. # @(#) begin string fimg, iimg, cstr struct line bool islist1, islist2, oneout int NN, NL fimg = ffiles iimg = ifiles islist1 = no islist2 = no oneout = no # Check whether input files exist... NL = 0 if ( substr(fimg,1,1) == "@" ) { islist1 = yes fimg = substr(fimg,2,strlen(fimg)) list = fimg while ( fscan(list,line) != EOF ) { cstr = line if ( !access(cstr) ) { print("ERROR: file "//cstr//" not found! Exit...") return } NL += 1 } } else { NL = 1 if ( !access(fimg) ) { print("ERROR: file "//fimg//" not found! Exit...") return } print (fimg, > "tmprdfts.flis") fimg = "tmprdfts.flis" } # Check whether output files do not yet exist... NN = 0 if ( substr(iimg,1,1) == "@" ) { islist2 = yes iimg = substr(iimg,2,strlen(fimg)) list = iimg while ( fscan(list,line) != EOF ) { cstr = line if ( access(cstr) ) { print("ERROR: file "//cstr//" already present! Exit...") return } NN += 1 } } else { NN = 1 if ( access(iimg) ) { print("ERROR: file "//iimg//" already present! Exit...") return } print (iimg, > "tmprdfts.ilis") iimg = "tmprdfts.ilis" } # Check, if input is a list of images, whether input and output # lists have same number of file names if ( islist1 && islist2 ) { if ( NN != NL && NN != 1 ) { print("ERROR: number of input and output files differ! Exit...") return } } if ( NN == 1 ) { oneout=yes } # Read in FITS images, and delete after reading... for ( NN = 1 ; NN <= NL ; NN = NN + 1 ) { rdlist(fimg, NN) cstr = rdlist.cline if (oneout) { rdlist(iimg, 1) } else { rdlist(iimg, NN) } rfits (cstr, "*", rdlist.cline, make_image=yes, long_header=no, short_header=verbose, datatype="real", blank=0., scale=yes, oldiraf=oldname, offset=0) delete (cstr, yes, verify=no) } # Clean-up... if ( access("tmprdfts.flis") ) { delete("tmprdfts.flis", yes, verify=no) } if ( access("tmprdfts.ilis") ) { delete("tmprdfts.ilis", yes, verify=no) } list = "" print("RDFITS: Finished.") end