• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python saltsafeio.listparse函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中saltsafeio.listparse函数的典型用法代码示例。如果您正苦于以下问题:Python listparse函数的具体用法?Python listparse怎么用?Python listparse使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了listparse函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: saltillum

def saltillum(images, outimages, outpref, mbox=11, clobber=False, logfile="salt.log", verbose=True):

    with logging(logfile, debug) as log:

        # Check the input images
        infiles = saltio.argunpack("Input", images)

        # create list of output files
        outfiles = saltio.listparse("Outfile", outimages, outpref, infiles, "")

        # verify that the input and output lists are the same length
        saltio.comparelists(infiles, outfiles, "Input", "output")

        # open each raw image file
        for infile, outfile in zip(infiles, outfiles):
            struct = saltio.openfits(infile)

            struct = illum_cor(struct, mbox)

            # add any header keywords like history
            fname, hist = history(level=1, wrap=False)
            saltkey.housekeeping(struct[0], "SILLUM", "File Illumination corrected", hist)

            # write it out and close it
            saltio.writefits(struct, outfile, clobber=clobber)
            saltio.closefits(struct)

            # output the information
            log.message("Illumination corrected image %s " % (infile), with_header=False, with_stdout=verbose)
开发者ID:saltastro,项目名称:pysalt,代码行数:29,代码来源:saltillum.py


示例2: hrsprepare

def hrsprepare(images, outimages, outpref, clobber=True, logfile='salt.log',verbose=True):
    """Convert .fit files to .fits files and place HRS data into 
       standard SALT FITS format

    """
 
    with logging(logfile,debug) as log:

       # Check the input images 
       infiles = saltio.argunpack ('Input',images)

       # create list of output files 
       outfiles=saltio.listparse('Outfile', outimages, outpref,infiles,'')

       #verify that the input and output lists are the same length
       saltio.comparelists(infiles,outfiles,'Input','output')

       #open the file and write out as a fits files in the output directory
       for img,oimg in zip(infiles, outfiles):
          hdu=saltio.openfits(img)
          hdu=prepare(hdu)
          log.message('Preparing HRS %s to %s' % (img, oimg), with_header=False)
          saltio.writefits(hdu, oimg, clobber=clobber)
    
 
    return 
开发者ID:apodemus,项目名称:pysalt3,代码行数:26,代码来源:hrsprepare.py


示例3: hrsstack

def hrsstack(images, outimages, outpref, clobber=True, logfile='salt.log',verbose=True):
    """Convert MEF HRS data into a single image.  If variance frames and BPMs, then 
       convert them to the same format as well.   Returns an MEF image but that is
       combined into a single frame

    """
 
    with logging(logfile,debug) as log:

       # Check the input images 
       infiles = saltio.argunpack ('Input',images)

       # create list of output files 
       outfiles=saltio.listparse('Outfile', outimages, outpref,infiles,'')

       #verify that the input and output lists are the same length
       saltio.comparelists(infiles,outfiles,'Input','output')

       #open the file and write out as a fits files in the output directory
       for img,oimg in zip(infiles, outfiles):
          hdu=saltio.openfits(img)
          hdu=stack(hdu)
          log.message('Stacking HRS %s to %s' % (img, oimg), with_header=False)
          saltio.writefits(hdu, oimg, clobber=clobber)
    
 
    return 
开发者ID:saltastro,项目名称:pysalt,代码行数:27,代码来源:hrsstack.py


示例4: saltsurface

def saltsurface(images,outimages,outpref, mask=True,  order=3, minlevel=0,
             clobber=False, logfile='salt.log',verbose=True):


   with logging(logfile,debug) as log:

       # Check the input images 
       infiles = saltio.argunpack ('Input',images)

       # create list of output files 
       outfiles=saltio.listparse('Outfile', outimages, outpref,infiles,'')

       #verify that the input and output lists are the same length
       saltio.comparelists(infiles,outfiles,'Input','output')

       # open each raw image file
       for infile, outfile in zip(infiles,outfiles):
           struct = saltio.openfits(infile)

           
           struct = surface_fit(struct, order=order, mask=mask, minlevel=minlevel)

           #add any header keywords like history 
           fname, hist=history(level=1, wrap=False)
           saltkey.housekeeping(struct[0],'SURFIT', 'File fit by a surface', hist)

           #write it out and close it
           saltio.writefits(struct,outfile,clobber=clobber)
           saltio.closefits(struct)

           #output the information
           log.message('Surface fitted image %s ' % (infile), with_header=False, with_stdout=verbose)
