Example #1
0
    wei2 = []

    # Create jackknife resamples from data
    for i in range(len(data)):
        l = []
        for j in range(len(data)):
            if j != i:
                l.append(data[j])
        resample_data = N.asarray(l)

        # Fit continuum for all spectra
        for d in resample_data:
            d.cont_fit()

        # Create a stack of all the deltas
        ll2, de2, wst2 = stack_flux(resample_data, 1)

        ## Create deltas of the stack (of weighted flux)
        # Stack the weighted flux
        ll1, st1, wst1 = stack_flux(resample_data, 0)

        # Fit the continuum for the stack
        g = data[0]
        d = forest(ll1, st1, wst1, g.thid, g.ra, g.dec, g.zqso, g.plate, g.mjd,
                   g.fid, g.order)
        try:
            d.cont_fit()
        except:
            print 'Error fitting continuum: ' + str(g.thid)
            break
        # Create deltas and weights in same bin widths as before
Example #2
0
# Fit the continua
newdata = []
for d in data:
    d.cont_fit()
    if d.bad_cont is not None:
        print 'bad cont: ' + str(T)
        continue
    else:
        newdata.append(d)
data = N.asarray(newdata)

# Define g in order to retrieve thid, etc for stats, continuum fitting and plot
g = data[0]

# Stack the weighted flux
ll1, st1, wst1  = stack_flux(data, 0)
# Fit the continuum for the stack
d = forest(ll1, st1, wst1, g.thid, g.ra, g.dec, g.zqso, g.plate, g.mjd, g.fid, g.order)
d.cont_fit()
# Create continuum in same bin widths as before
nstack = int((forest.lmax - forest.lmin) / forest.dll) + 1
co1 = sp.zeros(nstack)
bins=((d.ll - d.lmin) / d.dll + 0.5).astype(int)
c = sp.bincount(bins, weights = d.co)
co1[:len(c)] += c

# Get mean flux for each epoch
epochflux = []
for f in data:
    epochflux.append(N.sum(f.fl * f.iv)/N.sum(f.iv))
Example #3
0
            l.append(f)
        i += 1
    data = N.asarray(l)

    # Fit continuum for all spectra
    for d in data:
        d.cont_fit()

    # Define g in order to retrieve thid, etc for plot
    try:
        g = data[0]
    except:
        continue

    # Create a stack of all the deltas
    ll2, de2, wst2 = stack_flux(data, 1)

    # Create deltas of the stack (of weighted flux)
    # Stack the weighted flux
    ll1, st1, wst1 = stack_flux(data, 0)
    # Fit the continuum for the stack
    d = forest(ll1, st1, wst1, g.thid, g.ra, g.dec, g.zqso, g.plate, g.mjd,
               g.fid, g.order)
    d.cont_fit()
    # Create deltas in same bin widths as before
    nstack = int((forest.lmax - forest.lmin) / forest.dll) + 1
    de1 = sp.zeros(nstack)
    bins = ((d.ll - d.lmin) / d.dll + 0.5).astype(int)
    c = sp.bincount(bins, weights=d.fl / d.co - 1)
    de1[:len(c)] += c