def puftcorr_iraf(input, output): #Grab the iraf symbolset & stuff them in the environment variable. if 'nref' not in os.environ: os.environ['nref'] = iraf.osfn('nref$') if 'nicmos' not in os.environ: os.environ['nicmos'] = iraf.osfn('nicmos$') #Run the task. try: dopuft = puftcorr.clean(input, output) except NoPuftError as e: print(e)
def getGraphcap(filename=None): """Get graphcap file from filename (or cached version if possible)""" if filename is None: filename = iraf.osfn(iraf.envget('graphcap','dev$graphcap')) if not graphcapDict.has_key(filename): graphcapDict[filename] = graphcap.GraphCap(filename) return graphcapDict[filename]
def calcos_iraf(input, verbosity=1, savetmp=no, outdir="", find_target=no, cutoff=-1., shift_file="", csum=no, raw_csum=no, compress=no, comp_param="gzip,-0.01", binx=1, biny=1, stimfile="", livefile="", burstfile="", version=None): # Interpret input parameters find_target = _toBoolean(find_target) csum = _toBoolean(csum) raw_csum = _toBoolean(raw_csum) savetmp = _toBoolean(savetmp) compress = _toBoolean(compress) if outdir.strip() == "": outdir = None if outdir is not None: outdir = iraf.osfn(outdir) if cutoff <= 0.: cutoff = None if shift_file.strip() == "": shift_file = None if stimfile.strip() == "": stimfile = None if livefile.strip() == "": livefile = None if burstfile.strip() == "": burstfile = None calcos.calcos(input, outdir=outdir, verbosity=verbosity, find_target={ "flag": find_target, "cutoff": cutoff }, create_csum_image=csum, raw_csum_coords=raw_csum, binx=binx, biny=biny, compress_csum=compress, compression_parameters=comp_param, shift_file=shift_file, save_temp_files=savetmp, stimfile=stimfile, livetimefile=livefile, burstfile=burstfile)
def rnlincor_iraf(input, output, nozpcorr): #Grab the iraf symbolset & stuff them in the environment variable. if 'nref' not in os.environ: os.environ['nref'] = iraf.osfn('nref$') if 'nicmos' not in os.environ: os.environ['nicmos'] = iraf.osfn('nicmos$') #Handle optional file specifications opt = {'nozpcorr': nozpcorr} #Run the task. try: rnlincor.run(input, output, **opt) except ValueError as e: print("ValueError: ", str(e)) except KeyError as e: print("KeyError: ", str(e))
section=section, units=units, pixfrac=pixfrac, prodonly=prodonly, bits_final=_bits_final, bits_single=_bits_single, wt_scl=wt_scl, in_units=in_units, fillval=fillval, idckey=idckey) drobj.run(save=save, build=build, single=single, clean=clean) # Remove intermediate files #if clean == yes: # drobj.clean() # Setup PyDrizzle as an IRAF task here # by setting up an absolute path to the parfile... #_ospath = os.path # File that gets picked up here is: iraffunctions.py #_abspath = _ospath.split(_ospath.abspath(__file__))[0] #parfile = os.path.join(_abspath,'pydrizzle.par') parfile = iraf.osfn(_parfile) pyd = iraf.IrafTaskFactory(taskname=_taskname, value=parfile, pkgname=PkgName, pkgbinary=PkgBinary, function=pydriz_iraf) iraf.pydrizzle.version = pydrizzle.__version__
import sys import os.path import iraf _aotools_path = os.path.dirname(os.path.dirname(iraf.osfn('aotools$'))) if _aotools_path not in sys.path: # Add the directory to path. sys.path.insert(1, _aotools_path)
""" Inserts the directory containing links to all Python-based tasks in the STSDAS tree to the default Python path. """ from __future__ import division # confidence high import iraf, sys #Define path to top level Python directory in STSDAS _path = iraf.osfn('stsdas$python') # If directory not already in PYTHONPATH,... if _path not in sys.path: # Add the directory to path. sys.path.insert(1, _path)
#-------------------------------------------------------------- # # The main part starts here: # #axesimpath = iraf.envget('axesim') #sys.path.append(axesimpath) #print sys.path # # Check to see that all the executables are present # _present = yes for bin in _execfiles: _fname = iraf.osfn(_bin_dir + bin) if findFile(_fname) == no: _present = no # Now, decide whether to define the package or not if _present == yes: # All binaries are present, so... # ... acknowledge those responsible for the software # and where users can get support, then... print(_package_motd) else: # Tell user something was missing # and don't define anything... print(_abort_msg)
def saaclean_iraf(calcimage, targimage, output,clobber=None, readsaaper=None,saaperfile=None, writesaaper=None, flaatsaaper=None, darkpath=None,scale=None,wf1=None,wf2=None, crthresh=None,noisethresh=None,binsigfrac=None, stepsize=None, fitthresh=None, thresh=None, histbinwidth=None,nclip=None, hirange=None,lorange=None, fitmult=None,applied=None,hi_nr=None,lo_nr=None, alldiags=None,diagroot=None): # Don't specify any default values here - they are in the parfile. #Grab the iraf symbolset & stuff them in the environment variable. if 'nref' not in os.environ: os.environ['nref']=iraf.osfn('nref$') ## if 'nicmos' not in os.environ: ## os.environ['nicmos']=iraf.osfn('nicmos$') if 'nicmos' not in os.environ: os.environ['nicmos']=iraf.osfn('nicmos$') #If we want to fit the threshold, override any existing value of thresh. if fitthresh == yes: thresh=None #If we want to turn on all the diagnostic files,set up the filenames if alldiags: outroot='_'+os.path.splitext(os.path.basename(output))[0] flatsaaperfile=iraf.osfn(diagroot)+outroot+'_flat_saaper.fits' maskfile=iraf.osfn(diagroot)+outroot+'_mask.fits' diagfile=iraf.osfn(diagroot)+outroot else: flatsaaperfile=maskfile=diagfile=None #Make sure the darkpath directory exists darkpath=iraf.osfn(darkpath) if not os.path.isdir(darkpath): raise IOError('darkpath = %s does not exist'%darkpath) #Create the parameter structure pars=saaclean.params(darkpath=darkpath, saaperfile=saaperfile, clobber=clobber, readsaaper=readsaaper, writesaaper=writesaaper, flatsaaperfile=flatsaaperfile,maskfile=maskfile, scale=scale,wf1=wf1,wf2=wf2, crthresh=crthresh,noisethresh=noisethresh, binsigfrac=binsigfrac, stepsize=stepsize,thresh=thresh, histbinwidth=histbinwidth, nclip=nclip, fitthresh=fitthresh, hirange=hirange,lorange=lorange, dofit=fitmult,diagfile=diagfile) #Run the task. try: saaper,img = saaclean.clean(calcimage,targimage,output,pars) #Fill in the output parameters: Do this later! try: iraf.saaclean.thresh=img.thresh iraf.saaclean.applied=img.appstring iraf.saaclean.hi_nr=img.domains['high'].nr iraf.saaclean.lo_nr=img.domains['low'].nr except AttributeError as e: print(str(e)) print("Cannot fill output parameter in iraf task: continuing.") except NoPersistError as e: iraf.saaclean.applied='n/a' print("\t %s"%str(e)) except BadThreshError as e: iraf.saaclean.applied='aborted' print("\n\t %s"%str(e)) print(""" It appears that the fitting process for the threshold has failed. You may wish to examine the histogram of the persistence model image, and re-run the task, but set the threshold by hand.""") print("\nTask aborting...") except NegScaleError as e: iraf.saaclean.applied='aborted' print("\n\t %s"%str(e)) print(""" It appears that the fitting process to determine the best scale factor for this domain has failed. You may wish to examine the contents of the corresponding diag_*signal_domain.dat file (produced if saaclean.alldiags = 'yes') to see what's wrong. """) print("\nTask aborting...") except AlreadyDone as e: print("\n\t %s"%str(e)) print(""" SCNAPPLD keyword shows that SAA correction has already been applied to this file. This task will produce incorrect results if performed on an image that has already been corrected.""") print("\nTask aborting...") except LinAlgError as e: print("\n\t %s"%str(e)) print(""" Encountered Linear Algebra Error during the gauss-poly fit of the SAA persistence model histogram. The scaled histogram data that was being fit has been printed out in the _gp_hist.txt file for examination. This problem sometimes occurs due to a poor selection of the histbinwidth parameter; you may want to tweak that value.""") print("\nTask aborting...")
# Inserts the directory containing links # to all Python-based tasks in the STSDAS tree to # the default Python path. import iraf, sys # define path to top level Python directory in STSDAS _path = iraf.osfn('kepler$') # if directory not already in PYTHONPATH,... if _path not in sys.path: # Add the directory to path. sys.path.insert(1, _path)
# Inserts the directory containing links # to all Python-based tasks in the STSDAS tree to # the default Python path. import iraf, sys # define path to top level Python directory in STSDAS _path = iraf.osfn("kepler$") # if directory not already in PYTHONPATH,... if _path not in sys.path: # Add the directory to path. sys.path.insert(1, _path)