# Setup extract for extraction
    E = Extract()
    E.ra, E.dec = (t.root.Info.cols.ra[:], t.root.Info.cols.dec[:])
    E.data = t.root.Fibers.cols.spectrum[:]
    E.error = t.root.Fibers.cols.error[:]
    E.ifuslot_i = t.root.Info.cols.ifuslot[:]
    E.mask = np.isfinite(E.data)
    tophat = E.tophat_psf(3., 10.5, 0.025)
    moffat = E.moffat_psf(seeing, 10.5, 0.025)

    newpsf = tophat[0] * moffat[0] / np.max(tophat[0])
    psf = [newpsf, moffat[1], moffat[2]]
    E.psf = psf

    E.get_ADR_RAdec(A)
    E.coords = ncoords
    

    # Go through each source and extract
    log.info('Extracting %i Sources from %s' % 
             (len(E.coords), op.basename(filename)))
    for i in np.arange(len(E.coords)):
        # Extract spectrum
        specinfo = E.get_spectrum_by_coord_index(i)
        spectrum, error, weight = (specinfo[0], specinfo[1], specinfo[2])

        # If the spectrum info comes back empty
        if len(spectrum) == 0:
            log.info('Did not find fibers for source %i' % (i+1))
            continue
Example #2
0
if args.image_center_size is not None:
    bounding_box = [float(corner.replace(' ', ''))
                    for corner in args.image_center_size.split(',')]
else:
    bounding_box = [RA, Dec, 22.]

bounding_box[2] = int(bounding_box[2]*60./args.pixel_scale/2.) * 2 * args.pixel_scale

bb = int(bounding_box[2]/args.pixel_scale/2.)*args.pixel_scale
N = int(bounding_box[2]/args.pixel_scale/2.) * 2 + 1
args.log.info('Number of pixels: %i' % N)
A = Astrometry(bounding_box[0], bounding_box[1], 0., 0., 0.)
tp = A.setup_TP(A.ra0, A.dec0, 0.)
E = Extract()
Aother = Astrometry(bounding_box[0], bounding_box[1], pa, 0., 0.)
E.get_ADR_RAdec(Aother)
dra = np.interp(wave_extract[0], def_wave, E.ADRra)
ddec = np.interp(wave_extract[0], def_wave, E.ADRdec)
print(dra, ddec)
ra -= dra / 3600. / np.cos(np.deg2rad(A.dec0))
dec -= ddec / 3600.
header = tp.to_header()
x, y = tp.wcs_world2pix(ra, dec, 1)
xg = np.linspace(-bb, bb, N)
yg = np.linspace(-bb, bb, N)
xgrid, ygrid = np.meshgrid(xg, yg)
Pos = np.zeros((len(x), 2))
Pos[:, 0], Pos[:, 1] = (x, y)
back = biweight(spectra[:, bsel], axis=1)
data = (spectra[:, wsel] - back[:, np.newaxis]) * 2.
mask = np.array(np.isfinite(data), dtype=float)