Example #1
0
    for i in range(nextend):
        if struct[i].name != 'PRIMARY' or len(struct) == 1:
            #screw variance frames. Pay me more
            #actually do the math
            if is_image:
                struct[i].data = eval('struct[i].data' + str(op) +
                                      'opstruct[i].data')

                if op == '/':
                    #find where division by zero is going to happen
                    zidx = numpy.where(opstruct[i].data == 0)
                    struct[i].data[zidx] = divzero

            else:
                struct[i].data = eval('struct[i].data' + str(op) + 'opstruct')

                if op == '/' and opstruct == 0:
                    struct[i].data = numpy.ones(struct[i].data.shape) * divzero

    return struct


# -----------------------------------------------------------
# main code

parfile = iraf.osfn("saltred$saltarith.par")
t = iraf.IrafTaskFactory(taskname="saltarith",
                         value=parfile,
                         function=saltarith,
                         pkgname='saltred')
Example #2
0
        ])
    parser.add_argument('--verbose',
                        action='store_true',
                        help='Write to a log file?')
    parser.add_argument('--logfile',
                        '-l',
                        default='kepdeltapix.log',
                        help='Name of ascii log file',
                        dest='logfile',
                        type=str)
    parser.add_argument('--status',
                        '-e',
                        help='Exit status (0=good)',
                        default=0,
                        dest='status',
                        type=int)

    args = parser.parse_args()
    cmdLine = True
    kepdeltapix(args.infile, args.rownum, args.columns, args.rows, args.fluxes,
                args.prfdir, args.interpolation, args.tolerance, args.fittype,
                args.imscale, args.cmap, args.verbose, args.logfile,
                args.status, cmdLine)

else:
    from pyraf import iraf
    parfile = iraf.osfn("kepler$kepdeltapix.par")
    t = iraf.IrafTaskFactory(taskname="kepdeltapix",
                             value=parfile,
                             function=kepdeltapix)
Example #3
0
                        help='Overwrite output file?')
    parser.add_argument('--verbose',
                        action='store_true',
                        help='Write to a log file?')
    parser.add_argument('--logfile',
                        '-l',
                        help='Name of ascii log file',
                        default='kepcotrend.log',
                        dest='logfile',
                        type=str)
    parser.add_argument('--status',
                        '-e',
                        help='Exit status (0=good)',
                        default=0,
                        dest='status',
                        type=int)

    args = parser.parse_args()

    cmdLine = True

    kepclip(args.infile, args.outfile, args.ranges, args.plot, args.plotcol,
            args.clobber, args.verbose, args.logfile, args.status, cmdLine)

else:
    from pyraf import iraf
    parfile = iraf.osfn("kepler$kepclip.par")
    t = iraf.IrafTaskFactory(taskname="kepclip",
                             value=parfile,
                             function=kepclip)
Example #4
0
    parser.add_argument('--verbose',
                        action='store_true',
                        help='Write to a log file?')
    parser.add_argument('--logfile',
                        '-l',
                        help='Name of ascii log file',
                        default='kepcotrend.log',
                        dest='logfile',
                        type=str)
    parser.add_argument('--status',
                        '-e',
                        help='Exit status (0=good)',
                        default=0,
                        dest='status',
                        type=int)

    args = parser.parse_args()

    cmdLine = True

    keptrial(args.infile, args.outfile, args.datacol, args.errcol, args.fmin,
             args.fmax, args.nfreq, args.method, args.ntrials, args.plot,
             args.clobber, args.verbose, args.logfile, args.status, cmdLine)

else:
    from pyraf import iraf
    parfile = iraf.osfn("kepler$keptrial.par")
    t = iraf.IrafTaskFactory(taskname="keptrial",
                             value=parfile,
                             function=keptrial)
    msg += '#gratilt=%s\n' % grasteps
    msg += '#arang=%s\n' % arang
    msg += '#artilt=%s\n' % arsteps
    msg += '#filter=%s\n' % rfilter.strip()
    if objid:
        msg += '#slitid=%s\n' % objid
    msg += '#Function=%s\n' % function
    msg += '#Order=%s\n' % order
    msg += '#Starting Data\n'
    dout.write(msg)

    for i in range(len(ws_arr)):
        if ws_arr[i, 0]:
            msg = '%5.2f ' % ws_arr[i, 0]
            msg += ' '.join(['%e' % k for k in ws_arr[i, 1:]])
            dout.write(msg + '\n')
    dout.write('\n')
    dout.close()

    return


