def backest(grism='', config='', np=None, interp=None, niter_med=None, niter_fit=None, kappa=None, smooth_length=None, smooth_fwhm=None, old_bck=False, mask=False, in_af="", out_bck=None): """Function for the aXe task BACKEST""" # check for required environment variables axe_setup() # run BACKEST backest = axelowlev.aXe_BE(grism, config, np=np, interp=interp, niter_med=niter_med, niter_fit=niter_fit, kappa=kappa, smooth_length=smooth_length, smooth_fwhm=smooth_fwhm, old_bck=old_bck, mask=mask, in_af=in_af, out_bck=out_bck) backest.runall()
def pet2spc(grism='', config='', use_bpet=False, adj_sens=True, weights=False, do_flux=True, drzpath=False, in_af="", opet=None, bpet=None, out_spc=None, silent=False): """Function for the aXe task PET2SPC""" # check for required environment variables axe_setup() pet2spc = axelowlev.aXe_PET2SPC(grism, config, use_bpet=use_bpet, adj_sens=adj_sens, weights=weights, do_flux=do_flux, drzpath=drzpath, in_af=in_af, opet=opet, bpet=bpet, out_spc=out_spc) pet2spc.runall(silent)
def petcont(grism='', config='', cont_model="", model_scale=None, spec_models="", object_models="", inter_type='linear', lambda_psf=None, cont_map=True, in_af="", no_pet=False, silent=False): """Function for the aXe task PETCONT""" # check for required environment variables axe_setup() # run PETCONT petcont = axelowlev.aXe_PETCONT(grism, config, cont_model=cont_model, model_scale=model_scale, spec_models=spec_models, object_models=object_models, inter_type=inter_type, lambda_psf=lambda_psf, cont_map=cont_map, in_af=in_af, no_pet=no_pet, silent=silent) petcont.runall(silent)
def gol2af(grism='', config='', mfwhm=None, back=False, orient=True, slitless_geom=True, exclude=False, lambda_mark=None, dmag=None, out_af="", in_gol=None, silent=False): """Function for the aXe task GOL2AF""" # check for required environment variables axe_setup() # run GOL2AF gol2af = axelowlev.aXe_GOL2AF(grism, config, back=back, mfwhm=mfwhm, orient=orient, slitless_geom=slitless_geom, exclude=exclude, lambda_mark=lambda_mark, dmag=dmag, in_gol=in_gol, out_af=out_af) gol2af.runall(silent)
def petff(grism='', config='', back=False, ffname=None): """Function for the aXe task PETFF""" # check for required environment variables axe_setup() # run PETFF petff = axelowlev.aXe_PETFF(grism, config, back=back, ffname=ffname) petff.runall()
def axeddd(inlist='', configs='', mult_drizzle_par=None, infwhm=0.0, outfwhm=0.0, back=False, clean=True, makespc=True, adj_sens=True, opt_extr=True, driz_separate=False): """Function for aXedrizzle""" # make the general setup axe_setup(tmpdir=True) # do all the input checks inchecks = inputchecks.InputChecker('AXEDRIZZLE', inlist, configs) inchecks.check_axedrizzle(infwhm, outfwhm, back) inchecks.check_axecrr(back) # unload the DPP's dpps = dppdumps.DPPdumps(inlist, configs, False) dpps.filet_dpp(opt_extr) # get the contamination information cont_info = dpps.is_quant_contam() # assemble the drizzle parameters drizzle_params = drizzleobjects.DrizzleParams(configs) # make a list of drizzle objects dols = drizzleobjects.DrizzleObjectList(drizzle_params, mult_drizzle_par, cont_info, opt_extr, back) # check all files dols.check_files() # prepare and do the drizzling dols.prepare_drizzle() dols.drizzle() # if there are no background files, immediately extract # the spectra if makespc: # extract spectra from the deep 2D stamps mefs = mefobjects.MEFExtractor(drizzle_params, dols, opt_extr=opt_extr) mefs.extract(infwhm, outfwhm, adj_sens) # delete tmp objects if # requested if clean: dols.delete_files()
def drzprep(inlist='', configs='', back=False, opt_extr=True): """Convenience function for the aXe task DRZPREP""" # make the general setup; # needed to define # the BIN-directory axe_setup() # make the objects task object, run it an do the cleaning prepArator = axelowlev.aXe_DRZPREP(inlist, configs, back=back, opt_extr=opt_extr) prepArator.runall()
def af2pet(grism='', config='', back=False, in_af="", out_pet=None, silent=False): """Function for the aXe task AF2PET""" # check for required environment variables axe_setup() # run AF2PET af2pet = axelowlev.aXe_AF2PET(grism, config, back=back, in_af=in_af, out_pet=out_pet) af2pet.runall(silent)
def drz2pet(inlist='', config='', opt_extr=False, back=False, in_af="", out_pet=None): """Function for the aXe task DRZ2PET""" # check for required environment variables axe_setup() # run the DRZ2PET task drz2pet = axelowlev.aXe_DRZ2PET(inlist=inlist, config=config, opt_extr=opt_extr, back=back, in_af=in_af, out_pet=out_pet) drz2pet.runall()
def sex2gol(grism='', config='', in_sex='', use_direct=True, direct=None, dir_hdu=None, spec_hdu=None, out_sex=None, silent=False): """Function for the aXe task SEX2GOL""" # make the general setup axe_setup() sex2gol = pysex2gol.Sex2GolPy(grism, config, in_sex=in_sex, dirname=direct, out_sex=out_sex, spec_hdu=spec_hdu, dir_hdu=dir_hdu) sex2gol.runall(silent)
def axedirim(dirname='', config='', tpass_direct='', model_spectra=None, model_images=None, model_scale=None, tel_area=None, silent=False): """Function for the aXe task AXEDIRIM""" # check for required environment variables axe_setup() # run the command and delete what's left axedirim = axelowlev.aXe_DIRIMAGE(dirname, config, tpass_direct, model_spectra=model_spectra, model_images=model_images, model_scale=model_scale, tel_area=tel_area) return axedirim.runall(silent)
def stamps(grism='', config='', sampling='rectified', drzpath=False, in_af="", in_pet=None, out_stp=None, silent=False): """Function for the aXe task STAMPS""" # check for required environment variables axe_setup() # run STAMPS stamps = axelowlev.aXe_STAMPS(grism, config, sampling=sampling, drzpath=drzpath, in_af=in_af, in_pet=in_pet, out_stp=out_stp) stamps.runall(silent)
def axegps(grism='', config='', beam_ref='', xval=None, yval=None): """Function for the aXe task AXEGPS""" # check for required environment variables axe_setup() axegps = axelowlev.aXe_GPS(grism, config, beam_ref, xval, yval) axegps.runall()
def axecrr(inlist='', configs='', infwhm=0.0, outfwhm=0.0, back=False, clean=True, makespc=True, adj_sens=True, opt_extr=True, driz_separate=False): """Function for aXedrizzle with CosmicRay-rejection""" axe_setup(tmpdir=True) # do all the input checks inchecks = inputchecks.InputChecker('AXEDRIZZLE', inlist, configs) inchecks.check_axedrizzle(infwhm, outfwhm, back) # unload the DPP's dpps = dppdumps.DPPdumps(inlist, configs, False) dpps.filet_dpp(opt_extr) # get the contamination information cont_info = dpps.is_quant_contam() # delete the object del dpps # assemble the drizzle parameters drizzle_params = drizzleobjects.DrizzleParams(configs) # make a list of drizzle objects dols = drizzleobjects.DrizzleObjectList(drizzle_params, cont_info, opt_extr, back=False) _log.info(f"checking files {dols}") dols.check_files() # prepare and perform the drizzling dols.prepare_drizzle() dols.drizzle() # if there are no background # files, immediately extract the spectra if not back and makespc: # extract spectra from the deep 2D stamps mefs = mefobjects.MEFExtractor(drizzle_params, dols, opt_extr=opt_extr) mefs.extract(infwhm, outfwhm, adj_sens) del mefs # delete files if clean: dols.delete_files() del dols if back: # do all the input checks inchecks = inputchecks.InputChecker('AXEDRIZZLE', inlist, configs) inchecks.check_axedrizzle(infwhm, outfwhm, back) # unload the DPP's dpps = dppdumps.DPPdumps(inlist, configs, back=back) dpps.filet_dpp(opt_extr) # get the contamination information # cont_info = dpps.is_quant_contam() del dpps # make a list of drizzle objects back_dols = drizzleobjects.DrizzleObjectList(drizzle_params, None, opt_extr, back=back) # check all files back_dols.check_files() # prepare and do the drizzling back_dols.prepare_drizzle() back_dols.drizzle() # extract the spectra, if makespc: mefs = mefobjects.MEFExtractor(drizzle_params, dols, back_dols, opt_extr=opt_extr) mefs.extract(infwhm, outfwhm, adj_sens) if clean: dols.delete_files() back_dols.delete_files()
def check_simdispim_input(self, incat, config, lambda_psf, model_spectra, model_images, nx, ny, exptime, bck_flux, extraction, extrfwhm, orient, slitless_geom, adj_sens): """Does basic checks on the parameters The method checks whether all input values are reasonable, e.g. the exposure time and background flux >= 0.0 and similar. Input files are checked for existence. Also the input type is checked for the numbers. Parameters ---------- incat: str name of model object table config: str aXe configuration file name lambda_psf: float wavelength the object shapes were determined at model_spectra: str name of model spectra model_images: str name of model images nx: int number of pixels in x ny: int number of pixels in y exptime: float exposure time bck_flux: float flux in background extraction: bool flag for default extraction extrfwhm: float multiplier for extraction width orient: bool flag for tilted extraction slitless_geom: bool flag for slitless optimized extraction adj_sens: bool flag for adjusted flux conversion """ # do the setup config_util.axe_setup(axesim=True) # check the existence of the # model object table if not os.path.isfile(config_util.getDATA(incat)): msg = ("The Model Object Table does not exist: {}".format( config_util.getDATA(incat))) raise aXeSIMError(msg) # check the existence of the # axe configuration file if not os.path.isfile(config_util.getCONF(config)): msg = ("The aXe configuration file does not exist: {}".format( config_util.getCONF(config))) raise aXeSIMError(msg) else: # load the aXe configuration file conf = configfile.ConfigFile(config_util.getCONF(config)) # make the internal checks n_sens = conf.check_files(check_glob=False) # make sure there is # at least one sens. file if n_sens < 1: msg = ("There must be at least one sensitivity file in: {}". format(config_util.getCONF(config))) raise aXeSIMError(msg) # check whether the configuration files # allows the requested extraction if extraction and (slitless_geom or adj_sens): extr_ready = conf.confirm_extrkeys() # error and out if not extr_ready: msg = ("It is not possible to perform the requested" "extraction. The likely cause is that the configuration" "file does NOT contain the keywords 'POBJSIZE' or " "'SMFACTOR' or their values are NOT reasonable " "(e.g. <0.0)!") raise aXeSIMError(msg) # check the lambda_psf-value if ((lambda_psf is not None) and (lambda_psf <= 0.0)): msg = ("Value for 'lambda_psf' must be positive: {0:s}".format( str(lambda_psf))) raise aXeSIMError(msg) if (model_spectra is not None): # check the existence of the # model spectra file if not os.path.isfile(config_util.getDATA(model_spectra)): msg = ("The model spectra file does not exist: {}".format( config_util.getDATA(model_spectra))) raise aXeSIMError(msg) if model_images is not None: # check the existence of the # model images file if not os.path.isfile(config_util.getDATA(model_images)): msg = ("The model images file does not exist: ".format( config_util.getDATA(model_images))) raise aXeSIMError(msg) # check the nx-value if ((nx is not None) and (nx <= 0.0)): msg = ("Value for 'nx' or 'nx_disp' must be positive: {0:g}". format(nx)) raise aXeSIMError(msg) # check the ny-value if ((ny is not None) and (ny <= 0)): error_message = ("Value for 'ny' or 'ny_disp' must be " "positive: {0:g}".format(ny)) raise aXeSIMError(error_message) # check the exptime-value if ((exptime is not None) and (exptime < 0)): error_message = ("Value for 'exptime' or 'exptime_disp' must be " "positive: {0:g}".format(exptime)) raise aXeSIMError(error_message) # the extraction width must be set! if not extrfwhm: error_message = ("Value for 'extrfwhm' must not be 0.0 to create" "PETs, but extrfwhm={0:0.1f}!".format(extrfwhm)) raise aXeSIMError(error_message) # negative extraction width is significant ONLY # if orient="NO" if orient and extrfwhm < 0.0: error_message = ( "Negative width extrfwhm={0:0.1f} together with " "extraction orient=yes does NOT make sense!".format(extrfwhm)) raise aXeSIMError(error_message) try: # convert to float bck = float(bck_flux) # check for positive value if bck < 0: error_message = ("Value for 'bck_flux' or 'bck_flux_disp'" " most be positive: {0:g}".format(bck_flux)) raise aXeSIMError(error_message) # catch a string except ValueError: # check for existence of file if not os.path.isfile(config_util.getCONF(bck_flux)): error_message = ( "The background file does not exist: {0}".format( config_util.getCONF(bck_flux))) raise aXeSIMError(error_message)
def check_simdirim_input(self, incat, config, tpass_direct, model_spectra, model_images, nx, ny, exptime, bck_flux): """Does basic checks on the parameters The method checks whether all input values are reasonable, e.g. the exposure time and background flux >= 0.0 and similar. Input files are checked for existence. Also the input type is checked for the numbers. Parameters ---------- incat: str name of model object table config: str aXe configuration file name tpass_direct: str total passband file model_spectra: str name of model spectra model_images: str name of model images nx: int number of pixels in x ny: int number of pixels in y exptime: float exposure time bck_flux: float flux in background """ # do the setup config_util.axe_setup(axesim=True) # check the existence of the # model object table if not os.path.isfile(config_util.getDATA(incat)): error_message = ( "The Model Object Table does not exist: {0}".format( config_util.getDATA(incat))) raise aXeSIMError(error_message) # check the existence of the # axe configuration file if not os.path.isfile(config_util.getCONF(config)): error_message = ( "The aXe configuration file does not exist: {0}".format( config_util.getCONF(config))) raise aXeSIMError(error_message) else: # load the aXe configuration file conf = configfile.ConfigFile(config_util.getCONF(config)) # make the internal checks n_sens = conf.check_files(check_glob=False) # make sure there is # at least one sens. file if n_sens < 1: error_message = ("There must be at least one sensitivity " "file in: {0}".format( config_util.getCONF(config))) raise aXeSIMError(error_message) # check the existence of the # total passband file if not os.path.isfile(config_util.getSIMDATA(tpass_direct)): error_message = ( "The total passband file does not exist: {0}".format( config_util.getSIMDATA(tpass_direct))) raise aXeSIMError(error_message) if model_spectra is not None: # check the existence of the # model spectra file if not os.path.isfile(config_util.getDATA(model_spectra)): error_message = ( "The model spectra file does not exist: {0}".format( config_util.getDATA(config))) raise aXeSIMError(error_message) if model_images is not None: # check the existence of the # model images file if not os.path.isfile(config_util.getDATA(model_images)): error_message = ( "The model images file does not exist: {0}".format( config_util.getDATA(config))) raise aXeSIMError(error_message) # check the nx-value if ((nx is not None) and (nx <= 0.0)): error_message = ("Value for 'nx' or 'nx_dir' must be positive: " "{0:s}".format(str(nx))) raise aXeSIMError(error_message) # check the ny-value if ((ny is not None) and (ny <= 0)): error_message = ("Value for 'ny' or 'ny_dir' must be positive: " "{0:s}".format(str(ny))) raise aXeSIMError(error_message) # check the exptime-value if ((exptime is not None) and (exptime < 0)): error_message = ("Value for 'exptime' or 'exptime_dir' must be " "positive: {0:s}".format(str(exptime))) raise aXeSIMError(error_message) if bck_flux is not None: # check the bck_flux-value try: # convert to float bck = float(bck_flux) # check for positive value if bck < 0: error_message = ("Value for 'bck_flux' or 'bck_flux_dir'" " must be positive: {0:s}".format( str(bck_flux))) raise aXeSIMError(error_message) # catch a string except ValueError: # check for existence of file if not os.path.isfile(config_util.getCONF(bck_flux)): error_message = ( "The background file does not exist: {0}".format( config_util.getCONF(bck_flux))) raise aXeSIMError(error_message)
def axecore(inlist='', configs='', fconfterm='', back=False, extrfwhm=None, drzfwhm=None, backfwhm=None, lambda_mark=None, slitless_geom=True, orient=True, exclude=False, cont_model='gauss', model_scale=None, inter_type='linear', lambda_psf=None, np=None, interp=None, niter_med=None, niter_fit=None, kappa=None, smooth_length=None, smooth_fwhm=None, spectr=True, adj_sens=True, weights=False, sampling='drizzle'): """Convenience function for the aXe task AXECORE""" # only temporarily here ???? axe_setup() # do all the file checks inchecks = inputchecks.InputChecker('AXECORE', inlist, configs) inchecks.check_axecore(back, extrfwhm, drzfwhm, backfwhm, orient, slitless_geom, np, interp, cont_model, weights, sampling) # create a list with the basic aXe inputs axe_inputs = axeinputs.aXeInput(inlist, configs, fconfterm) # go over all the input for row in axe_inputs: # make an extraction object _log.info("image is located: {0}".format(row['grisim'])) aXeNator = axesingextr.aXeSpcExtr(row['grisim'], row['objcat'], row['dirim'], row['config'], row['dmag'], back=back, extrfwhm=extrfwhm, drzfwhm=drzfwhm, backfwhm=backfwhm, lambda_mark=lambda_mark, slitless_geom=slitless_geom, orient=orient, exclude=exclude, cont_model=cont_model, model_scale=model_scale, inter_type=inter_type, lambda_psf=lambda_psf, np=np, interp=interp, niter_med=niter_med, niter_fit=niter_fit, kappa=kappa, smooth_length=smooth_length, smooth_fwhm=smooth_fwhm, spectr=spectr, adj_sens=adj_sens, weights=weights, sampling=sampling) aXeNator.run() del aXeNator