Exemple #1
0
         `len(plist)`, char="=")
 for pkg in plist:
     if not ptried.has_key(pkg):
         ptried[pkg] = 1
         nnew = nnew+1
         l1 = (70-len(pkg))//2
         l2 = 70-l1-len(pkg)
         printcenter(pkg)
         if pkg == "digiphotx":
             print """
                     Working around bug in digiphotx.
                     It screws up subsequent loading of digiphot tasks.
                     (It happens in IRAF too.)"""
         else:
             try:
                 iraf.load(pkg)
             except KeyboardInterrupt:
                 print 'Interrupt'
                 keepGoing = 0
                 break
             except Exception, e:
                 sys.stdout.flush()
                 traceback.print_exc()
                 if e.__class__ == MemoryError:
                     keepGoing = 0
                     break
                 print "...continuing...\n"
 ntotal = ntotal + nnew
 printcenter("Finished pass "+`npass` +
         " new pkgs " + `nnew` +
         " total pkgs " + `ntotal`, char="=")
Exemple #2
0
 printcenter("pass " + ` npass ` + " trying " + ` len(plist) `, char="=")
 for pkg in plist:
     if not ptried.has_key(pkg):
         ptried[pkg] = 1
         nnew = nnew + 1
         l1 = (70 - len(pkg)) // 2
         l2 = 70 - l1 - len(pkg)
         printcenter(pkg)
         if pkg == "digiphotx":
             print """
                     Working around bug in digiphotx.
                     It screws up subsequent loading of digiphot tasks.
                     (It happens in IRAF too.)"""
         else:
             try:
                 iraf.load(pkg)
             except KeyboardInterrupt:
                 print 'Interrupt'
                 keepGoing = 0
                 break
             except Exception, e:
                 sys.stdout.flush()
                 traceback.print_exc()
                 if e.__class__ == MemoryError:
                     keepGoing = 0
                     break
                 print "...continuing...\n"
 ntotal = ntotal + nnew
 printcenter("Finished pass " + ` npass ` + " new pkgs " + ` nnew ` +
             " total pkgs " + ` ntotal `,
             char="=")
# Eventually, get all initializations from initobs:
print data
obs = ns.initobs(data, remote=(not local))
_proc = obs[1]
_raw = obs[8]
n_ap = obs[14]  #  number of apertures (i.e., echelle orders)
filter = obs[15]  # photometric band in which we're operating
prefn = obs[16]  # filename prefix
calnod = obs[17]  # whether A0V calibrators nod, or not

procData = processCal or processTarg
badval = 0
ir.task(bfixpix=_iraf + "bfixpix.cl")
ir.task(bfixpix_one=_iraf + "bfixpix_one.cl")
#ir.load('fitsutil')
ir.load('noao')
ir.load('astutil')
ir.load("imred")
ir.load('echelle')
ir.load('twodspec')
ir.load('apextract')

telluric_list = ns._home + '/proj/pcsa/data/atmo/telluric_hr_' + filter + '.dat'
if filter == 'K' or filter == 'H':
    horizsamp = "10:500 550:995"

elif filter == 'L':
    horizsamp = "10:270 440:500 550:980"

elif filter == 'Karies':
    horizsamp = "10:995"
