Ejemplo n.º 1
0
def load_filter(filter, gen=2):
    '''Given the filter and generation, attempt to load the data from
   FITS file and put it in the cache.'''
    file = os.path.join(base, "%s_mean%d.fits" % (filter, gen))
    f = FITS.FITS(file)
    xs = f['CRVAL1'] + (num.arange(f['NAXIS1']) + 1 -
                        f['CRPIX1']) * f['CDELT1']
    ys = f['CRVAL2'] + (num.arange(f['NAXIS2']) + 1 -
                        f['CRPIX2']) * f['CDELT2']
    xx, yy = num.meshgrid(xs, ys)
    points = num.array([num.ravel(xx), num.ravel(yy)]).T
    values = f.data()
    mean[(filter, gen)] = interp2d(points, num.ravel(values))
    f.close()
    f = FITS.FITS(file.replace('mean', 'std'))
    values = f.data()
    std[(filter, gen)] = interp2d(points, num.ravel(values))
    f.close()
Ejemplo n.º 2
0
from scipy.interpolate import CloughTocher2DInterpolator as interp2D
import FITS
import re

pat = re.compile(r'([ugriYJHBV])_mean2.fits')
f = open('BV_max.dat')
lines = f.readlines()
lines = map(string.strip, lines)
lines = map(string.split, lines)
names = [line[0] for line in lines]
name_sts = array([float(line[7]) / 30. for line in lines])

file = sys.argv[1]
filt = pat.search(file).group(1)

f = FITS.FITS(file)
xs = f['CRVAL1'] + (arange(1, f['NAXIS1'] + 1) - f['CRPIX1']) * f['CDELT1']
ys = f['CRVAL2'] + (arange(1, f['NAXIS2'] + 1) - f['CRPIX2']) * f['CDELT2']
N = f['NAXIS1'] * f['NAXIS2']
X = dstack(meshgrid(xs, ys)).reshape((N, 2))
fl = interp2D(X, ravel(f.data()))
efl = interp2D(X, ravel(FITS.qread(file.replace('mean', 'std'))))

x, y, v, efluxes, mesh, xoff, xscale, yoff, yscale, mean_flux = getdata(
    filt, False)

x = x * xscale + xoff
y = y * yscale + yoff

ids = concatenate([nonzero(diff(y))[0], array([len(y) - 1])])
sts = y[ids]
Ejemplo n.º 3
0
    wave.append(float(fs[1]))
    flux.append(float(fs[2]))
f.close()

day = array(day)
wave = array(wave)
flux = array(flux)
# figure out the dimensions
val1 = day[0]
numwaves = len(nonzero(equal(day, day[0])))
nx = numwaves
x0 = wave[0]
dx = wave[1] - wave[0]
dy = day[numwaves] - day[0]
ny = len(day) / nx
y0 = day[0]

flux.shape = (ny, nx)

of = FITS.FITS(outfile, create=1)
of.newhead("T", -32, 2, [nx, ny])
of.putdata(flux)
print 1, x0, dx, 1, y0, dy
of.inskey("NAXIS2", "CRPIX1", 1)
of.inskey("CRPIX1", "CRVAL1", x0)
of.inskey("CRVAL1", "CDELT1", dx)
of.inskey("CDELT1", "CRPIX2", 1)
of.inskey("CRPIX2", "CRVAL2", y0)
of.inskey("CRVAL2", "CDELT2", dy)
of.close