示例#1
0
	def calculateac05(self, input, column, operation, outputfmt):
		'''
		Can be used to calculate the ac05 (from 3 pix to 10pix) aperture correction.
		Uses IRAF task tcalc, and adds the calculated values as a new column at the
		end of the table.
		'''
		I.tcalc(input, column, operation, colfmt=outputfmt)
示例#2
0
    def calculateac05(self, input, column, operation, outputfmt):
        '''
		Can be used to calculate the ac05 (from 3 pix to 10pix) aperture correction.
		Uses IRAF task tcalc, and adds the calculated values as a new column at the
		end of the table.
		'''
        I.tcalc(input, column, operation, colfmt=outputfmt)
def post_correction_check(config, sky, sky_nofits, total_sci_ext, fits_number):
	for i in range(1,total_sci_ext+1): 
		galaxy.instres(sky,linelist='igaldir$GMOSsky_instres.dat', sci_ext='sci,%d' % i)
		iraf.rename('%s_instres.tab' % sky_nofits, '%s_instres_slit%d_post.tab' % (sky_nofits, i))
		iraf.tcalc('%s_instres_slit%d_post.tab' % (sky_nofits, i), 'dlambda', 'LAMBDAIN-lambdaout', colfmt='f6.3')
		iraf.tstat('%s_instres_slit%d_post.tab' % (sky_nofits, i), 'dlambda', outtable='%s_lambdaoffall_post.tab' % config)
		iraf.tstat('%s_instres_slit%d_post.tab' % (sky_nofits, i), 'dlambda', outtable='%s_lambdaoff_post.tab' % config, lowlim=(iraf.tstat.median-3*iraf.tstat.stddev), highlim=(iraf.tstat.median+3*iraf.tstat.stddev))
	
	end_row = total_sci_ext * fits_number #the mdf is minus 1 bc the offset between MDF index # and actual number
	beg_row = (total_sci_ext * fits_number) - (total_sci_ext-1) #the mdf is -2; -1 to account for offset and another -1 
	print 'Taking the median of rows: %s - %s in the %s file for file #%d of the file list' % (beg_row, end_row, '*_lambdaoff.tab', fits_number)

	iraf.tstat('%s_lambdaoff_post.tab' % config,'median',outtable='%s_lambdaoffmed_post.tab' % config,row='%s - %s' % (beg_row, end_row), Stdout=0)
示例#4
0
    def checkMDF(self, rawMDF, flatList, **kwargs):

        # copy raw MDF to local directory
        mdf = rawMDF
        if not os.path.exists(mdf):
            print "\nFETCHING RAW MDF"
            mdfPath = "/Users/roedigerj/anaconda/envs/astroconda/iraf_extern/gemini/gmos/data/"
            rawMDF = mdfPath + rawMDF
            shutil.copy(rawMDF, "./")

        # TODO: check that flatList is not empty

        # grab the name of a single flat to reduce
        im = utils.getImPaths(flatList)[0]

        print "\nCHECKING MDF WITH " + im

        # repeat the following steps until the MDF deemed correct
        while True:

            # do basic reduction of selected exposure
            _ = self.reduceIm(im, fl_inter="no", fl_gscrrej="no", \
             fl_extract="no", fl_wavtran="no", fl_skysub="no", \
             fl_fluxcal="no", mdffile=mdf, mdfdir="./", verbose="no", \
             **kwargs)

            # extract spectrum to check match between MDF and IFU flat
            logFile = ""
            if "logfile" in kwargs.keys():
                logFile = kwargs["logfile"]
            iraf.delete("database/aperg" + im[:im.find(".")] + "*",
                        verify="yes")
            self.extractSpec("rg" + im, fl_inter="yes", logfile=logFile, \
             verbose="no")

            # TODO: remove any extracted files

            # call tcalc to fix MDF (if necessary)
            fixMDF = bool(input("\nDoes MDF need fixing? (True/False): "))
            if fixMDF:
                fiber = input("Fiber to fix: ")
                flag = input("Flag value: ")
                iraf.tcalc(
                    mdf, "BEAM", "if NO == " + str(fiber) + "then " +
                    str(flag) + " else BEAM")
            else:
                break

        return
