コード例 #1
0
ファイル: InterIdentify.py プロジェクト: dr-jpk/pysalt
 def testfeatures(self):
     """Run the test matching algorithm"""
     self.set_wdiff()
     xp,wp=st.crosslinematch(self.xarr, self.farr, self.slines, self.sfluxes,
                            self.ws, mdiff=self.mdiff, wdiff=20, sigma=self.sigma, niter=self.niter)
     for x, w in zip(xp, wp):
        if w not in self.wp and w>-1: 
           self.xp.append(x)
           self.wp.append(w)
     self.plotFeatures()
     self.redraw_canvas()
コード例 #2
0
ファイル: InterIdentify.py プロジェクト: dr-jpk/pysalt
   def findfeatures(self):
       """Given a set of features, find other features that might 
          correspond to those features
       """
       self.set_wdiff()

       #xp, wp=st.findfeatures(self.xarr, self.farr, self.slines, self.sfluxes,
       #                       self.ws, mdiff=self.mdiff, wdiff=self.wdiff, sigma=self.sigma, niter=self.niter, sections=3)
       xp,wp=st.crosslinematch(self.xarr, self.farr, self.slines, self.sfluxes,
                              self.ws, mdiff=self.mdiff, wdiff=20, sigma=self.sigma, niter=self.niter)
       for x, w in zip(xp, wp):
          if w not in self.wp and w>-1: 
             self.xp.append(x)
             self.wp.append(w)
       self.plotFeatures()
       self.redraw_canvas()
コード例 #3
0
ファイル: InterIdentify.py プロジェクト: saltastro/pysalt
    def findfeatures(self):
        """Given a set of features, find other features that might
           correspond to those features
        """
        #self.set_wdiff()

        # xp, wp=st.findfeatures(self.xarr, self.farr, self.slines, self.sfluxes,
        # self.ws, mdiff=self.mdiff, wdiff=self.wdiff, sigma=self.sigma,
        # niter=self.niter, sections=3)
        xp, wp = st.crosslinematch(self.xarr, self.farr, self.slines, self.sfluxes, self.ws,
                                   res=max(self.sigma*self.res, 3), mdiff=self.mdiff, wdiff=10,
                                   sections=self.sections, sigma=self.sigma, niter=self.niter)
        for x, w in zip(xp, wp):
            if w not in self.wp and w > -1:
                self.xp.append(x)
                self.wp.append(w)
        # for i in range(len(self.xp)): print self.xp[i], self.wp[i]
        # print
        self.plotFeatures()
        self.redraw_canvas()
コード例 #4
0
ファイル: autoarclens.py プロジェクト: crawfordsm/zSALT
def auto_arc_lens(arc_image, dbfile='wav.db', ndstep=20, logfile='salt.log'):
    """Automatically process an arc image for the SALT Lens project

    """
    hdu = fits.open(arc_image)
    hdr = hdu[0].header
    if hdr['LAMPID'] == 'Xe' and hdr['GRATING'] == 'PG0900' and hdr['GRTILT'] == 15.875:
        print('Automatically processing arc image')
        data = hdu[1].data
        ystart = int(0.5 * len(data))
        xarr = np.arange(len(data[ystart]), dtype='int64')
        farr = data[ystart]

        lampfile = os.path.dirname(__file__)+'/data/Xe.lens'
        guessfile = os.path.dirname(__file__)+'/data/lens.db'

        slines, sfluxes = st.readlinelist(lampfile)
        spectrum = Spectrum.Spectrum(
            slines, sfluxes, dw=0.1, stype='line', sigma=6)
        swarr = spectrum.wavelength
        sfarr = spectrum.flux * farr.max() / spectrum.flux.max()

        soldict = readsolascii(guessfile, {})
        soldict = (soldict[soldict.keys()[0]])
        ws = WavelengthSolution.WavelengthSolution(
             xarr, xarr, function=soldict[7], order=soldict[8])
        ws.func.func.domain = soldict[11]
        ws.set_coef(soldict[10][2])
 
        # start the pre processing
        dcoef = ws.coef * 0.0
        dcoef[0] = 0.05 * ndstep
        dcoef[1] = 0.01 * ws.coef[1]
        ws = st.findxcor(xarr, farr, swarr, sfarr, ws,
                         dcoef=dcoef, ndstep=ndstep, best=False, inttype='interp')
        xp, wp = st.crosslinematch(xarr, farr, slines, sfluxes, ws,
                                   res=6, mdiff=20, wdiff=10,
                                   sections=3, sigma=5, niter=5)
        ws = st.findfit(np.array(xp), np.array(wp), ws=ws, thresh=ws.thresh)
        print(ws)
        with logging(logfile, True) as log:
            iws = ai.AutoIdentify(xarr, data, slines, sfluxes, ws, farr=farr,
                      method='Matchlines', rstep=100, istart=ystart, nrows=1,
                      res=6, dres=0.25, mdiff=20, sigma=5,
                      smooth=3, niter=5, dc=5, ndstep=ndstep, 
                      oneline=False, log=log, verbose=True)

            # get the basic information about the spectrograph
            dateobs = saltkey.get('DATE-OBS', hdu[0])
            try:
                utctime = saltkey.get('UTC-OBS', hdu[0])
            except SaltError:
                utctime = saltkey.get('TIME-OBS', hdu[0])

            instrume = saltkey.get('INSTRUME', hdu[0]).strip()
            grating = saltkey.get('GRATING', hdu[0]).strip()
            grang = saltkey.get('GR-ANGLE', hdu[0])
            grasteps = saltkey.get('GRTILT', hdu[0])
            arang = saltkey.get('AR-ANGLE', hdu[0])
            arsteps = saltkey.get('CAMANG', hdu[0])
            rssfilter = saltkey.get('FILTER', hdu[0])
            specmode = saltkey.get('OBSMODE', hdu[0])
            masktype = saltkey.get('MASKTYP', hdu[0]).strip().upper()
            slitname = saltkey.get('MASKID', hdu[0])
            slit = st.getslitsize(slitname)
            xbin, ybin = saltkey.ccdbin(hdu[0], arc_image)
            writeIS(iws, dbfile, dateobs=dateobs, utctime=utctime, instrume=instrume,
                    grating=grating, grang=grang, grasteps=grasteps, arsteps=arsteps,
                    arang=arang, rfilter=rssfilter, slit=slit, xbin=xbin,
                    ybin=ybin, objid=None, filename=arc_image, log=log, verbose=True)
        print(iws)

        #self.findfit()

 
    else:
        lamp = hdr['LAMPID']
        lampfile=iraf.osfn("pysalt$data/linelists/%s.salt" % lamp)
        lampfile = 'Xe.lens'
        specidentify(arc_image, lampfile, dbfile, guesstype='rss', 
                  guessfile=None, automethod='Matchlines',  function='legendre',  order=3,
                  rstep=100, rstart='middlerow', mdiff=20, thresh=5, niter=5, smooth=3,
                  inter=True, clobber=True,  preprocess=True, logfile=logfile, verbose=True)
        print("Running specidenity in interactive mode")