コード例 #1
0
    def do_overscan_subtract(self, get_or_create_tmpdir, request):
        """
        Run overscan correction on the main data.

        .. note::
            Fixture.
        """
        # Copy the raw data file into here
        rawfilename = 'bias*{}*.fits'.format(request.param)
        tmpsubdir, cal_service = get_or_create_tmpdir
        # Make sure we're working inside the temp dir
        # rawfiles = glob.glob(os.path.join(
        #     os.path.dirname(os.path.abspath(__file__)),
        #     'testdata',
        #     rawfilename))
        # shutil.copy(
        #     rawfiles[0],
        #     os.path.join(tmpsubdir.dirname, tmpsubdir.basename))
        rawfile = glob.glob(
            os.path.join(tmpsubdir.dirname, tmpsubdir.basename,
                         rawfilename))[0]

        # Do the overscan subtraction
        reduce = Reduce()
        reduce.drpkg = 'ghostdr'
        reduce.files = [
            rawfile,
        ]
        reduce.mode = [
            'test',
        ]
        reduce.recipename = 'recipeBiasRemoveOverscan'
        reduce.logfile = os.path.join(tmpsubdir.dirname, tmpsubdir.basename,
                                      'reduce_overscancorrect.log')
        reduce.logmode = 'quiet'
        reduce.suffix = '_testOverscanCorrect'
        logutils.config(file_name=reduce.logfile, mode=reduce.logmode)
        reduce.runr()

        corrfilename = os.path.join(tmpsubdir.dirname, tmpsubdir.basename,
                                    '*' + reduce.suffix + '.fits')
        corrfilename = glob.glob(corrfilename)[0]
        corrfile = os.path.join(tmpsubdir.dirname, tmpsubdir.basename,
                                corrfilename)

        # Return filenames of raw, subtracted files
        yield rawfile, corrfile

        # Execute teardown code
        for _ in glob.glob(
                os.path.join(os.getcwd(), '*{}.fits'.format(reduce.suffix))):
            os.remove(_)
コード例 #2
0
    def do_master_bias(self, get_or_create_tmpdir, request):
        """
        Perform bias subtraction on the main data.

        .. note::
            Fixture.
        """
        rawfilename = 'bias*{}*.fits'.format(request.param)
        # Copy the raw data file into here
        tmpsubdir, cal_service = get_or_create_tmpdir
        # Find all the relevant files
        # rawfiles = glob.glob(os.path.join(os.path.dirname(
        #     os.path.abspath(__file__)),
        #     'testdata',
        #     rawfilename))
        # for f in rawfiles:
        #     shutil.copy(f, os.path.join(tmpsubdir.dirname, tmpsubdir.basename))
        rawfiles = glob.glob(
            os.path.join(tmpsubdir.dirname, tmpsubdir.basename, rawfilename))

        # Do the master bias generation
        reduce = Reduce()
        reduce.drpkg = 'ghostdr'
        reduce.files = rawfiles
        reduce.mode = [
            'test',
        ]
        reduce.recipename = 'recipeBiasCreateMaster'
        reduce.upars = [
            'refresh=True',
        ]
        # reduce.mode = ['sq', ]
        # reduce.recipename = 'makeProcessedBias'
        reduce.logfile = os.path.join(
            tmpsubdir.dirname, tmpsubdir.basename,
            'reduce_masterbias_{}.log'.format(request.param))
        reduce.logmode = 'quiet'
        reduce.suffix = '_{}_testMasterBias'.format(request.param)
        logutils.config(file_name=reduce.logfile, mode=reduce.logmode)

        reduce.runr()
        # import pdb; pdb.set_trace()

        corrfilename = '*' + reduce.suffix + '.fits'
        corrfilename = os.path.join(tmpsubdir.dirname, tmpsubdir.basename,
                                    glob.glob(corrfilename)[0])
        corrfile = os.path.join(tmpsubdir.dirname, tmpsubdir.basename,
                                corrfilename)

        # Find the overscan-corrected bias files
        rawfiles = glob.glob(
            os.path.join(
                tmpsubdir.dirname,
                tmpsubdir.basename,
                rawfilename.split('.')[0] + '*_overscanCorrect*.fits',
            ))

        # Return filenames of raw, subtracted files
        yield rawfiles, corrfile

        # Execute teardown code
        pass
コード例 #3
0
    def do_bias_subtract(self, get_or_create_tmpdir, request):
        """
        Perform basic bias subtraction on the dark frame.

        .. note::
            Fixture.
        """
        rawfilename = 'dark*{}*.fits'.format(request.param)
        # Copy the raw data file into here
        tmpsubdir, cal_service = get_or_create_tmpdir
        # Find all the relevant files
        # rawfiles = glob.glob(os.path.join(os.path.dirname(
        #     os.path.abspath(__file__)),
        #     'testdata',
        #     rawfilename))
        # for f in rawfiles:
        #     shutil.copy(f, os.path.join(tmpsubdir.dirname, tmpsubdir.basename))
        rawfiles = glob.glob(
            os.path.join(tmpsubdir.dirname, tmpsubdir.basename, rawfilename))

        # Do the master bias generation
        reduce = Reduce()
        reduce.drpkg = 'ghostdr'
        reduce.files = rawfiles[0]
        reduce.mode = [
            'test',
        ]
        reduce.recipename = 'recipeDarkBiasCorrect'
        # reduce.mode = ['sq', ]
        # reduce.recipename = 'makeProcessedBias'
        reduce.logfile = os.path.join(
            tmpsubdir.dirname, tmpsubdir.basename,
            'reduce_biascorrect_{}.log'.format(request.param))
        reduce.logmode = 'quiet'
        reduce.suffix = '_{}_testBiasCorrect'.format(request.param)
        logutils.config(file_name=reduce.logfile, mode=reduce.logmode)
        # import pdb; pdb.set_trace()
        calibs = {
            'processed_bias':
            glob.glob(
                os.path.join('calibrations', 'processed_bias',
                             'bias*{}*.fits'.format(request.param)))[0],
        }
        reduce.ucals = normalize_ucals(
            reduce.files, ['{}:{}'.format(k, v) for k, v in calibs.items()])

        # import pdb;
        # pdb.set_trace()
        reduce.runr()

        corrfilename = '*' + reduce.suffix + '.fits'
        corrfilename = os.path.join(tmpsubdir.dirname, tmpsubdir.basename,
                                    glob.glob(corrfilename)[0])
        corrfile = os.path.join(tmpsubdir.dirname, tmpsubdir.basename,
                                corrfilename)

        # Return filenames of raw, subtracted files
        yield rawfiles, corrfile, calibs

        # Execute teardown code
        for _ in glob.glob(
                os.path.join(os.getcwd(), '*{}.fits'.format(reduce.suffix))):
            os.remove(_)