예제 #1
0
    ministart[spectral_feature_name] = [0, 0, 0]

print ministart

ministart = unparseP(ministart)
print ministart
miniscale = ministart + 1.

NA, NA, Cmat = miniLM_new(ministart=ministart,
                          miniscale=miniscale,
                          passdata=params,
                          residfn=residfn,
                          verbose=True,
                          maxiter=1)
if show_plots:
    save_img(Cmat, "Cmat.fits")

errs = sqrt(diag(Cmat))

parsed_errs = parseP(errs, params)

if show_plots:
    plt.figure(figsize=(8, len(parsed_errs.keys()) * 3))

    for i, key in enumerate(parsed_errs):
        plt.subplot(len(parsed_errs.keys()), 1, i + 1)

        y_scale = 1
        if type(parsed_errs[key]) == type(arange(2.)[0]):
            x_vals = 0
        elif len(parsed_errs[key]) == params["n_redshift"]:
예제 #2
0
def Kim13_PCs():
    [bands, pcs, phases, mags] = readcol("input/LC_PCs.txt", 'aiff')
    bands = array(bands)

    interpfns = {}
    for i, band in enumerate('griz'):
        plt.subplot(2,2,i+1)
        plt.title(band)
        for pc in range(4):
            inds = where((bands == band)*(pcs == pc))
            phase = phases[inds]
            mag = mags[inds]
            
            phase = concatenate(([-100.], phase, [100.]))
            mag = concatenate(([mag[0]], mag, [mag[-1]]))
            
            interpfns[(band, pc)] = interp1d(phase, mag, kind = 'linear')
            plt.plot(arange(-10., 36.), interpfns[(band, pc)](arange(-10., 36.)), label = str(pc))
        plt.legend(loc = 'best')
    plt.savefig("pc_interps.pdf")
    plt.close()

    redshift = 1.2

    sncosmo_model = realize_SN_model(redshift = redshift, x1 = 0.0, c = 0.0, MV = -19.08 + 2.1*0.0)
    if redshift == 1.2:
        colors = {"Z087": 'm', "Y106": 'b', "J129": 'g', "H158": 'orange'} # "F184": 'red'
        obs_to_pc_filt = {"Z087": 'g', "Y106": 'r', "J129": 'i', "H158": 'z'}
    else:
        colors = {"Y106": 'b', "J129": 'g', "H158": 'orange', "F184": 'red'}
        obs_to_pc_filt = {"Y106": 'g', "J129": 'r', "H158": 'i', "F184": 'z'}

    dates = arange(-10*(1. + redshift), 35*(1 + redshift), 5)
    phases = dates/(1. + redshift)
    jacobian = zeros([len(phases)*4, 6], dtype=float64) # parameters are daymax, mag, pc0123
    jacobian[:,1] = 1.

    weight_matrix = zeros([len(phases)*4]*2, dtype=float64)
    total_SNR_all = 0.

    for i, date in enumerate(dates):
        phase = date/(1. + redshift)
        for j, filt in enumerate(colors):

            total_SN = 0
            f_lamb_SN = sncosmo_model.flux(date, obs_waves)
            args["mdl"] = f_lamb_SN


            for dither in range(1):
                ETC_result = get_imaging_SN(redshift = redshift, exp_time = 100.*(1. + (filt == "F184")), effective_meters2_fl = filt + ".txt", phase = phase,
                                            offset_i = random.random()*22, offset_j = random.random()*22, **args)
                
                total_SN += ETC_result["PSF_phot_S/N"]**2.
            total_SNR_all += total_SN
            total_SN = sqrt(total_SN)

            dmag = (2.5/log(10.))/total_SN
            weight_matrix[i + j*len(dates), i + j*len(dates)] = 1./(dmag**2.)

            f_lamb_SN = sncosmo_model.flux(date + 0.2*(1. + redshift), obs_waves)
            args["mdl"] = f_lamb_SN
            ETC_result_dphase = get_imaging_SN(redshift = redshift, exp_time = 100., effective_meters2_fl = filt + ".txt", phase = phase + 0.2,
                                               offset_i = random.random()*22, offset_j = random.random()*22, **args)

            jacobian[i + j*len(dates), 0] = (ETC_result_dphase["AB_mag"] - ETC_result["AB_mag"])/0.2


            for k in range(4):
                jacobian[i + j*len(dates), k+2] = interpfns[(obs_to_pc_filt[filt], k)](phase)

    total_SNR_all = sqrt(total_SNR_all)
    print weight_matrix
    save_img(jacobian, "jacobian.fits")
    save_img(weight_matrix, "weight_matrix.fits")
    param_wmat = dot(transpose(jacobian), dot(weight_matrix, jacobian))
    param_cmat = linalg.inv(param_wmat)
    print param_cmat
    print total_SNR_all, sqrt(diag(param_cmat))
예제 #3
0
    


params_as_array = array(params_as_array)

print params_as_array.shape

cmat = corrcoef(transpose(params_as_array))

print cmat.shape

print combs[0]

from DavidsNM import save_img
save_img(cmat, "cmat.fits")




commands.getoutput("rm -f slurm-*.out")
commands.getoutput("rm -fr " + sys.argv[1])


surveys_written = 0



print "Ready to start..."

for i in range(nsurveys):
예제 #4
0
from numpy import *
import pyfits
from scipy.interpolate import RectBivariateSpline
from scipy.special import jv
from DavidsNM import save_img

print "This is a dumb hack to get PSFS while we wait for better ones."
f = open("tiny.par")
orig_lines = f.read()
f.close()
commands.getoutput("rm -f *.fits")

waves = exp(arange(log(3000.), log(30001.), log(10.)/23.))

for wave in waves:
    xs, ys = meshgrid(arange(-200., 201.)*0.005, arange(-200., 201.)*0.005)


    rs = sqrt(xs**2. + ys**2.)
    rs = clip(rs, 1e-4, 1e10)

    psf = jv(1, rs*1.e6*3.14159**2. / (27.*wave))**2. / (3.14159*rs**2.)
    psf *= 0.005**2.

    print sum(psf)

    save_img(psf, "%05i_5mas.fits" % wave)
    
    

예제 #5
0
import commands
from numpy import *
import pyfits
from scipy.interpolate import interp1d
from DavidsNM import save_img

norm = interp1d(
    [1000., 6000., 10500, 12500, 15500, 20000, 40000],
    [0.88, 0.88, 0.852273685192, 0.837328058564, 0.807873205993, 0.75, 0.75],
    kind='linear')

print "HACK!!!!" * 100
norm = lambda x: 1.

commands.getoutput("rm -f *.fits")

waves = exp(arange(log(3000.), log(30001.), log(10.) / 23.))

for wave in waves:
    dat = zeros([401, 401], dtype=float64)

    dat[200, 200] = 1.0001 * norm(wave) / 3.
    dat[200, 200 - 30] = norm(wave) / 3.
    dat[200, 200 + 30] = norm(wave) / 3.

    save_img(dat, "%05i_5mas.fits" % wave)