# main code

parfile = iraf.osfn("saltspec$specarcstraighten.par")
t = iraf.IrafTaskFactory(
    taskname="specarcstraighten",
    value=parfile,
    function=specarcstraighten,
    pkgname='saltspec')
Example #6
0
    parser.add_argument('--verbose',
                        action='store_true',
                        help='Write to a log file?')
    parser.add_argument('--logfile',
                        '-l',
                        help='Name of ascii log file',
                        default='kepcotrend.log',
                        dest='logfile',
                        type=str)
    parser.add_argument('--status',
                        '-e',
                        help='Exit status (0=good)',
                        default=0,
                        dest='status',
                        type=int)

    args = parser.parse_args()

    kepcotrendsc(args.infile, args.outfile, args.bvfile, args.listbv,
                 args.fitmethod, args.fitpower, args.iterate, args.sigma,
                 args.maskfile, args.scinterp, args.plot, args.clobber,
                 args.verbose, args.logfile, args.status)

else:
    from pyraf import iraf

    parfile = iraf.osfn("kepler$kepcotrend.par")
    t = iraf.IrafTaskFactory(taskname="kepcotrend",
                             value=parfile,
                             function=kepcotrendsc)
Example #7
0
        if 3 in steps:
            wred.flatten(qombo)
        if 4 in steps:
            wred.mkfringe(qombo)
        if 5 in steps:
            wred.defringe(qombo)
        if 6 in steps:
            wred.coadd(qombo)
        if 7 in steps:
            wred.zeropt(qombo)

######################################################################

# location of parameter files
_parfile=pardir + "iqwirc.par"
t=iraf.IrafTaskFactory(taskname="iqwirc",
                       value=_parfile,function=iqwirc)

######################################################################

def main():

    # Command line
    try:
        opts, args = getopt.getopt(sys.argv[1:], 
                          "hcdg:F:f:l:o:r:q:s:",
                         ["help","cals","draft","glob=","flaton=","flatoff=",
                          "log=","object=","filter=","qombo=","step="])
    except getopt.GetoptError:
        # print help information and exit:
        usage()
        sys.exit(2)
