def _check_global_backsub(self): """Check for global background subtraction""" # go over all inputs for one_input in self.axe_inputs: # load the config file and get the extension information conf = configfile.ConfigFile( config_util.getCONF(one_input['config'])) ext_info = config_util.get_ext_info( config_util.getDATA(one_input['grisim']), conf) # open the fits image gri_fits = fits.open(config_util.getDATA(one_input['grisim']), 'readonly') # go to the correct header act_header = gri_fits[ext_info['fits_ext']].header # make sure a sky background value is set if 'SKY_CPS' in act_header and act_header['SKY_CPS'] >= 0.0: # close the fits gri_fits.close() else: # close fits, complain and out gri_fits.close() err_msg = ( "{0:s}: The grism image: \n{1:s}\nhas no keyword " "SKY_CPS>=0.0 in the extension {2:d}. This means " "it had NO global\nsky subtraction, which is " "required for the CRR version of aXedrizzle!".format( self.taskname, config_util.getDATA(one_input['grisim']), ext_info['fits_ext'])) raise aXeError(err_msg)
def _check_dpps(self, back=False): # go over all inputs for one_input in self.axe_inputs: # load the config file and get the extension information conf = configfile.ConfigFile( config_util.getCONF(one_input['config'])) ext_info = config_util.get_ext_info( config_util.getDATA(one_input['grisim']), conf) # derive the aXe names axe_names = config_util.get_axe_names(one_input['grisim'], ext_info) # check the DPP file if not os.path.isfile(config_util.getOUTPUT(axe_names['DPP'])): # error and out err_msg = ("{0s:}: The DPP file: {1:s} does not exist!".format( self.taskname, config_util.getOUTPUT(axe_names['DPP']))) raise aXeError(err_msg) # check for the background DPP file if back and not os.path.isfile( config_util.getOUTPUT(axe_names['BCK_DPP'])): # error and out err_msg = ("{0:s}: The background DPP file: {1:s} does not " "exist!".format( self.taskname, config_util.getOUTPUT(axe_names['BCK_DPP']))) raise aXeError(err_msg)
def _get_grism_ext_info(self, grisim='', config='', spec_hdu=None): """Determine the extension information on the grism image. Parameters ---------- grisim : str The name of the grism images config : str The name of the configuration file spec_hdu : int, None The extention number of the spectra data Returns ------- ext_info : dict A dictionary that contains the header extension and the data extension """ if spec_hdu is None: conf = configfile.ConfigFile(getCONF(config)) ext_info = get_ext_info(getDATA(grisim), conf) else: # make by hand the extension information ext_info = {'axe_ext': spec_hdu, 'fits_ext': spec_hdu - 1} # return the extension info return ext_info
def _get_dpp_list(self, inima, confterm, back): """Determine the name of all DPP files""" DPP_list = [] # generate the input list for aXe axe_inputs = axeinputs.aXeInput(inima, confterm) # go over the list of all inputs for an_input in axe_inputs: # load the configuration file conf = configfile.ConfigFile(config_util.getCONF(an_input['config'])) # get the image extensions ext_info = config_util.get_ext_info(config_util.getDATA(an_input['grisim']), conf) # get the name of all axe files axe_names = config_util.get_axe_names(an_input['grisim'], ext_info) # if requested, # append the background DPP file if back: DPP_list.append(axe_names['BCK_DPP']) else: # append the 'normal' DPP name to the list DPP_list.append(axe_names['DPP']) # return the DPP list return DPP_list
def _get_dirname_information(self, dirname=None, config="", grisim="", grism_extinfo=None, dir_hdu=None): """Determine the direct image information. Parameters ---------- dirname : str Diretory name config : str The name of the config file grisim : str The name of the grisim image grism_extinfo : dict Dictionary of header information dir_hdu : fits.HDU FITS header data unit Returns ------- A tuple of the direct image name and a dictionary of extension information """ # check whether ANY direct image information exists if ((dirname is None) and (dir_hdu is None)): # set the grism image as direct image dirname = grisim dirname_extinfo = grism_extinfo elif ((dirname is not None) and (dir_hdu is None)): # load the configuration file; # determine the extension information conf = configfile.ConfigFile(getCONF(config)) dirname_extinfo = get_ext_info(getDATA(grisim), conf) del conf elif ((dirname is not None) and (dir_hdu is not None)): # make by hand the extension information dirname_extinfo = {'axe_ext': dir_hdu, 'fits_ext': dir_hdu - 1} else: # error and out err_msg = ("Specifying NO direct image but a direct image HDU: " "{0:d} makrs NO sense!".format(dir_hdu)) raise aXeError(err_msg) # return the name and the extension info return dirname, dirname_extinfo
def run(self): # load the configuration files; # get the extension info conf = configfile.ConfigFile(config_util.getCONF(self.config)) ext_info = config_util.get_ext_info(config_util.getDATA(self.grisim), conf) del conf # Does this harm data that was astrodrizzled? if (('drzfwhm' in self.params) and (self.params['drzfwhm']) or (('cont_model' in self.params) and (config_util.is_quant_contam(self.params['cont_model'])))): # generate the non-linear distortions from the IDCTAB; # and store them in the fits-file header _log.info( "Generating and storing nonlinear distortions in {0}".format( config_util.getDATA(self.grisim))) nlins = nlincoeffs.NonLinCoeffs(config_util.getDATA(self.grisim), ext_info) nlins.make() nlins.store_coeffs() del nlins # make the object PET's self._make_objPET() # make a background PET if necessary if 'back' in self.params and self.params['back']: _log.info("\nMaking backpet\n") self._make_bckPET() # extract the spectra if 'spectr' in self.params and self.params['spectr']: _log.info("\nMaking spectra\n") self._make_spectra() # make the proper non-quantitative contamination if ('drzfwhm' in self.params and self.params['drzfwhm']) and \ ('cont_model' in self.params and not config_util.is_quant_contam(self.params['cont_model'])): _log.info("\nmaking non quant contam\n") self._make_drzgeocont(ext_info)
def _check_fluxcubes(self): # go over all inputs for one_input in self.axe_inputs: # load the config file and get the extension information conf = configfile.ConfigFile( config_util.getCONF(one_input['config'])) ext_info = config_util.get_ext_info( config_util.getDATA(one_input['grisim']), conf) # derive the aXe names axe_names = config_util.get_axe_names(one_input['grisim'], ext_info) # check the fluxcube if not os.path.isfile(config_util.getDATA(axe_names['FLX'])): # error and out err_msg = ( "{0:s}: The fluxcube file: {1:s} does not exist!".format( self.taskname, config_util.getDATA(axe_names['FLX']))) raise aXeError(err_msg)
def run(self): """Run AXEPREP on one slitless image""" # load the configuration files; # get the extension info conf = configfile.ConfigFile(config_util.getCONF(self.config)) ext_info = config_util.get_ext_info(self.grisim, conf) # make a background PET if necessary if 'backgr' in self.params and self.params['backgr']: self._subtract_background(ext_info) # make a background PET if necessary if 'norm' in self.params and self.params['norm']: self._transform_to_cps(ext_info, conf) # check wheter the gain correction is desired if 'gcorr' in self.params and self.params['gcorr']: # check whether we have NICMOS data if not self._is_nicmos_data(): # check whether gain correction IS desired if self._check_gain_correction(): # make the gain correction self._apply_gain_correction(ext_info) else: # make the gain correction self._apply_gain_correction(ext_info) del conf # return something return 1