开发者ID:astrophysaxist,项目名称:pysalt,代码行数:32,代码来源:saltsurface.py


示例5: specsky

def specsky(images,outimages,outpref, method='normal', section=None, 
            function='polynomial', order=2, 
            clobber=True,logfile='salt.log',verbose=True):

   with logging(logfile,debug) as log:

       # Check the input images 
       infiles = saltio.argunpack ('Input',images)

       # create list of output files 
       outfiles=saltio.listparse('Outfile', outimages, outpref,infiles,'')

       if method not in ['normal', 'fit']: 
           msg='%s mode is not supported yet' % method
           raise SALTSpecError(msg)

       if section is None:
           section=saltio.getSection(section)
           msg='This mode is not supported yet'
           raise SALTSpecError(msg)
       else:
           section=saltio.getSection(section)

       # Identify the lines in each file
       for img, ofile in zip(infiles, outfiles):
          log.message('Subtracting sky spectrum in image %s into %s' % (img, ofile))
          #open the images
          hdu=saltio.openfits(img)

          #sky subtract the array
          hdu=skysubtract(hdu, method=method, section=section, funct=function, order=order) 

          #write out the image
          if clobber and os.path.isfile(ofile): saltio.delete(ofile)
          hdu.writeto(ofile)
开发者ID:dr-jpk,项目名称:pysalt,代码行数:35,代码来源:specsky.py


示例6: specselfid

def specselfid(images, outimages, outpref, refimage=None, ystart='middlerow',
               rstep=3, clobber=False, logfile='salt.log', verbose=True):

    with logging(logfile, debug) as log:

        # set up the variables
        infiles = []
        outfiles = []

        # Check the input images
        infiles = saltio.argunpack('Input', images)

        # create list of output files
        outfiles = saltio.listparse(
            'Outimages',
            outimages,
            outpref,
            infiles,
            '')

        # set up defaults
        if saltio.checkfornone(refimage) is not None:
            rhdu = saltio.openfits(refimage)
        else:
            refimage = None

        # read in rectify each image
        for img, oimg, in zip(infiles, outfiles):
            hdu = saltio.openfits(img)
            log.message(
                'Performing self-identification and rectification on %s' %
                img)
            for i in range(1, len(hdu)):
                if hdu[i].name == 'SCI':
                    if refimage is None:
                        sdata = hdu[i].data
                    else:
                        sdata = rhdu[i].data
                    hdu[i].data = selfid(
                        hdu[i].data,
                        sdata,
                        ystart=ystart,
                        rstep=rstep)
                    if saltkey.found('VAREXT', hdu[i]):
                        varext = saltkey.get('VAREXT', hdu[i])
                        hdu[varext].data = selfid(
                            hdu[varext].data,
                            sdata,
                            ystart=ystart,
                            rstep=rstep)
                    if saltkey.found('BPMEXT', hdu[i]):
                        bpmext = saltkey.get('BPMEXT', hdu[i])
                        hdu[bpmext].data = selfid(
                            hdu[bpmext].data,
                            sdata,
                            ystart=ystart,
                            rstep=rstep)

            # write out the oimg
            saltio.writefits(hdu, oimg, clobber=clobber)
开发者ID:apodemus,项目名称:pysalt3,代码行数:60,代码来源:specselfid.py


示例7: saltprepare