Example #8
0
    Needed so that when we do flatcombine iraf doesn't try to do flat correction
    etc. Might need to run before calling any other function. Not sure if specphot
    is appropriate but seems to work.
    """

    iraf.noao(_doprint=0)
    iraf.imred(_doprint=0)
    iraf.ccdred(_doprint=0)

    iraf.setinstrument.setParam('instrument','specphot')
    iraf.setinstrument()

    return None

parfile = iraf.osfn(os.path.join(homedir,'Dropbox/IoA/WHT_Proposal_2015a/Iraf/set_instrument.par') )
t = iraf.IrafTaskFactory(taskname="set_instrument", value=parfile, function=set_instrument)

def liris_pixmap(targetdir):

    """
    Currently there is a shift of pixels on the detector which does not correspond
    to the actual geometrical location. Fixes alignment between top and bottom quadrants
    """

    print 'In directory ' + targetdir
    print 'Applying lxpixmap correction...'

    iraf.lirisdr(_doprint=0)

    # Make input. Finds all files .fit and assumes image in extension 1.
    names = [name for name in os.listdir(targetdir) if (name.endswith('.fit')) & (name.startswith('r'))]
Example #9
0
                          inttype=inttype,
                          debug=False)
        data[j, :] = zeroshift(data[j, :],
                               xarr,
                               nws,
                               blank=blank,
                               inttype=inttype)
    return data


def zeroshift(data, xarr, nws, blank=0, inttype='interp'):
    """Calculate zeropoint shift and apply to the data
    """
    if nws is not None:
        w_arr = nws.value(xarr)
        data = st.interpolate(xarr,
                              w_arr,
                              data,
                              inttype,
                              left=blank,
                              right=blank)
    return data


if not iraf.deftask('specselfid'):
    parfile = iraf.osfn("saltspec$specselfid.par")
    t = iraf.IrafTaskFactory(taskname="specselfid",
                             value=parfile,
                             function=specselfid,
                             pkgname='saltspec')
Example #10
0
    x = np.arange(len(y))
    coef = fit_response(x, y, order, conv, niter)
    response = np.polyval(coef, x)
    response = response / response.mean()

    return response.reshape(len(y), 1)


def fit_response(x, y, order=2, conv=1e-2, niter=20):
    """ Fit a polynomial to the response curve
    """
    coef = np.polyfit(x, y, order)
    s = (y - np.polyval(coef, x)).std()
    for i in range(niter):
        mask = (abs(y - np.polyval(coef, x)) < 3 * s)
        coef = np.polyfit(x[mask], y[mask], order)
        s1 = (y[mask] - np.polyval(coef, x[mask])).std()
        if abs(s1 - s) < conv:
            break
        s = s1
    return coef


# main code

parfile = iraf.osfn("saltspec$specslitnormalize.par")
t = iraf.IrafTaskFactory(taskname="specslitnormalize",
                         value=parfile,
                         function=specslitnormalize,
                         pkgname='saltspec')
Example #11
0
                vhdu1 = saltkey.get('VAREXT', struct[i])
                vhdu2 = saltkey.get('VAREXT', struct[i + 1])
                try:
                    struct[vhdu1].data += xc2 * struct[vhdu2].data
                    struct[vhdu2].data += xc1 * struct[vhdu1].data
                except Exception, e:
                    msg = 'Cannot update the variance frame in %s[%i] because %s' % (
                        infile, vhdu1, e)
                    raise SaltError(msg)

            #print the message
            if log:
                message = '%25s[%1d]  Amp%1d - Amp%1d * %8.6f' % \
                         (infile, i, ext1, ext2, xc2)
                log.message(message, with_header=False, with_stdout=verbose)
                message = '%25s[%1d]  Amp%1d - Amp%1d * %8.6f' % \
                         (infile, i+1, ext2, ext1, xc1)
                log.message(message, with_header=False, with_stdout=verbose)

    return struct


# -----------------------------------------------------------
# main code
if not iraf.deftask('saltxtalk'):
    parfile = iraf.osfn("saltred$saltxtalk.par")
    t = iraf.IrafTaskFactory(taskname="saltxtalk",
                             value=parfile,
                             function=saltxtalk,
                             pkgname='saltred')
Example #12
0
                                 verify=False)
        print "x,y %f,%f to ra,dec %f,%f" % (x, y, refra, refdec)

    iraf.images.imcoords.wcsctran(prefix + "ccmap.db",
                                  "tmp_" + prefix + "pixpixmap.txt",
                                  pmf,
                                  inwcs="world",
                                  outwcs="physical",
                                  columns="3 4 1 2 5 6 7 8",
                                  units="hours")
    ppf = open(prefix + "pixpixmap.txt", 'w')
    for line in file("tmp_" + prefix + "pixpixmap.txt"):
        if line[0] != "#":
            data = line.strip().split()
            if len(data) >= 4:
                data[0], data[1], data[2], data[3] = data[2], data[3], data[
                    0], data[1]
                ppf.write(" ".join(["%13s" % d for d in data]))
                ppf.write("\n")
        else:
            ppf.write(line)
    ppf.close()
    os.remove("tmp_" + prefix + "pixpixmap.txt")


curpath = os.path.dirname(os.path.abspath(__file__))
parfile = iraf.osfn(curpath + "/fit_coords.par")
t = iraf.IrafTaskFactory(taskname="fit_coords",
                         value=parfile,
                         function=fit_coords)
Example #13
0
    if bpm is None:
        bpm = arr * 0.0 + 1.0
        wei = None
    else:
        # correct the weights for the bad pixel mask
        if ivar is None: ivar = arr * 0.0 + 1.0
        wei = ivar * (1 - bpm)
        #TODO: need to add a check to make sure that there are is a place
        #to make sure that one of the weights is at least zero
        check_wei = wei.sum(axis=0)
        wei[0][check_wei == 0] = wei.min()

    if method == 'average':
        c_arr, s_arr = np.average(arr, axis=0, weights=wei, returned=True)
        return c_arr, s_arr
    elif method == 'median':
        return np.median(arr, axis=0), bpm.sum(axis=0)
    else:
        msg = '%s is not a method for combining arrays' % method
        raise SaltError(msg)


# -----------------------------------------------------------
# main code
if not iraf.deftask('saltcombine'):
    parfile = iraf.osfn("saltred$saltcombine.par")
    t = iraf.IrafTaskFactory(taskname="saltcombine",
                             value=parfile,
                             function=saltcombine,
                             pkgname='saltred')
    temp = input.split(",")
    for word in temp:
        words.extend(word.split())
    input = []
    for word in words:
        input.extend(irafglob(word))

    if output == '':
        output = None
    else:
        words = []
        temp = output.split (",")
        for word in temp:
            words.extend (word.split())
        output = words

    if shifts == '':
        shifts = None
    else:
        shifts = [int(v) for v in shifts.split(' ')]

    SH.sshift(input, output=output, shifts=shifts, platescale=platescale,
              tolerance=tolerance)

#  Set up sshift as an IRAF task by setting up an absolute
#  path to the parfile.

dnois = iraf.IrafTaskFactory(taskname='sshift', value=iraf.osfn(_parfile),
                             pkgname=PkgName, pkgbinary=PkgBinary,
                             function=_sshift_iraf)
Example #15
0
    """Return the keyword value.  Throw a warning if it doesn't work """

    try:
        value = saltkey.get(keyword, struct)
        if isinstance(default, str): value = value.strip()
    except SaltIOError:
        value = default
        infile = struct._file.name
        message = 'WARNING: cannot find keyword %s in %s' % (keyword, infile)
        if warn and log: log.message(message, with_header=False)
    if (str(value).strip() == ''): value = default
    if (type(value) != type(default)):
        infile = struct._file.name
        message = 'WARNING: Type mismatch for %s for  %s in %s[0]' % (
            str(value), keyword, infile)
        message += '/n ' + str(type(value)) + ' ' + str(type(default))
        if warn and log: log.message(message, with_header=False)
        value = default

    return value


