示例#1
0
from astroquery.sdss import SDSS
from astropy import coordinates as coords
pos = coords.SkyCoord(RA * u.deg, Dec * u.deg, frame='fk5')
xid = SDSS.query_region(pos, radius=11*u.arcmin, spectro=True,
                        photoobj_fields=['ra', 'dec', 'u', 'g', 'r', 'i', 'z'],
                        specobj_fields=['plate', 'mjd', 'fiberID', 'z',
                                        'specobjid', 'run2d', 'instrument'])
ra, dec = xid['ra'], xid['dec']
sp = SDSS.get_spectra(matches=xid)

# Build aperture PSF for aperture extraction
fixed_aperture = 4.
aperture = E.tophat_psf(fixed_aperture, 10.5, 0.25)

# Get curve of growth from VIRUS PSF for the given loaded shot
psf = E.model_psf(gmag_limit=22.)
r, curve_of_growth = E.get_psf_curve_of_growth(psf)
correction = 1. / np.interp(fixed_aperture, r, curve_of_growth)
E.log.info('PSF correction for radius, %0.1f", is: %0.2f' % (fixed_aperture, 
                                                             correction))

coords = SkyCoord(ra * u.deg, dec * u.deg)
L = []
kk = 0
for coord, S, xi in zip(coords, sp, xid):
    if coord.dec.deg > 0.:
        pn = '+'
    else:
        pn = '-'
    coord_tup = (coord.ra.hms.h, coord.ra.hms.m, coord.ra.hms.s, pn,
                 np.abs(coord.dec.dms.d), np.abs(coord.dec.dms.m),
示例#2
0
from hetdex_api.extract import Extract
import argparse
import sys
from astropy.io import fits

parser = argparse.ArgumentParser()
parser.add_argument("-s", "--shot", type=str, help="Shotid.")
args = parser.parse_args(sys.argv[1:])

shot = args.shot

E = Extract()
E.load_shot(shot, survey="hdr2")

gmag_limit = 22.
radius = 50.
psf = E.model_psf(gmag_limit=gmag_limit, radius=radius)

hdr = fits.Header()
hdr["SHOT"] = shot
hdr["GMAG_LIMIT"] = gmag_limit
hdr["RADIUS"] = radius

hdu = fits.PrimaryHDU(psf[0], header=hdr)
hdu_x, hdu_y = fits.ImageHDU(psf[1]), fits.ImageHDU(psf[2])
hdul = fits.HDUList([hdu, hdu_x, hdu_y])

hdul.writeto("/data/05865/maja_n/im2d/psf_hdr2/" + shot + ".fits",
             overwrite=True)
print("Wrote to /data/05865/maja_n/im2d/psf_hdr2/" + shot + ".fits")