def saltprepare(images,outimages,outpref,createvar=False, badpixelimage=None, clobber=True,logfile='salt.log',verbose=True):

   with logging(logfile,debug) as log:

       # Check the input images 
       infiles = saltio.argunpack ('Input',images)

       # create list of output files 
       outfiles=saltio.listparse('Outfile', outimages, outpref,infiles,'')

       #verify that the input and output lists are the same length
       saltio.comparelists(infiles,outfiles,'Input','output')

       # open the badpixel image
       if saltio.checkfornone(badpixelimage) is None:
          badpixelstruct=None
       else:
           try:
               badpixelstruct = saltio.openfits(badpixelimage)
           except saltio.SaltIOError,e:
               msg='badpixel image must be specificied\n %s' % e
               raise SaltError(msg)

       # open each raw image file
       for img, oimg, in zip(infiles, outfiles):

           #open the fits file
           struct=saltio.openfits(img)

           #if createvar, throw a warning if it is using slotmode
           if saltkey.fastmode(saltkey.get('DETMODE', struct[0])) and createvar:
               msg='Creating variance frames for slotmode data in %s' % img
               log.warning(msg)
  
           # identify instrument
           instrume,keyprep,keygain,keybias,keyxtalk,keyslot = saltkey.instrumid(struct)

           # has file been prepared already?
           try:
               key = struct[0].header[keyprep]
               message = 'ERROR -- SALTPREPARE: File ' + infile
               message += ' has already been prepared'
               raise SaltError(message)
           except:
               pass


           # prepare file
           struct=prepare(struct,createvar=createvar, badpixelstruct=badpixelstruct)

           # housekeeping keywords
           fname, hist=history(level=1, wrap=False, exclude=['images', 'outimages', 'outpref'])
           saltkey.housekeeping(struct[0],keyprep, 'File prepared for IRAF', hist)

           # write FITS file
           saltio.writefits(struct,oimg, clobber=clobber)
           saltio.closefits(struct)

           message = 'SALTPREPARE -- %s => %s' % (img, oimg)
           log.message(message, with_header=False)
开发者ID:cmccully,项目名称:pysalt,代码行数:60,代码来源:saltprepare.py


示例8: saltfpskyring

def saltfpskyring(
    images,
    outimages,
    outpref,
    axc,
    ayc,
    arad,
    rxc,
    ryc,
    pmin,
    pmax,
    swindow=5,
    clobber=False,
    logfile="salt.log",
    verbose=True,
):
    """Sky subtracts Fabry-Perot images"""

    # start log now that all parameter are set up

    with logging(logfile, debug) as log:

        # Check the input images
        infiles = saltio.argunpack("Input", images)

        # create list of output files
        outfiles = saltio.listparse("Outfile", outimages, outpref, infiles, "")

        # verify that the input and output lists are the same length
        saltio.comparelists(infiles, outfiles, "Input", "output")

        for img, oimg in zip(infiles, outfiles):

            # open up the file
            hdu = saltio.openfits(img)

            # determine the azimuthally averaged profile
            rpro, radial_profile = median_radial_profile(
                hdu[0].data, xc=axc, yc=ayc, rmax=arad, nbins=100, pmin=pmin, pmax=pmax
            )

            if swindow > 1:
                radial_profile = np.convolve(radial_profile, np.ones(swindow), mode="same") / swindow

            # calculate the indices from the image
            y, x = np.indices(hdu[0].data.shape)
            radius = np.hypot(x - axc, y - ayc)

            # subtract off the sky data
            mdata = hdu[0].data - np.interp(radius, rpro, radial_profile)
            hdu[0].data = mdata

            # write FITS file
            saltio.writefits(hdu, oimg, clobber=clobber)
            saltio.closefits(hdu)

            message = "SALTFPSKYRING -- Subtracted sky from  %s" % (img)
            log.message(message, with_header=False)
开发者ID:saltastro,项目名称:pysalt,代码行数:58,代码来源:saltfpskyring.py


示例9: saltxtalk