# -----------------------------------------------------------
# main code
if not iraf.deftask('saltobslog'):
    parfile = iraf.osfn("saltred$saltobslog.par")
    t = iraf.IrafTaskFactory(taskname="saltobslog",
                             value=parfile,
                             function=saltobslog,
                             pkgname='saltred')
Example #16
0
    parser.add_argument('--verbose',
                        action='store_true',
                        help='Write to a log file?')
    parser.add_argument('--logfile',
                        '-l',
                        help='Name of ascii log file',
                        default='kepcotrend.log',
                        dest='logfile',
                        type=str)
    parser.add_argument('--status',
                        '-e',
                        help='Exit status (0=good)',
                        default=0,
                        dest='status',
                        type=int)

    args = parser.parse_args()

    cmdLine = True

    keppixseries(args.infile, args.outfile, args.plotfile, args.plottype,
                 args.filter, args.function, args.cutoff, args.clobber,
                 args.verbose, args.logfile, args.status, cmdLine)

else:
    from pyraf import iraf
    parfile = iraf.osfn("kepler$keppixseries.par")
    t = iraf.IrafTaskFactory(taskname="keppixseries",
                             value=parfile,
                             function=keppixseries)
Example #17
0
    # convert from string to list
    location = commaSep(location, "float")
    extrsize = commaSep(extrsize, "int")

    inlist = input.split(",")
    more_input = []
    for filename in inlist:
        more_input.extend(filename.split())
    all_input = []
    for filename in more_input:
        filename = iraf.osfn(filename)
        all_input.extend(glob.glob(filename))

    X1D.extractSpec(all_input,
                    outdir=outdir,
                    update_input=update_input,
                    location=location,
                    extrsize=extrsize,
                    find_target=find_targ,
                    verbosity=verbosity)


# Initialize IRAF Task definition now...
parfile = iraf.osfn(_parfile)
junk = iraf.IrafTaskFactory(taskname=_taskname,
                            value=parfile,
                            pkgname=PkgName,
                            pkgbinary=PkgBinary,
                            function=x1d_iraf)
