bug in PyRAF gemcrspec

Home Forums Gemini Data Reduction bug in PyRAF gemcrspec

This topic contains 2 replies, has 2 voices, and was last updated by  rarnason 3 years, 4 months ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
  • #1492


    Hi all,

    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.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[0])), 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[0])), 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.





    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:

    task gemcrspec=/path/to/new/gemcrspec.cl



    1. gemcrspec.cl_.gz


    Hi James,

    Your corrected gemcrspec.cl fixes this problem and works as expected.

    Thanks for your help!



Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.