Exemple #4
0
def compileall():
    """Compile all CL procedures & packages"""

    # start the timer

    t0 = time.time()

    # now do the IRAF startup

    from pyraf import iraf, cl2py, clcache, irafglobals
    from pyraf.iraftask import IrafCLTask, IrafPkg

    # close the old code cache and reopen without system cache

    cl2py.codeCache.close()
    del clcache.codeCache

    userCacheDir = os.path.join(irafglobals.userIrafHome, 'pyraf')
    if not os.path.exists(userCacheDir):
        try:
            os.mkdir(userCacheDir)
            print 'Created directory %s for cache' % userCacheDir
        except OSError:
            print 'Could not create directory %s' % userCacheDir
    dbfile = 'clcache'
    clcache.codeCache = clcache._CodeCache(
        [os.path.join(userCacheDir, dbfile)])
    cl2py.codeCache = clcache.codeCache

    iraf.setVerbose()

    pkgs_tried = {}
    tasks_tried = {}
    npkg_total = 0
    ntask_total = 0
    ntask_failed = 0

    # main loop -- keep loading packages as long as there are
    # new ones to try, and after loading each package look for
    # and initialize any CL tasks

    npass = 0
    pkg_list = iraf.getPkgList()
    keepGoing = 1
    while keepGoing and (npkg_total < len(pkg_list)):
        npass = npass + 1
        pkg_list.sort()
        npkg_new = 0
        printcenter("pass %d: %d packages (%d new)" %
                    (npass, len(pkg_list), len(pkg_list) - npkg_total),
                    char="=")
        for pkg in pkg_list:
            if not pkgs_tried.has_key(pkg):
                pkgs_tried[pkg] = 1
                npkg_new = npkg_new + 1
                printcenter(pkg)
                if pkg in ["newimred", "digiphotx"]:
                    print """
Working around bugs in newimred, digiphotx.
They screw up subsequent loading of imred/digiphot tasks.
(It happens in IRAF too.)"""
                    sys.stdout.flush()
                else:
                    try:
                        # redirect stdin in case the package tries to
                        # prompt for parameters (this aborts but keeps
                        # going)
                        iraf.load(pkg, kw={'Stdin': 'dev$null'})
                    except KeyboardInterrupt:
                        print 'Interrupt'
                        sys.stdout.flush()
                        keepGoing = 0
                        break
                    except Exception, e:
                        sys.stdout.flush()
                        traceback.print_exc()
                        if isinstance(e, MemoryError):
                            keepGoing = 0
                            break
                        print "...continuing...\n"
                        sys.stdout.flush()
                # load tasks after each package
                task_list = iraf.getTaskList()
                task_list.sort()
                for taskname in task_list:
                    if not tasks_tried.has_key(taskname):
                        tasks_tried[taskname] = 1
                        taskobj = iraf.getTask(taskname)
                        if isinstance(taskobj, IrafCLTask) and \
                                        not isinstance(taskobj,IrafPkg):
                            ntask_total = ntask_total + 1
                            print "%d: %s" % (ntask_total, taskname)
                            sys.stdout.flush()
                            try:
                                taskobj.initTask()
                            except KeyboardInterrupt:
                                print 'Interrupt'
                                sys.stdout.flush()
                                keepGoing = 0
                                break
                            except Exception, e:
                                sys.stdout.flush()
                                traceback.print_exc(10)
                                if isinstance(e, MemoryError):
                                    keepGoing = 0
                                    break
                                print "...continuing...\n"
                                sys.stdout.flush()
                                ntask_failed = ntask_failed + 1
                if not keepGoing: break
Exemple #5
0
date = '20151102'
date = '20151101'

_data = _home + '/proj/mdwarfs/data/raw/' + date +'/'
_proc = _home + '/proj/mdwarfs/data/proc/' + date +'/'

doextract=True
writefiles = True
wavecal = True
clobber = True

ordlocs = None
_wldat = 'database'
lamp_list = _home + '/proj/pcsa/data/atmo/efosc_gr16_HeAr.dat'

iraf.load('fitsutil')
iraf.load('noao')
iraf.load('astutil')
iraf.load("imred")
iraf.load('specred')

# Set EFOSC parameters:
#iraf.unlearn('specred')

# Set parameters for aperture tracing, flat-field normalizing, etc.
iraf.specred.dispaxis = 2
iraf.specred.apfind.nfind = 1
iraf.specred.apfind.recenter = "Yes"
iraf.specred.apfind.nsum = -3