def saltxtalk(images,outimages,outpref,xtalkfile=None, usedb=False,
              clobber=True, logfile='salt.log',verbose=True):

   #start logging
   with logging(logfile,debug) as log:

       # Check the input images 
       infiles = saltio.argunpack ('Input',images)

       # create list of output files 
       outfiles=saltio.listparse('Outfile', outimages, outpref,infiles,'')

       # are input and output lists the same length?
       saltio.comparelists(infiles,outfiles,'Input','output')

       # does crosstalk coefficient data exist
       if usedb:
           xtalkfile = xtalkfile.strip()
           xdict = saltio.readxtalkcoeff(xtalkfile)
       else:
           xdict=None

       for img, oimg in zip(infiles, outfiles):

           #open the fits file
           struct=saltio.openfits(img)

           #find the best xcoeff for the image if using the db
           if usedb:
              obsdate=saltkey.get('DATE-OBS', struct[0])
              obsdate=int('%s%s%s' % (obsdate[0:4],obsdate[5:7], obsdate[8:]))
              xkey=np.array(xdict.keys())
              date=xkey[abs(xkey-obsdate).argmin()]
              xcoeff=xdict[date]
           else:
              xcoeff=[]

           # identify instrument
           instrume,keyprep,keygain,keybias,keyxtalk,keyslot = saltkey.instrumid(struct)

           # has file been prepared already?
           if saltkey.found(keyxtalk, struct[0]):
               message='%s has already been xtalk corrected' % img
               raise SaltError(message)


           #apply the cross-talk correction
           struct = xtalk(struct, xcoeff, log=log, verbose=verbose)

           # housekeeping keywords
           fname, hist=history(level=1, wrap=False, exclude=['images', 'outimages', 'outpref'])
           saltkey.housekeeping(struct[0], 'SXTALK', 'Images have been xtalk corrected', hist)

           # write FITS file
           saltio.writefits(struct,oimg, clobber=clobber)
           saltio.closefits(struct)
开发者ID:astrophysaxist,项目名称:pysalt,代码行数:56,代码来源:saltxtalk.py


示例10: saltcrclean

def saltcrclean(images,outimages,outpref,crtype='fast',thresh=5,mbox=3,         \
                bthresh=3, flux_ratio=0.2, bbox=11, gain=1, rdnoise=5, fthresh=5,\
                bfactor=2, gbox=3, maxiter=5, multithread=False, update=True,
                clobber=True,  logfile='salt.log', verbose=True):


   with logging(logfile,debug) as log:


       # Check the input images 
       infiles = saltio.argunpack ('Input',images)

       # create list of output files 
       outfiles=saltio.listparse('Outfile', outimages, outpref,infiles,'')

       #verify that the input and output lists are the same length
       saltio.comparelists(infiles,outfiles,'Input','output')

       #check to see if multithreading is available
       if mp:
          pass
       else:
          multithread=False
          log.warning('multiprocessing module is not available.  Setting multiththread=False')


       # Begin processes each file
       for infile,outfile in zip(infiles,outfiles):

           #open the infile
           struct=saltio.openfits(infile)

           #clean the cosmic rays
           if multithread and len(struct)>1:
               struct=multicrclean(struct, crtype, thresh, mbox, bbox, bthresh, flux_ratio, \
                          gain, rdnoise, bfactor, fthresh, gbox, maxiter, log, verbose=verbose)
           else:
               struct=crclean(struct, crtype, thresh, mbox, bbox, bthresh, flux_ratio, \
                          gain, rdnoise, bfactor, fthresh, gbox, maxiter, update, log, verbose=verbose)
          
           #log the call
           #log.message('Cleaned %i cosmic rays from %s using %s method' % (totcr, infile, crtype), with_header=False)
           log.message('', with_header=False, with_stdout=verbose)

           #add house keeping keywords
           saltkey.put('SAL-TLM',time.asctime(time.localtime()), struct[0])
   
           #add the history keyword
           fname, hist=history(level=1, wrap=False)
           saltkey.history(struct[0],hist)

           #write out the file
           saltio.writefits(struct, outfile, clobber=clobber)

           #close the image
           saltio.closefits(struct)
开发者ID:astrophysaxist,项目名称:pysalt,代码行数:56,代码来源:saltcrclean.py


示例11: specwavemap

