Ejemplo n.º 1
0
 def findxcorfit(self):
     """Maximize the normalized correlation coefficient using the full wavelength solution.
     """
     self.ws = st.fitxcor(
         self.xarr,
         self.farr,
         self.swarr,
         self.sfarr,
         self.ws,
         interptype='interp')
     self.plotArt()
     self.redraw_canvas()
Ejemplo n.º 2
0
def arcstraight(data, xarr, istart, ws=None, function='poly', order=3,
                rstep=1, nrows=1, dcoef=None, y1=None, y2=None, log=None, verbose=True):
    """For a given image, assume that the line given by istart is the fiducial and then calculate
       the transformation between each line and that line in order to straighten the arc

       returns Wavlenght solution
    """
    ImageSolution = {}

    #set up the edges 
    if y1 is None: y1=0
    if y2 is None: y2=data.shape[0]

    # extract the central row
    oxarr = xarr.copy()
    ofarr = data[istart]
    ws = WavelengthSolution.WavelengthSolution(xarr, xarr, function, order)
    ws.fit()
    ImageSolution[istart] = ws
    if isinstance(dcoef, str): 
       if dcoef=='':
          dcoef = None
       else:
          try:
              dcoef = [float(w) for w in dcoef.replace('[','').replace(']','').split()]
          except:
              raise SaltError('dcoef is not the right format')
      
    if dcoef is not None: ws.coef = dcoef

    data = nd.gaussian_filter(data, 3)

    # now step around the central row
    for i in range(rstep, int(0.5 * len(data)), rstep):
        for k in [istart - i, istart + i]:
            if k < y1 or k > y2: continue
            lws = getwsfromIS(k, ImageSolution)
            xarr = np.arange(len(data[k]))
            farr = apext.makeflat(data, k, k + nrows)
            nws = st.fitxcor(
                xarr,
                farr,
                oxarr,
                ofarr,
                lws,
                interptype='interp')
            ImageSolution[k] = nws

    return ImageSolution
Ejemplo n.º 3
0
def arcstraight(data,
                xarr,
                istart,
                ws=None,
                function='poly',
                order=3,
                rstep=1,
                nrows=1,
                dcoef=None,
                y1=None,
                y2=None,
                log=None,
                verbose=True):
    """For a given image, assume that the line given by istart is the fiducial and then calculate
       the transformation between each line and that line in order to straighten the arc

       returns Wavlenght solution
    """
    ImageSolution = {}

    #set up the edges
    if y1 is None: y1 = 0
    if y2 is None: y2 = data.shape[0]

    # extract the central row
    oxarr = xarr.copy()
    ofarr = data[istart]
    ws = WavelengthSolution.WavelengthSolution(xarr, xarr, function, order)
    ws.fit()
    ImageSolution[istart] = ws
    if isinstance(dcoef, str):
        if dcoef == '':
            dcoef = None
        else:
            try:
                dcoef = [
                    float(w)
                    for w in dcoef.replace('[', '').replace(']', '').split()
                ]
            except:
                raise SaltError('dcoef is not the right format')

    if dcoef is not None: ws.coef = dcoef

    data = nd.gaussian_filter(data, 3)

    # now step around the central row
    for i in range(rstep, int(0.5 * len(data)), rstep):
        for k in [istart - i, istart + i]:
            if k < y1 or k > y2: continue
            lws = getwsfromIS(k, ImageSolution)
            xarr = np.arange(len(data[k]))
            farr = apext.makeflat(data, k, k + nrows)
            nws = st.fitxcor(xarr,
                             farr,
                             oxarr,
                             ofarr,
                             lws,
                             interptype='interp')
            ImageSolution[k] = nws

    return ImageSolution