iraf.apall.ylevel = "INDEF" #0.05
Exemple #6
0
date = '20151102'
date = '20151101'

_data = _home + '/proj/mdwarfs/data/raw/' + date + '/'
_proc = _home + '/proj/mdwarfs/data/proc/' + date + '/'

doextract = True
writefiles = True
wavecal = True
clobber = True

ordlocs = None
_wldat = 'database'
lamp_list = _home + '/proj/pcsa/data/atmo/efosc_gr16_HeAr.dat'

iraf.load('fitsutil')
iraf.load('noao')
iraf.load('astutil')
iraf.load("imred")
iraf.load('specred')

# Set EFOSC parameters:
#iraf.unlearn('specred')

# Set parameters for aperture tracing, flat-field normalizing, etc.
iraf.specred.dispaxis = 2
iraf.specred.apfind.nfind = 1
iraf.specred.apfind.recenter = "Yes"
iraf.specred.apfind.nsum = -3

iraf.apall.ylevel = "INDEF"  #0.05
def compileall():
    """Compile all CL procedures & packages"""

    # start the timer

    t0 = time.time()

    # now do the IRAF startup

    from pyraf import iraf, cl2py
    from pyraf.iraftask import IrafCLTask, IrafPkg

    iraf.setVerbose()

    pkgs_tried = {}
    tasks_tried = {}
    npkg_total = 0
    ntask_total = 0
    ntask_failed = 0

    # main loop -- keep loading packages as long as there are
    # new ones to try, and after loading each package look for
    # and initialize any CL tasks

    npass = 0
    pkg_list = iraf.getPkgList()
    keepGoing = 1
    while keepGoing and (npkg_total<len(pkg_list)):
        npass = npass + 1
        pkg_list.sort()
        npkg_new = 0
        printcenter("pass %d: %d packages (%d new)" %
                (npass,len(pkg_list),len(pkg_list)-npkg_total), char="=")
        for pkg in pkg_list:
            if not pkgs_tried.has_key(pkg):
                pkgs_tried[pkg] = 1
                npkg_new = npkg_new+1
                printcenter(pkg)
                if pkg in ["newimred","digiphotx"]:
                    print """
Working around bugs in newimred, digiphotx.
They screw up subsequent loading of imred/digiphot tasks.
(It happens in IRAF too.)"""
                    sys.stdout.flush()
                else:
                    try:
                        # redirect stdin in case the package tries to
                        # prompt for parameters (this aborts but keeps
                        # going)
                        iraf.load(pkg,kw={'Stdin': 'dev$null'})
                    except KeyboardInterrupt:
                        print 'Interrupt'
                        sys.stdout.flush()
                        keepGoing = 0
                        break
                    except Exception, e:
                        sys.stdout.flush()
                        traceback.print_exc()
                        if isinstance(e,MemoryError):
                            keepGoing = 0
                            break
                        print "...continuing...\n"
                        sys.stdout.flush()
                # load tasks after each package
                task_list = iraf.getTaskList()
                task_list.sort()
                for taskname in task_list:
                    if not tasks_tried.has_key(taskname):
                        tasks_tried[taskname] = 1
                        taskobj = iraf.getTask(taskname)
                        if isinstance(taskobj, IrafCLTask) and \
                                        not isinstance(taskobj,IrafPkg):
                            ntask_total = ntask_total+1
                            print "%d: %s" % (ntask_total, taskname)
                            sys.stdout.flush()
                            try:
                                taskobj.initTask()
                            except KeyboardInterrupt:
                                print 'Interrupt'
                                sys.stdout.flush()
                                keepGoing = 0
                                break
                            except Exception, e:
                                sys.stdout.flush()
                                traceback.print_exc(10)
                                if isinstance(e,MemoryError):
                                    keepGoing = 0
                                    break
                                print "...continuing...\n"
                                sys.stdout.flush()
                                ntask_failed = ntask_failed+1
                if not keepGoing: break