def specwavemap(
    images,
    outimages,
    outpref,
    solfile=None,
    caltype="line",
    function="polynomial",
    order=3,
    blank=0,
    nearest=False,
    clobber=True,
    logfile="salt.log",
    verbose=True,
):

    with logging(logfile, debug) as log:

        # set up the variables
        infiles = []
        outfiles = []

        # Check the input images
        infiles = saltsafeio.argunpack("Input", images)

        # create list of output files
        outfiles = saltsafeio.listparse("Outimages", outimages, outpref, infiles, "")

        # read in the wavelength solutions and enter them into
        # there own format
        if caltype == "line":
            soldict = sr.entersolution(solfile)
        else:
            soldict = None

        # read in rectify each image
        for img, oimg in zip(infiles, outfiles):
            if caltype == "line":
                msg = "Creating wave map image %s from image %s using files %s" % (oimg, img, solfile)
            else:
                msg = "Creating wave map image %s from image %s using RSS Model" % (oimg, img)
            log.message(msg)
            hdu = saltsafeio.openfits(img)
            hdu = wavemap(
                hdu,
                soldict,
                caltype=caltype,
                function=function,
                order=order,
                blank=blank,
                nearest=nearest,
                clobber=clobber,
                log=log,
                verbose=verbose,
            )
            saltsafeio.writefits(hdu, oimg, clobber=clobber)
开发者ID:saltastro,项目名称:pysalt,代码行数:55,代码来源:specwavemap.py


示例12: slotpreview

def slotpreview(images,outfile,ampperccd=2,ignorexp=6,recenter_radius=5,
                tgt_col='b',cmp_col='g', tgt_lw=2,cmp_lw=2,cmap='gray',
                scale='zscale',contrast=0.1,clobber=True,logfile='salt.log',
                verbose=True):

    with logging(logfile,debug) as log:
        
        # is the input file specified?
        saltsafeio.filedefined('Input',images)

        # if the input file is a list, does it exist?
        if images[0] == '@':
            saltsafeio.listexists('Input',images)

        # parse list of input files
        imlist=saltsafeio.listparse('Raw image',images,'','','')

        # check input files exist
        saltsafeio.filesexist(imlist,'','r')

        # is the output file specified?
        saltsafeio.filedefined('Output',outfile)

        # check output file does not exist, optionally remove it if it does exist
        if os.path.exists(outfile) and clobber:
            os.remove(outfile)
        elif os.path.exists(outfile) and not clobber:
            raise SaltIOError('File '+outfile+' already exists, use clobber=y')

        # Get the number of ccds to calculate the number of frames to skip
        try:
            nccds=pyfits.getheader(imlist[0])['NCCDS']
        except:
            raise SaltIOError('Could not read NCCDS parameter from header of first fits file.')

        # Create GUI
        App = QtGui.QApplication(sys.argv)
        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))
开发者ID:astrophysaxist,项目名称:pysalt,代码行数:51,代码来源:slotpreview.py


示例13: saltarith

def saltarith(operand1, op, operand2, result, outpref, divzero=0, clobber=False,     \
             logfile='salt.log',verbose=True):


   with logging(logfile,debug) as log:

       # Check the input images 
       infiles = saltio.argunpack ('Input',operand1)

       # create list of output files 
       outfiles=saltio.listparse('Outfile', result, outpref, infiles,'')

       #verify that the input and output lists are the same length
       saltio.comparelists(infiles,outfiles,'Input','output')

       #let's keep track of whether operand2 is an image or not
       is_image = False

       #load in operand2, or, if it's not an image, assume it's a number
       try: operand2struct = float(operand2)
       except ValueError:
          operand2struct = saltio.openfits(operand2)
          is_image = True

       #open the input image files
       for infile, outfile in zip(infiles,outfiles):
           struct = saltio.openfits(infile)

           #do some math!
           outstruct = arith(struct, op, operand2struct, is_image, divzero)
           try:
               pass 
           except Exception as e:
               msg='Unable to do math %s because %s' % (infile, e)
               raise SaltError(msg)

           #update header stuff
           fname, hist = history(level=1, wrap=False)
           saltkey.housekeeping(struct[0],'SARITH', 'Some arithmatic was performed',hist)

           #write it. close it.
           saltio.writefits(outstruct,outfile,clobber=clobber)
           saltio.closefits(struct)

           #output the information
           log.message('imarith: %s %s %s %s' % (infile, op, operand2, outfile), with_header=False, with_stdout=verbose)

       #close the operand2 image
       if is_image: saltio.closefits(operand2struct)
