February 10, 2017 at 4:12 pm #1492
I am making a python (2.7.12) PyRAF (2.16) script to reduce some GMOS data in MOS mode. Since I only have one image per target/grating/central wavelength combination, I am using gemcrspec to perform CR rejection on these images. One thing I am taking advantage of in testing this script is that IRAF tasks will exit with an error if the designated output file already exists, so I can quickly test later steps in the script by simply keeping intermediate files around and skipping steps I’ve already tested. However, gemcrspec seems to be curiously circumventing this behaviour. I have discovered if the output files gemcrspec is supposed to make already exist, it will exit the task with the error as expected, but then will delete all of the output files! Here’s the PyRAF snippet, with a couple of calls to “ls” checking if the files are still there:
call("ls Sculptor*.fits",shell=True) print ("=== Finished Basic Calibration Processing ===") print ("\n") print ("=== Performing cosmic-ray rejection using gemcrspec ===") gemtools.gemcrspec.unlearn() gemtools.gemcrspec.xorder = '9' gemtools.gemcrspec.yorder = '-1' gemtools.gemcrspec.sigclip = '4.5' gemtools.gemcrspec.sigfrac= '0.5' gemtools.gemcrspec.objlim = '1.0' gemtools.gemcrspec.verbose = 'no' prefix = 'gs' #CR rejection on the science images for tag,w in cwf.iteritems(): qdf['Disperser'] = tag[0:2] + '00+_%' qdf['CentWave'] = w outFile = qdf['Object'] + '-M01_' + tag sciFull = fs.fileListQuery(dbFile, fs.createQuery('sciSpec', qdf), qdf) gemtools.gemcrspec((prefix+str(sciFull)), outFile) # Do the same for the standard star for tag,w in cws.iteritems(): qd_std['Disperser'] = tag[0:2] + '00+_%' qd_std['CentWave'] = w outFile = qd_std['Object'] + '-M01_' + tag stdFull = fs.fileListQuery(dbFile, fs.createQuery('std', qd_std), qd_std) gemtools.gemcrspec(str((prefix+stdFull)), outFile) call("ls Sculptor*.fits",shell=True)
Here is the output generated from this portion of the script if the output files (those with Sculptor*.fits) already exist:
Sculptor-field1-M01_B6-520.fits Sculptor-field1-M01_B6-522.fits Sculptor-field1-M01_B6-525.fits === Finished Basic Calibration Processing === === Performing cosmic-ray rejection using gemcrspec === ERROR - GEMCRSPEC: Output image Sculptor-field1-M01_B6-522 exists ERROR - GEMCRSPEC: Output image Sculptor-field1-M01_B6-520 exists ERROR - GEMCRSPEC: Output image Sculptor-field1-M01_B6-525 exists ERROR - GEMCRSPEC: Output image LTT1020-M01_B6-625 exists ERROR - GEMCRSPEC: Output image LTT1020-M01_B6-520 exists ERROR - GEMCRSPEC: Output image LTT1020-M01_B6-415 exists ls: cannot access 'Sculptor*.fits': No such file or directory
Expected behaviour: If output files already exist, GEMCRSPEC should exit with an error but should leave the output files untouched.
Robin00February 20, 2017 at 11:27 pm #1498
Thanks for reporting this bug. Does this version do what you want?
Sorry, the forum won’t let me upload a .cl file, so you’ll need to run gunzip on it. You can either copy it into gemtools/ (best save a copy of the original there) or re-declare it after loading the gemini package, eg. by adding this to your loginuser.cl:
gemini gmos gemtools task gemcrspec=/path/to/new/gemcrspec.cl
Attachments:February 22, 2017 at 7:20 pm #1501
Your corrected gemcrspec.cl fixes this problem and works as expected.
Thanks for your help!
You must be logged in to reply to this topic.