print('>>> 0 = no')
ans = raw_input('>>> Your choice:   ')

if ans == '0':
    print('>>> Whoa, a bug already?! Shoot Elaine an email.')
    sys.exit()
else:
    print('>>> Alright, on to the reduction...')
    time.sleep(2)

#################
#start reduction#
#################

#~~~~load iraf packages
iraf.load('gemini')
time.sleep(2)
iraf.load('gmos')

#~~~~flat 1 reduction

print('%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%')
print('starting flat reduction and fiber identification')
print('%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%')
time.sleep(2)

def run_gfreduce(inimage,biasimage,refimage,slit,cr,wt,ss,inter,os,tr,bi,ex,fl,ap,weight,trac,rec,orde):
    iraf.gemini.gmos.gfreduce(inimage, \
                              fl_inter=inter, \
                              fl_over=os, \
                              fl_trim=tr, \
Exemple #9
0
# Preprocessing
print "START PREPROCESSING"

# Autogenerate module documentation in *modules* directory for all modules listed in *modules.lst*
print "Automatica2014generating API documentation for modules in 'modules.lst'."

# Remove old versions
if os.path.exists('modules'):
    shutil.rmtree('modules')

os.mkdir('modules')
modstubs.autogen('modules.lst', 'modules')

# Autogenerate rst from IRAF help files
print "Automatically converting IRAF help file documentation for tasks listed in 'tasks.lst'."
iraf.load('pysalt')
pysalt_list = []
for i in iraf.getTaskList():
    i = i.split('.')
    if i[0].count('pysalt') and len(i) > 1:
        try:
            iraf.load(i[1])
            pysalt_list.append(i[1])
        except:
            pass

tasks = []
for i in iraf.getTaskList():
    i = i.split('.')
    if i[0] in pysalt_list and len(i) > 1:
        tasks.append('%s/doc/%s.hlp' % (i[0], i[1]))
Exemple #10
0
# Preprocessing
print "START PREPROCESSING"

# Autogenerate module documentation in *modules* directory for all modules listed in *modules.lst*
print "Automatica2014generating API documentation for modules in 'modules.lst'."

# Remove old versions
if os.path.exists('modules'):
    shutil.rmtree('modules')

os.mkdir('modules')
modstubs.autogen('modules.lst','modules')

# Autogenerate rst from IRAF help files
print "Automatically converting IRAF help file documentation for tasks listed in 'tasks.lst'."
iraf.load('pysalt')
pysalt_list = []
for i in iraf.getTaskList():
    i = i.split('.')
    if i[0].count('pysalt') and len(i)>1:
         try:
             iraf.load(i[1])
             pysalt_list.append(i[1])
         except:
             pass

tasks=[]
for i in iraf.getTaskList():
    i = i.split('.')
    if i[0] in pysalt_list and len(i)>1: 
       tasks.append('%s/doc/%s.hlp' % (i[0], i[1]))
print('0=no')
ans = raw_input('your choice:   ')

if ans == '0':
    print('Whoa, a bug already?! Shoot Elaine an email.')
    sys.exit()
else:
    print('Alright, on to the reduction...')
    time.sleep(2)

#################
#start reduction#
#################

#~~~~load iraf packages
iraf.load('gemini')
time.sleep(2)
iraf.load('gmos')

#~~~~flat reduction

print('%%%%%%%%%%%%%%%%%%%%%%%')
print('starting flat reduction')
print('%%%%%%%%%%%%%%%%%%%%%%%')
time.sleep(2)


def run_gfreduce(inimage, biasimage, refimage, slit, cr, wt, ss, inter, os, tr,
                 bi, ex, fl, ap, weight, trac, rec, orde):
    iraf.gemini.gmos.gfreduce(inimage, \
                              fl_inter=inter, \
Exemple #12
0
def test_load_package(pkg):
    iraf.load(pkg, doprint=False, hush=False)