iraf.x1dcorr.version = _version
Example #18
0
	parser = argparse.ArgumentParser(description='Time invariant algebra on light curve data')
	parser.add_argument('--shell', action='store_true', help='Are we running from the shell?')

	parser.add_argument('infile', help='Name of input file', type=str)
	parser.add_argument('outfile', help='Name of FITS file to output', type=str)

	parser.add_argument('--datacol', '-d', default='SAP_FLUX', dest='datacol', help='Name of the column containing the flux time series', type=str)
	parser.add_argument('--constantfunc', '-f', default='None', dest='constantfunc', help='A value calculated from a function to be used in operation', type=str,
		choices=['None','median','mean','MAD','std','max','range'])
	parser.add_argument('--constantval', '-v', default='None', dest='constantval', help='Use a given number in operation', type=str)
	parser.add_argument('--operation', '-o', default='add', dest='operation', help='Add, subtract, multiply, divide flux by a constant', type=str,
		choices=['add','','subtract','multiply','divide'])
	
	parser.add_argument('--clobber', action='store_true', help='Overwrite output file?')
	parser.add_argument('--verbose', action='store_true', help='Write to a log file?')
	parser.add_argument('--logfile', '-l', help='Name of ascii log file', default='kepcotrend.log', dest='logfile', type=str)
	parser.add_argument('--status', '-e', help='Exit status (0=good)', default=0, dest='status', type=int)


	args = parser.parse_args()
	
	kepaddconstant(args.infile,args.outfile,args.datacol,args.constantfunc,args.constantval,args.operation,args.clobber,args.verbose,args.logfile,args.status)
	

else:
	from pyraf import iraf
	parfile = iraf.osfn("kepler$keparith.par")
	t = iraf.IrafTaskFactory(taskname="keparith", value=parfile, function=kepaddconstant)
	
	
Example #19
0
        print dir, ' directory with data'
        outfile = outfile.strip()
        if os.path.isfile(outfile):
            print 'output file exists, appending'
#            saltsafeio.delete(outfile)

# check whether the calibrate logfile is defined

        saltsafeio.filedefined('Log', calibratelogfile)

        # Get current working directory as the Fortran code changes dir
        startdir = os.getcwd()

        # If all looks OK, run the FORTRAN code

        calibrate_wrapper.calibrate(plottype, infile, outfile,
                                    calibratelogfile)

        # go back to starting directory
        os.chdir(startdir)


# -----------------------------------------------------------
# main code

parfile = iraf.osfn("saltfp$saltfpcalibrate.par")
t = iraf.IrafTaskFactory(taskname="saltfpcalibrate",
                         value=parfile,
                         function=saltfpcalibrate,
                         pkgname='saltfp')
Example #20
0
        aw = ApplicationWindow(imlist=imlist,
                               number=ignorexp * ampperccd * nccds + 1,
                               config=outfile,
                               target_line_color=tgt_col,
                               comparison_line_color=cmp_col,
                               target_line_width=tgt_lw,
                               comparison_line_width=cmp_lw,
                               distance=recenter_radius,
                               cmap=cmap,
                               scale=scale,
                               contrast=contrast)
        aw.show()

        # Start application event loop
        exit = App.exec_()

        # Check if GUI was executed succesfully
        if exit != 0:
            log.warning('Slotpreview GUI has unexpected exit status' +
                        str(exit))


# -----------------------------------------------------------
# main code

parfile = iraf.osfn("slottools$slotpreview.par")
t = iraf.IrafTaskFactory(taskname="slotpreview",
                         value=parfile,
                         function=slotpreview,
                         pkgname='slottools')
Example #21
0
    header.update('SCIEXT', sci_ext, comment='Extension of science frame')
    return pyfits.ImageHDU(data=data, header=header, name='BPM')


def createvariance(inhdu, sci_ext, var_ext):
    """Create a variance hdu from an input hdu"""

    # create the variance array
    data = inhdu.data.copy()
    if (data <= 0).any():
        j = numpy.where(data > 0)
        min_pos = data[j].min()
        j = numpy.where(data <= 0)
        data[j] = min_pos
    data = data ** 0.5

    header = inhdu.header.copy()
    header['EXTVER'] = var_ext
    header.update('SCIEXT', sci_ext, comment='Extension of science frame')
    return pyfits.ImageHDU(data=data, header=header, name='VAR')

# -----------------------------------------------------------
# main code

parfile = iraf.osfn("saltspec$specprepare.par")
t = iraf.IrafTaskFactory(
    taskname="specprepare",
    value=parfile,
    function=specprepare,
    pkgname='saltspec')
