示例#1
0
def get_arcs(image, skypol=2, clip=3, fferr=0.015):
    """Fit arc image and create table with one-dimensional arc spectra.

    Parameters
    ----------
    image: ~fits.HDUList
        prepared image set with one extension for each chip
    skypol: ~int, optional
        degree with which image is fit along spatial direction (default: 2)
    clip: ~float, optional
        maximum sigma with which points are allowed to deviate from fit
        (default: 3)
    fferr: ~float, optional
        Flat field uncertainty, used for estimating uncertainties
        (default: 0.015)

    Returns
    -------
    Table with columns 'x' (positions on exposed part of CCD) and
    extracted fluxes 'f' (with dimension equal to number of extensions)
    """
    data = multiext_data(image)
    ron = multiext_header_value(image, 'RDNOISE')
    arc, chi2, _, ntbadl, ntbadh = extract.fitsky(data, ron=ron, skypol=skypol,
                                                  clip=clip, fferr=0.015,
                                                  ibadlimit=7)
    x = multiext_x_coords(image, 'CCDSEC').squeeze()
    arctab = Table([x.T, arc.T, chi2.T], names=('x', 'f', 'chi2'))
    arctab.meta['grwlen'] = image[0].header['GRWLEN']
    return arctab
示例#2
0
def extract_arc(gmos_slice, extracted_spectrum):
    arc = np.array(gmos_slice.get_prepared_arc_data())
    if extracted_spectrum.meta['nstars'] > 1:
        raise ValueError('cannot yet extract arcs for more than one star')
    psf_offsets = (extracted_spectrum.meta['tracepos'] +
                   extracted_spectrum.meta['psfpar'][0])
    ix = np.round(psf_offsets).astype(np.int)
    ix = np.minimum(np.maximum(ix, 0), arc.shape[1]-1)
    if ix.ndim == 1:
        ix = ix[np.newaxis,:]
    (_, chi2, arcfit, ntbadl, ntbadh) = extract.fitsky(arc, ibadlimit=99)
    arc = arcfit[(0,1,2),ix[:,(0,1,2)],:].transpose(2,0,1)
    arctab = Table([extracted_spectrum['x'], arc, chi2.T],
                   names=['x', 'arc', 'chi2'])
    arctab.meta['nstars'] = 1
    arctab.meta['nbad'] = [ntbadl, ntbadh]

    return arctab
示例#3
0
def get_arcs(image, skypol=2, clip=3, fferr=0.015, fitrange=None):
    """Fit arc image and create table with one-dimensional arc spectra.

    Parameters
    ----------
    image: ~fits.HDUList
        prepared image set with one extension for each chip
    skypol: ~int, optional
        degree with which image is fit along spatial direction (default: 2)
    clip: ~float, optional
        maximum sigma with which points are allowed to deviate from fit
        (default: 3)
    fferr: ~float, optional
        Flat field uncertainty, used for estimating uncertainties
        (default: 0.015)
    fitrange: slice, or list of two ~int
        slice along slit, or offsets relative to centre, to extract arc from

    Returns
    -------
    Table with columns 'x' (positions on exposed part of CCD) and
    extracted fluxes 'f' (with dimension equal to number of extensions)
    """

    data = multiext_data(image)

    ron = multiext_header_value(image, 'RDNOISE')

    arc, chi2, _, ntbadl, ntbadh = extract.fitsky(data,
                                                  ron=ron,
                                                  skypol=skypol,
                                                  clip=clip,
                                                  fferr=0.015,
                                                  fitrange=fitrange,
                                                  ibadlimit=7)
    x = multiext_x_coords(image, 'CCDSEC').squeeze()
    arctab = Table([x.T, arc.T, chi2.T], names=('x', 'f', 'chi2'))
    arctab.meta['grwlen'] = image[0].header['GRWLEN']
    return arctab
示例#4
0
文件: trial.py 项目: mhvk/mcsnr
        plt.ion()
        plt.clf()
        plt.plot(scitab['x'], scitab['f'][:,0,:])
        plt.draw()

if __name__ != '__main__':
        # get corresponding arc
        prep_arc_fits = raw_sci.mask_arc.prepared_fits.fits.fits_data
        arcdata = np.array([prep_arc_fits[chip].data[sci_slice, :]
                            for chip in range(1,4)])

        ix = np.round(psf.offsets()+tracepos[0]).astype(np.int)
        if len(tracepos) == 1:
            ix = ix[np.newaxis,:]
        (_, arcchi2, arctest, ntbadl, ntbadh) = extract.fitsky(arcdata)
        scitab['a'] = arctest[(0,1,2),ix[:,(0,1,2)],:].transpose(2,0,1)

        # plt.plot(dayarc['w'], dayarc['f']-5000.)
        # plt.plot(model_wide_slit_arc['w'], model_wide_slit_arc['f']-3500.)
        # scitab['w'] = lines.fit(np.arange(3)[np.newaxis,:],
        #                         scitab['x'][:,np.newaxis])[:,np.newaxis,:]
        # plt.plot(scitab['w'][:,0,:], scitab['a'][:,0,:])

        # **** AM HERE ***
        specpos_x = raw_sci.raw_fits.mask.table[slitno]['specpos_x']
        # print slitno, specpos_x
        #   specpos_x  xrefbest
        # 18:  -56. -> 624.
        # 19:  124. -> 466.
        # 20: -119  -> 679.