# Initialize array for rebinned blurred stars:
cap_sdssbin = n.zeros((npars, naxis1), dtype=float)

# Do the blurring and rebinning:
for i in xrange(npars):
    print(i)
    blurspec = sdss_blur * data_flat[i]
    pxspline = pxs.PixelSpline(hires_wavebound, sdss_blur * data_flat[i])
    cap_sdssbin[i] = pxspline.resample(wavebound_sdss)


#i = -1L
#
#i += 1
#p.plot(10.**loglam_sdss, cap_sdssbin[i], drawstyle='steps-mid', hold=False)

# reshape the array:
out_shape = data[...,0].shape + (naxis1,)
cap_sdssbin.resize(out_shape)

out_infodict = copy.deepcopy(infodict)
out_infodict['version'] = infodict['version'] + '_lr'
out_infodict['filename'] = 'ndArch-' + out_infodict['class'] + '-' + out_infodict['version'] + '.fits'
out_infodict['coeff0'] = coeff0
out_infodict['coeff1'] = coeff1

io.write_ndArch(n.float32(cap_sdssbin), baselines, out_infodict)

#junk, bjunk, ijunk = io.read_ndArch(infodict['filename'])

cont_halpha = n.asarray([n.sum(sdss_meanspec[i] * wtest * deltawave_sdss) /
                         n.sum(deltawave_sdss * wtest) for i in xrange(nsub_age)])

# Let's try the following range of Halpha equivalent widths:
ew_ha = n.asarray([0., 3.0, 9.0])
n_ew = len(ew_ha)

# Broadcast-fu to add the line spectra and expand the grid:
full_sdssbin = cont_halpha.reshape((-1,1,1,1)) * \
               ew_ha.reshape((1,1,-1,1)) * \
               sdss_line_spec.reshape((1,1,1,-1)) + \
               ssp_sdssbin.reshape((nsub_age,log_vnum,1,naxis1))


baselines = [n.log10(ssp_agegyr[idx]), log_vbase, ew_ha]

this_class = 'ssp_galaxy_cont'
this_version = 'v002'

infodict = {'par_names': n.asarray(['log10-age', 'log10-vdisp', 'EW_Halpha']),
            'par_units': n.asarray(['log10-Gyr', 'log10-km/s', 'rest-frame Angstroms']),
            'par_axistype': n.asarray(['regular', 'regular', 'irregular']),
            'coeff0': coeff0, 'coeff1': coeff1,
            'fluxunit': '10^'+str(exp_div)+' erg/s/Ang/M_sun_init',
            'filename': 'ndArch-'+this_class+'-'+this_version+'.fits'}

io.write_ndArch(n.float32(full_sdssbin), baselines, infodict)

#junk, bjunk, ijunk = io.read_ndArch(infodict['filename'])

Beispiel #3
0
wavebound_rebin = 10.**logbound_rebin

# Initialize array for rebinned blurred SSPs:
ssp_rebin = n.zeros((nsub_age, naxis1), dtype=float)

# Do the rebinning:
for i_age in xrange(nsub_age):
    print(i_age)
    pxspline = pxs.PixelSpline(ssp_wavebound,
                               rebin_blur * ssp_flam[idx[i_age]])
    ssp_rebin[i_age] = pxspline.resample(wavebound_rebin)

baselines = [n.log10(ssp_agegyr[idx])]

this_class = 'ssp_hires_galaxy'
this_version = 'v001'

infodict = {
    'par_names': n.asarray(['log10-age']),
    'par_units': n.asarray(['log10-Gyr']),
    'par_axistype': n.asarray(['regular']),
    'coeff0': coeff0,
    'coeff1': coeff1,
    'fluxunit': '10^' + str(exp_div) + ' erg/s/Ang/M_sun_init',
    'filename': 'ndArch-' + this_class + '-' + this_version + '.fits'
}

io.write_ndArch(n.float32(ssp_rebin), baselines, infodict)

#junk, bjunk, ijunk = io.read_ndArch(infodict['filename'])
# Initialize array for rebinned blurred SSPs:
ssp_rebin = n.zeros((n_vdisp, nsub_age, naxis1), dtype=float)

# Do the rebinning:
for j_v in xrange(n_vdisp):
    print('vdisp step ', j_v, ' of ', n_vdisp)
    # Desired output sigma on baseline of the input SSPs:
    sig_wave_final = ssp_wave * vdisp_base[j_v] / c_kms
    # Subtract starting dispersion in quadrature:
    sig_wave_net = n.sqrt(sig_wave_final**2 - ssp_dwave**2)
    rebin_blur = misc.gaussproj(ssp_wavebound, sig_wave_net, wavebound_rebin)
    for i_age in xrange(nsub_age): ssp_rebin[j_v,i_age] = rebin_blur * ssp_flam[idx[i_age]]

baselines = [vdisp_base, n.log10(ssp_agegyr[idx])]

this_class = 'ssp_hires_galaxy'
this_version = 'v002'

infodict = {'par_names': n.asarray(['vdisp', 'log10-age']),
            'par_units': n.asarray(['km/s', 'log10-Gyr']),
            'par_axistype': n.asarray(['regular', 'regular']),
            'coeff0': coeff0, 'coeff1': coeff1,
            'fluxunit': '10^'+str(exp_div)+' erg/s/Ang/M_sun_init',
            'filename': 'ndArch-'+this_class+'-'+this_version+'.fits'}

io.write_ndArch(n.float32(ssp_rebin), baselines, infodict)

#junk, bjunk, ijunk = io.read_ndArch(infodict['filename'])

Beispiel #5
0
# Initialize array for rebinned blurred stars:
cap_sdssbin = n.zeros((npars, naxis1), dtype=float)

# Do the blurring and rebinning:
for i in xrange(npars):
    print(i)
    blurspec = sdss_blur * data_flat[i]
    pxspline = pxs.PixelSpline(hires_wavebound, sdss_blur * data_flat[i])
    cap_sdssbin[i] = pxspline.resample(wavebound_sdss)

#i = -1L
#
#i += 1
#p.plot(10.**loglam_sdss, cap_sdssbin[i], drawstyle='steps-mid', hold=False)

# reshape the array:
out_shape = data[..., 0].shape + (naxis1, )
cap_sdssbin.resize(out_shape)

out_infodict = copy.deepcopy(infodict)
out_infodict['version'] = infodict['version'] + '_lr'
out_infodict['filename'] = 'ndArch-' + out_infodict[
    'class'] + '-' + out_infodict['version'] + '.fits'
out_infodict['coeff0'] = coeff0
out_infodict['coeff1'] = coeff1

io.write_ndArch(n.float32(cap_sdssbin), baselines, out_infodict)

#junk, bjunk, ijunk = io.read_ndArch(infodict['filename'])