def slit_offset(config, sky, sky_nofits, total_sci_ext):
	#the range matches up the index with the MDF science extensions; instres only works on science extensions
	for i in range(1,total_sci_ext+1):

		#this creates an STsci table (which can be read, edited, etc from the ttools package)
		line_list='igaldir$GMOSsky_instres.dat'
		galaxy.instres(sky, linelist=line_list, output='%s_instres_slit%d.tab' % (sky_nofits, i), sci_ext='sci,%d' % i)
		
		#showing a graph that plots the gaussian fit to the sky lines in the image
		#iraf.gkimos('tmp.gki')
		#os.system('rm tmp.gki')
			
		#this is determining the change in wavelength (delta lambda) of the line-list from the measured lines
		#LAMDAIN is the rest wavelength line and lambdaout is the skyline from our frame (colfmt gives the type of unit)
		iraf.tcalc('%s_instres_slit%d.tab' % (sky_nofits, i), 'dlambda', 'LAMBDAIN-lambdaout', colfmt='f6.3')

		#this is extracting the dlambda column of the file and putting it into a new table 
		#the new table will be populated with the mean, stddev, median, min, and max values for the loaded table column (dlambda)
		iraf.tstat('%s_instres_slit%d.tab' % (sky_nofits, i), 'dlambda', outtable='%s_lambdaoffall.tab' % config)

		#this is extracting the dlambda column of the loaded file and putting it into another table if it's within certain limits
		#the new table will be populated with the mean, stddev, median, min, and max values for the restricted dlambda values
		iraf.tstat('%s_instres_slit%d.tab' % (sky_nofits, i), 'dlambda', outtable='%s_lambdaoff.tab' % config, lowlim=(iraf.tstat.median-3*iraf.tstat.stddev), highlim=(iraf.tstat.median+3*iraf.tstat.stddev))          
示例#6
0
    def correctMagnitude(self, input, column, operation, outputfmt):
        '''
		Essentially the same as calculateac05 function.
		'''
        I.tcalc(input, column, operation, colfmt=outputfmt)
for i in mask2:
	root = i[0:13]
	#this is copying the primary header unit to the new MEF
	iraf.imcopy('corrected_cmgs%s[%d]' % (i, 0), 'corrected_cmgs%s_ext25.fits' % root)
	
	#this is copying the MDF extension to the new MEF (using iraf's table select function to create a new table from rows of an old one)
	#the MDF index number is different than the MEF extension # - the MDF counts acquisition stars, the MEF index doesn't;
	#I'm copying the MDF information about ext 25 to the MDF of the new MEF we're making
	iraf.tselect('corrected_cmgs%s.fits[MDF]' % root,'corrected_cmgs%s_ext25.fits[1]' % root, 'extver==24')

	#this is allowing us to rename extension 1's name to 'MDF' in the newly created MEF (can check it worked with pyfits.info(filename))
	iraf.parkey("MDF",'corrected_cmgs%s_ext25.fits[1]' % root,"EXTNAME",add='yes')

	#we are re-writing the 'extver' value (written two steps before) in the MDF to 1 in this step.
	iraf.tcalc('corrected_cmgs%s_ext25.fits[MDF]' % root, 'extver','1')

	#here we are inserting the 25th extension (the double object slit) into extension 2 of our newly-created MEF
	iraf.fxinsert('corrected_cmgs%s.fits[25]' % root, 'corrected_cmgs%s_ext25.fits[2]' % root)

	#hedit allows us to change header values; here I'm adjusting some of the values so they reflect the position in the new MEF
	#these are values changed in the actual data part of the image (how is that possible? no keywords are there?)
	iraf.hedit('corrected_cmgs%s_ext25.fits[2]' % root, 'EXTVER', 1, upd='yes', ver='no')
	iraf.hedit('corrected_cmgs%s_ext25.fits[2]' % root, "MDFROW", 1, upd='yes', ver='no')   # used by gsskysub
	#these are values changed in the header of the image
	iraf.hedit('corrected_cmgs%s_ext25.fits[0]' % root, "NSCIEXT", 1, upd='yes', ver='no')  #number of science extensions
	iraf.hedit('corrected_cmgs%s_ext25.fits[0]' % root, "NEXTEND", 2, upd='yes', ver='no')  #number of extensions in file
	


#running those extracted slits through gsskysub manually;
示例#8
0
	def correctMagnitude(self, input, column, operation, outputfmt):
		'''
		Essentially the same as calculateac05 function.
		'''
		I.tcalc(input, column, operation, colfmt=outputfmt)