def main(): for workdir in curr_work_dirs: work_path = 'observations/' + workdir if not os.path.exists(work_path): os.makedirs(work_path) if not os.path.exists(work_path+'/database'): os.makedirs(work_path+'/database') if not os.path.exists(work_path+'/cosmics'): os.makedirs(work_path+'/cosmics') # don't ask, we just need this os.system("touch %s/blank.txt" % work_path) # enter working folder, all the way to the end iraf.cd(work_path) # maybe useful, maybe not, not sure iraf.prcacheOff() # main steps, should work individually #check_spectra(workdir, '.ec.vh') create_masterbias(workdir) create_masterflat(workdir) #do_ref_apall(workdir) #normalize_masterflat(workdir) clean_folder_write_header(workdir) bias_correct(workdir) #flat_correct(workdir) #remove_cosmics(workdir) do_apall_for_real(workdir) apply_apall(workdir) wavelength_solution(workdir) #check_wav_solution(workdir) apply_wav_solution(workdir) vhelio_correct(workdir) #check_spectra(workdir, '.ec.vh') combine_normalize_images(workdir, combine=False) get_RV(workdir, multi_ref=False, multi_sample=False) # export_spectrum_to_txt(workdir, suffix='.ec_wvl', export_cal=True) # export_spectrum_to_txt(workdir, suffix='_vh_norm') #check_spectra(workdir) #new_flatfield_lens_problems(workdir) # back to mother folder iraf.cd('../') iraf.cd('../')
def init_iraf(): """Initializes the pyraf environment. """ # The display of graphics is not used, so skips Pyraf graphics # initialization and run in terminal-only mode to avoid warning messages. os.environ['PYRAF_NO_DISPLAY'] = '1' # Set PyRAF process caching off to avoid errors if spawning multiple # processes. iraf.prcacheOff() # Load iraf packages and does not show any output of the tasks. iraf.digiphot(_doprint = 0) iraf.apphot(_doprint = 0) iraf.images(_doprint = 0) # Set the iraf.phot routine to scripting mode. iraf.phot.interactive = "no" iraf.phot.verify = "no"
def init_iraf(): """Initializes the pyraf environment. """ # The display of graphics is not used, so skips Pyraf graphics # initialization and run in terminal-only mode to avoid warning messages. os.environ['PYRAF_NO_DISPLAY'] = '1' # Set PyRAF process caching off to avoid errors if spawning multiple # processes. iraf.prcacheOff() # Load iraf packages and does not show any output of the tasks. iraf.digiphot(_doprint=0) iraf.apphot(_doprint=0) iraf.images(_doprint=0) # Set the iraf.phot routine to scripting mode. iraf.phot.interactive = "no" iraf.phot.verify = "no"
def setiraf(self): """ Set IRAF global parameters and load DAOPHOT package for aperture photometry. Parameters ---------- Returns ------- None """ iraf.prcacheOff() iraf.set(writepars=0) # Load IRAF packages iraf.noao(_doprint = 0) iraf.noao.digiphot(_doprint = 0) iraf.noao.digiphot.daophot(_doprint = 0) return
#!/scisoft/bin/python ''' pyraf equivalents of speedup.cl, processccd.cl, combflat.cl, CCDsort.cl, and IRsort.cl these functions mirror their iraf counterparts pretty closesly, and function in the same way the pyraf wrapper prevents caching problems and lets us easily change directories, execute functions etc some projects have special places to pick up data, like the blazar group the photometric standards, xrb group, and bethany. specific checks are made for those data ''' import pyfits, os, fnmatch, glob, subprocess from pyraf import iraf iraf.prcacheOff() def cpCals(date, fwheel=['sky', 'V', 'R', 'I'], outdir='.'): ''' copy the calibration frames from the date specified by "date" to the directory specefied by "outdir" input: date: YYYYMMDD of the date directory you want to get data from. program will look under /data/yalo180/yalo/SMARTS13m/date/ccd/processed/ for calibrations fwheel: python list specifying the filters of the calibrations you want to copy. by default includes all of them outdir: string specifying the path you want to copy the calibrations to. by default set to "." output: None ''' date = str(date) if len(glob.glob('/data/yalo180/yalo/SMARTS13m/' + date)) == 1: for f in fwheel: try: subprocess.check_output('cp -v /data/yalo180/yalo/SMARTS13m/' +
from astropy import wcs # Importing pyraf -- note that this requires IRAF to be installed # and the "iraf" and "IRAFARCH" environment variables to be set with warnings.catch_warnings(): # Ignore the ImportWarning we often get when importing pyraf, because pyraf # likes to create working dirs with its name in the local dir. warnings.filterwarnings("ignore", message="(.*)Not importing dir(.*)") # Disable pyraf graphics: from stsci.tools import capable capable.OF_GRAPHICS = False from pyraf import iraf from iraf import noao, digiphot, daophot # Turn cache off to enable multiprocessing to be used; # cf. http://www.stsci.edu/institute/software_hardware/pyraf/pyraf_faq#3.5 iraf.prcacheOff() iraf.set(writepars=0) from .utils import timed class DaophotError(Exception): """Raised if Daophot failed to perform an operation.""" pass class Daophot(object): """DAOPHOT wrapper class. The constructor of this class expects to receive ALL the non-default configuration parameters because IRAF is very stateful.
defaults. Set shift=0 in calls to ecreidenfity. 2014-12-17 14:17 IJMC: Added new troubleshooting & alternative flat-normalization approaches, since PyRAF's apnormalize continues to give me trouble. 2016-10-15 02:09 IJMC: Trying it for ARIES. This script has been around for a little while! 2016-10-18 13:50 IJMC: Now apply ARIES quad-detector crosstalk correction 2017-10-11 16:41 IJMC: Handing this off to Nicholas Mehrle. Good luck! 2017-10-25 ????? NM : Moved version control to Git """ import os, sys, shutil from pyraf import iraf as ir ir.prcacheOff() # Might be necessary for some iraf tasks with multiprocessing, unsure ir.set(writepars=0) from scipy import interpolate, isnan, isinf try: from astropy.io import fits as pyfits except: import pyfits import lib.nsdata as ns import lib.spec as spec import numpy as ny from pylab import find import pdb