开发者ID:apodemus,项目名称:pysalt3,代码行数:49,代码来源:saltarith.py


示例14: saltmosaic

def saltmosaic(images,outimages,outpref,geomfile,interp='linear',geotran=True, cleanup=True,clobber=False,logfile=None,verbose=True):

   #Start the logging
   with logging(logfile,debug) as log:

       # Check the input images 
       infiles = saltio.argunpack ('Input',images)

       # create list of output files 
       outfiles=saltio.listparse('Outfile', outimages, outpref,infiles,'')

       #verify that the input and output lists are the same length
       saltio.comparelists(infiles,outfiles,'Input','output')



       # does CCD geometry definition file exist
       geomfilefile = geomfile.strip()
       saltio.fileexists(geomfile)

       gap = 0
       xshift = [0, 0]
       yshift = [0, 0]
       rotation = [0, 0]
       gap, xshift, yshift, rotation=saltio.readccdgeom(geomfile)

       # open each raw image file and apply the transformation to it
       for img, oimg in zip(infiles, outfiles):

           #open the structure
           struct = saltio.openfits(img)

           #create the mosaic
           ostruct=make_mosaic(struct, gap, xshift, yshift, rotation, interp_type=interp, geotran=geotran, cleanup=cleanup, log=log, verbose=verbose)

           #update the header information
           # housekeeping keywords
           fname, hist=history(level=1, wrap=False, exclude=['images', 'outimages', 'outpref'])
           saltkey.housekeeping(ostruct[0], 'SMOSAIC', 'Images have been mosaicked ', hist)

           #write the image out
           saltio.writefits(ostruct,oimg, clobber=clobber)
 
           #close the files
           saltio.closefits(struct)
           saltio.closefits(ostruct)
开发者ID:dr-jpk,项目名称:pysalt,代码行数:46,代码来源:saltmosaic.py


示例15: saltgain

def saltgain(images,outimages, outpref, gaindb=None,usedb=False, mult=True,
             clobber=True, logfile='salt.log',verbose=True):

   #start logging
   with logging(logfile,debug) as log:

       # Check the input images 
       infiles = saltio.argunpack ('Input',images)

       # create list of output files 
       outfiles=saltio.listparse('Outfile', outimages, outpref,infiles,'')

       #verify that the input and output lists are the same length
       saltio.comparelists(infiles,outfiles,'Input','output')

       # read in the database file if usedb is true
       if usedb:
           gaindb = gaindb.strip()
           dblist= saltio.readgaindb(gaindb)
       else:
           dblist=[]


       for img, oimg in zip(infiles, outfiles):
           #open the fits file
           struct=saltio.openfits(img)

           # identify instrument
           instrume,keyprep,keygain,keybias,keyxtalk,keyslot = saltkey.instrumid(struct)

           # has file been prepared already?
           if saltkey.found(keygain, struct[0]):
               message='SALTGAIN: %s has already been gain-corrected' % img
               raise SaltError(message)


           # gain correct the data
           struct = gain(struct,mult=mult, usedb=usedb, dblist=dblist, log=log, verbose=verbose)

           # housekeeping keywords
           fname, hist=history(level=1, wrap=False, exclude=['images', 'outimages', 'outpref'])
           saltkey.housekeeping(struct[0],keygain, 'Images have been gain corrected', hist)

           # write FITS file
           saltio.writefits(struct,oimg, clobber=clobber)
           saltio.closefits(struct)
开发者ID:apodemus,项目名称:pysalt3,代码行数:46,代码来源:saltgain.py