Example #22
0
    saltsafekey.new('CRVAL2', float(ybin), 'WCS: Y reference coordinate value',
                    struct, outfile)
    saltsafekey.new('CDELT1', float(xbin), 'WCS: X pixel size', struct,
                    outfile)
    saltsafekey.new('CDELT2', float(ybin), 'WCS: Y pixel size', struct,
                    outfile)
    saltsafekey.new('CTYPE1', 'pixel', 'X type', struct, outfile)
    saltsafekey.new('CTYPE2', 'pixel', 'Y type', struct, outfile)

    return struct


def addhousekeeping(struct, outhdu, outfile):
    """housekeeping keywords"""

    saltsafekey.put('SAL-TLM', time.asctime(time.localtime()), struct, outfile)
    saltsafekey.new('EXTNAME', 'SCI', 'Extension name', struct, outfile)
    saltsafekey.new('EXTVER', outhdu, 'Extension number', struct, outfile)

    return struct


# -----------------------------------------------------------
# main code

parfile = iraf.osfn("slottools$slotmerge.par")
t = iraf.IrafTaskFactory(taskname="slotmerge",
                         value=parfile,
                         function=slotmerge,
                         pkgname='slottools')
Example #23
0
    kepmsg.clock(message,logfile,verbose)

# main
if '--shell' in sys.argv:
    import argparse
    
    parser = argparse.ArgumentParser(description='Append multiple month short cadence and/or multiple quarter long cadence data')
    parser.add_argument('--shell', action='store_true', help='Are we running from the shell?')
    parser.add_argument('infiles', help='List of input files', type=str)

    parser.add_argument('outfile', help='Name of FITS file to output', type=str)


    parser.add_argument('--clobber', action='store_true', help='Overwrite output file?')
    parser.add_argument('--verbose', action='store_true', help='Write to a log file?')
    parser.add_argument('--logfile', '-l', help='Name of ascii log file', default='kepcotrend.log', dest='logfile', type=str)
    parser.add_argument('--status', '-e', help='Exit status (0=good)', default=0, dest='status', type=int)


    args = parser.parse_args()
    
    

    kepstitch(args.infiles,args.outfile,args.clobber,args.verbose,args.logfile,args.status)
    

else:
    from pyraf import iraf
    parfile = iraf.osfn("kepler$kepstitch.par")
    t = iraf.IrafTaskFactory(taskname="kepstitch", value=parfile, function=kepstitch)
Example #24
0
        for i in range(ys):
            x = numpy.arange(xs)
            rdata = data[i, :]
            rmask = mask[i, :]
            rmask = nd.minimum_filter(rmask, size=3)
            if rmask.any() == True:
                rdata = numpy.interp(x, x[rmask], rdata[rmask])
                data[i, rmask == 0] = rdata[rmask == 0]

    return data


def tran_func(a, xshift, yshift, xmag, ymag, xrot, yrot):
    xtran = ymag * a[0] * cos(yrot * pi / 180.0) \
        - xmag * a[1] * sin(xrot * pi / 180) \
        - yshift
    ytran = ymag * a[0] * sin(yrot * pi / 180.0) \
        + xmag * a[1] * cos(xrot * pi / 180) \
        - xshift
    return xtran, ytran


# -----------------------------------------------------------
# main code
if not iraf.deftask('saltmosaic'):
    parfile = iraf.osfn("saltred$saltmosaic.par")
    t = iraf.IrafTaskFactory(taskname="saltmosaic",
                             value=parfile,
                             function=saltmosaic,
                             pkgname='saltred')
Example #25
0
def findwskeyword(keyword, sol):
    """Find and return a value for a keyword in the list of the wavelength solution"""
    i = sol.index(keyword)
    j = sol[i:].index('\n')
    return sol[i:i + j].split('=')[1].strip()


def enterdatetime(dstr):
    """Break up the datetime string to create a datetime object
       return datetime
    """
    dlist = dstr.split()
    year, month, day = dlist[0].split('-')
    hour, minute, second = dlist[1].split(':')

    return datetime.datetime(
        int(year), int(month), int(day), int(hour), int(minute), int(float(second)))


def subtracttime(d1, d2):
    """Return the difference in two dates in seconds"""
    dt = max(d1, d2) - min(d1, d2)
    return 86400 * dt.days + dt.seconds


# main code
if not iraf.deftask('specrectify'):
    parfile = iraf.osfn("saltspec$specrectify.par")
    t = iraf.IrafTaskFactory(taskname="specrectify", value=parfile, 
                             function=specrectify, pkgname='saltspec')
