コード例 #1
0
ファイル: specwavemap.py プロジェクト: saltastro/pysalt
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)
コード例 #2
0
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)
コード例 #3
0
def quickspec(profile, lampid=None, solfile=None, findobj=False, objsection=None, skysection=None, clobber=False, logfile='saltclean.log', verbose=True):
   """From mosaicked data, produce wavelength calibrated files"""
   profile = os.path.basename(profile)

   #fill in the mosaic 
   #fillgaps(profile)

   #specrectify
   caltype='rss'
   if solfile:
      soldict = entersolution(solfile)
      hdu = fits.open(profile)
      instrume = hdu[0].header['INSTRUME']
      grating = hdu[0].header['GRATING']
      grang = hdu[0].header['GRTILT']
      arang = hdu[0].header['CAMANG']
      filtername = hdu[0].header['FILTER']
      slitid=None
      for sol in soldict:
         if matchobservations( soldict[sol], instrume, grating, grang, arang, filtername, slitid):
            caltype='line'
            break
         

   specrectify(profile, outimages='', outpref='s', solfile=solfile, caltype=caltype,
                   function='legendre',  order=3, inttype='interp', w1=None, w2=None, dw=None, nw=None,
                   blank=0.0, clobber=True, logfile=logfile, verbose=True)

   y1,y2=quickap('s' + profile, lampid, findobj, objsection, skysection, clobber, logfile, verbose)

   if skysection is None:
      ylen=100
      skysection='[%i:%i]' % (y2+0.1*ylen,y2+0.2*ylen)
   
   specsky('s'+profile, outimages='s'+profile, outpref='', method='normal', section=skysection, function='polynomial', order=3, clobber=clobber, logfile=logfile, verbose=verbose)

   return y1,y2