示例16: saltslot

def saltslot(images,outimages,outpref,gaindb='',xtalkfile='',usedb=False, clobber=False,logfile='salt.log',verbose=True):


   #start logging
   with logging(logfile,debug) as log:

       # Check the input images 
       infiles = saltio.argunpack ('Input',images)

       # create list of output files 
       outfiles=saltio.listparse('Outfile', outimages, outpref,infiles,'')

       # are input and output lists the same length?
       saltio.comparelists(infiles,outfiles,'Input','output')

       # does crosstalk coefficient data exist
       if usedb:
           dblist= saltio.readgaindb(gaindb)
           xtalkfile = xtalkfile.strip()
           xdict = saltio.readxtalkcoeff(xtalkfile)
       else:
           dblist=[]
           xdict=None

       for img, oimg in zip(infiles, outfiles):
           #open the fits file
           struct=saltio.openfits(img)

           # identify instrument
           instrume,keyprep,keygain,keybias,keyxtalk,keyslot = saltkey.instrumid(struct)

           # has file been prepared already?
           if saltkey.found(keygain, struct[0]):
               message='%s has already been reduced' % img
               raise SaltError(message)



           # housekeeping keywords
           fname, hist=history(level=1, wrap=False, exclude=['images', 'outimages', 'outpref'])
           saltkey.housekeeping(struct[0],keyslot, 'Images have been slotmode reduced', hist)

           # write FITS file
           saltio.writefits(struct,oimg, clobber=clobber)
           saltio.closefits(struct)
开发者ID:dr-jpk,项目名称:pysalt,代码行数:45,代码来源:saltslot.py


示例17: specrectify

def specrectify(images, outimages, outpref, solfile=None, caltype='line',
                function='polynomial', order=3, inttype='linear', w1=None,
                w2=None, dw=None, nw=None, blank=0, conserve=False, nearest=False,
                clobber=True, logfile='salt.log', verbose=True):

    with logging(logfile, debug) as log:

        # set up the variables
        infiles = []
        outfiles = []

        # Check the input images
        infiles = saltsafeio.argunpack('Input', images)

        # create list of output files
        outfiles = saltsafeio.listparse(
            'Outimages',
            outimages,
            outpref,
            infiles,
            '')

        # read in the wavelength solutions and enter them into
        # there own format
        if caltype == 'line':
            soldict = entersolution(solfile)
        else:
            soldict = None

        # read in rectify each image
        for img, oimg, in zip(infiles, outfiles):
            if caltype == 'line':
                msg = 'Creating rectified image %s from image %s using files %s' % (
                    oimg, img, solfile)
            else:
                msg = 'Creating rectified image %s from image %s using RSS Model' % (
                    oimg, img)
            log.message(msg)
            hdu = saltsafeio.openfits(img)
            hdu = rectify(hdu, soldict, caltype=caltype, function=function,
                          order=order, inttype=inttype, w1=w1, w2=w2, dw=dw, nw=nw,
                          pixscale=0.0, blank=blank, conserve=conserve, nearest=nearest,
                          clobber=clobber, log=log, verbose=verbose)
            # write out the oimg
            saltsafeio.writefits(hdu, oimg, clobber=clobber)
开发者ID:astrophysaxist,项目名称:pysalt,代码行数:45,代码来源:specrectify.py


示例18: slotreadtimefix