Example #26
0
    parser.add_argument('--verbose',
                        action='store_true',
                        help='Write to a log file?')
    parser.add_argument('--logfile',
                        '-l',
                        help='Name of ascii log file',
                        default='kepcotrend.log',
                        dest='logfile',
                        type=str)
    parser.add_argument('--status',
                        '-e',
                        help='Exit status (0=good)',
                        default=0,
                        dest='status',
                        type=int)

    args = parser.parse_args()

    cmdLine = True

    kepdiffim(args.infile, args.outfile, args.plotfile, args.imscale,
              args.cmap, args.filter, args.function, args.cutoff, args.clobber,
              args.verbose, args.logfile, args.status, cmdLine)

else:
    from pyraf import iraf
    parfile = iraf.osfn("kepler$kepdiffim.par")
    t = iraf.IrafTaskFactory(taskname="kepdiffim",
                             value=parfile,
                             function=kepdiffim)
Example #27
0
    #set binning
    binstr = saltstring.makebinstr(flatkeys[2])

    #set gain
    gnstr = saltstring.makegainstr(flatkeys[3])

    #set readout
    rostr = saltstring.makereadoutstr(flatkeys[4])

    fltstr = flatkeys[5].strip()

    if flatkeys[6].count('SKY'):
        skystr = 'Sky'
    else:
        skystr = ''

    flatname = '%s%s%sFlat%s%s%s%s%s.fits' % (instr, obsdate, skystr, mdstr,
                                              binstr, gnstr, rostr, fltstr)
    return flatname


# -----------------------------------------------------------
# main code

if not iraf.deftask('saltclean'):
    parfile = iraf.osfn("saltred$saltclean.par")
    t = iraf.IrafTaskFactory(taskname="saltclean",
                             value=parfile,
                             function=saltclean,
                             pkgname='saltred')
Example #28
0
    parser.add_argument('--verbose',
                        action='store_true',
                        help='Write to a log file?')
    parser.add_argument('--logfile',
                        '-l',
                        help='Name of ascii log file',
                        default='kepcotrend.log',
                        dest='logfile',
                        type=str)
    parser.add_argument('--status',
                        '-e',
                        help='Exit status (0=good)',
                        default=0,
                        dest='status',
                        type=int)

    args = parser.parse_args()

    cmdLine = True

    kepwindow(args.infile, args.outfile, args.fcol, args.fmax, args.nfreq,
              args.plot, args.clobber, args.verbose, args.logfile, args.status,
              cmdLine)

else:
    from pyraf import iraf
    parfile = iraf.osfn("kepler$kepwindow.par")
    t = iraf.IrafTaskFactory(taskname="kepwindow",
                             value=parfile,
                             function=kepwindow)
Example #29
0
    # create the columns and the
    for ap in ap_list:
        fvar = abs(ap.lvar)**0.5
        # create the columns
        col1 = pyfits.Column(name='wavelength',
                             format='D',
                             unit='Angstroms',
                             array=ap.wave)
        col2 = pyfits.Column(name='counts',
                             format='D',
                             unit='Counts',
                             array=ap.ldata)
        col3 = pyfits.Column(name='counts_err', format='D', array=fvar)

        # add to the table
        tbhdu = pyfits.new_table([col1, col2, col3])
        hdulist.append(tbhdu)

    # write it out
    hdulist.writeto(ofile)
    return


# main code

parfile = iraf.osfn("saltspec$specextract.par")
t = iraf.IrafTaskFactory(taskname="specextract",
                         value=parfile,
                         function=specextract,
                         pkgname='saltspec')
Example #30
0
                   psize=_fpars['psize'],
                   orient=_fpars['orient'],
                   ra=_fpars['ra'],
                   dec=_fpars['dec'])

    drobj = xydrizzle.PyDrizzle(input,
                                output=output,
                                field=_field,
                                kernel=kernel,
                                units=units,
                                pixfrac=pixfrac,
                                bits=bits,
                                idckey=idckey,
                                clean=clean)
    drobj.run(save=save, build=build)


# 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='xydrizzle',
                           value=parfile,
                           pkgname=PkgName,
                           pkgbinary=PkgBinary,
                           function=pydriz_iraf)