def slotreadtimefix(images,outimages, outpref, 
                    clobber=False, logfile='slot.log',verbose=True):
    
    with logging(logfile,debug) as log:

       # Check the input images 
       infiles = saltio.argunpack ('Input',images)

       # create list of output files 
       outfiles=saltio.listparse('Outfile', outimages, outpref,infiles,'')

       #verify that the input and output lists are the same length
       saltio.comparelists(infiles,outfiles,'Input','output')

       for img, oimg in zip(infiles, outfiles):
           #check to see if the out image already exists
           if not clobber and os.path.isfile(oimg):
              raise SaltIOError('%s alraedy exists' % oimg)

           #open the file
           struct=saltio.openfits(img)

           #log the message
           log.message('Updateing times in %s' % img, with_header=False, with_stdout=verbose)

           #now for each science frame, corrent the readtime
           #Assumes SALT format and that the first extension 
           #is empty
           for i in range(1,len(struct)):
              try:
                  struct[i]=readtimefix(struct[i])
              except SaltIOError,e :
                  raise SaltError('%s %s' % (img,e))

           #Add history keywords
           # housekeeping keywords
           fname, hist=history(level=1, wrap=False, exclude=['images', 'outimages', 'outpref'])
           saltkey.housekeeping(struct[0],"SLOTREAD", 'READTIME added', hist)


           #write to the output
           saltio.writefits(struct, oimg, clobber)

       return
开发者ID:astrophysaxist,项目名称:pysalt,代码行数:44,代码来源:slotreadtimefix.py


示例19: saltfpmask

def saltfpmask(images, outimages, outpref, axc,ayc, arad, maskmethod='c', maskvalue=0, \
               radi=None,rado=None,clobber=False, logfile='saltfp.log', verbose=True):  
    """Aperture masks Fabry-Perot images"""

    with logging(logfile, debug) as log:
       # Check the input images 
       infiles = saltio.argunpack ('Input',images)

       # create list of output files 
       outfiles=saltio.listparse('Outfile', outimages, outpref,infiles,'')

       #verify that the input and output lists are the same length
       saltio.comparelists(infiles,outfiles,'Input','output')

       for img, oimg in zip(infiles, outfiles):
           #open the image
           hdu=saltio.openfits(img)

           #test that the data are in the first 
           try:
               data=hdu[0].data
           except Exception, e:
               message='SALTFPMASK--ERROR:  Could not access data in Primary exention of %s because %s' % (img, e)
               log.message(message)
          

           #determine the mask value if it is a region
           if maskmethod=='region': 
               maskvalue=calc_maskvalue(data, axc, ayc, radi, rado)

           #mask the image
           message="SALTFPMASK--Masking image %s with a value of %s" % (img, maskvalue)
           log.message(message, with_header=False)
           hdu[0].data= maskimage(data, axc, ayc, arad, maskvalue)
           try:
               pass
           except Exception, e:
               message='SALTFPMASK--ERROR:  Could not create mask for %s because %s' % (img, e)
               log.message(message)

           #write out the image
           saltio.writefits(hdu, oimg, clobber=clobber)
开发者ID:astrophysaxist,项目名称:pysalt,代码行数:42,代码来源:saltfpmask.py


示例20: specprepare

def specprepare(images,outimages,outpref,badpixelimage='', \
                clobber=True,logfile='salt.log',verbose=True):

   with logging(logfile,debug) as log:


       # Check the input images 
       infiles = saltio.argunpack ('Input',images)

       # create list of output files 
       outfiles=saltio.listparse('Outfile', outimages, outpref,infiles,'')

       #verify that the input and output lists are the same length
       saltio.comparelists(infiles,outfiles,'Input','output')

       # open the badpixel image
       if saltio.checkfornone(badpixelimage) is None:
          badpixelstruct=None
       else:
           try:
               badpixelstruct = saltio.openfits(badpixelimage)
           except saltio.SaltIOError,e:
               msg='badpixel image must be specificied\n %s' % e
               raise SALTSpecError(msg)

       # open each raw image file

       for img, oimg, in zip(infiles, outfiles):

          #open the fits file
	  struct=saltio.openfits(img)

          # prepare file
	  struct=prepare(struct,badpixelstruct)

          # write FITS file
          saltio.writefits(struct,oimg, clobber=clobber)
          saltio.closefits(struct)

	  message = 'SPECPREPARE -- %s => %s' % (img, oimg)
          log.message(message)
开发者ID:dr-jpk,项目名称:pysalt,代码行数:41,代码来源:specprepare.py



注:本文中的saltsafeio.listparse函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python saltsafeio.openfits函数代码示例发布时间:2022-05-27
下一篇:
Python saltsafeio.argunpack函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap