def gal_model_calcs(self): ''' Read in galaxy SEDs, regrid them, calculate the model flux in each filter for each redshift. ''' print('Using %ld gal templates over %ld redshifts' % (self._n_gal_template, self.nz)) self.zstep = (self.zmax - self.zmin) / (self.nz - 1) model_flux_gals = np.zeros( (self.n_filter, self._n_gal_template * self.nz)) for i in xrange(self._n_gal_template): sed_length = get_file_length(i, self.gals_sed_input) p_lam, p_val = read_file(i, self.gals_sed_input) for j in xrange(self.nz): z = self.zmin + j * self.zstep for k in xrange(self.n_filter): p_val_fine = regrid_sed( z, p_lam, p_val, self.filter_lgth_fine[k], sed_length, self.filter_lamb_fine[k]) mod_val = integrate_sed( self.filter_lgth_fine[k], p_val_fine, self.filter_lamb_fine[k], self.filter_thru_fine[k]) model_flux_gals[k][j + i * self.nz] = mod_val self.model_flux_gals = model_flux_gals
def star_model_calcs(self): ''' Read in star SEDs, regrid them, calculate the model flux in each filter for each redshift. ''' print('Using %ld star templates' % self._n_star_template) model_flux_stars = np.zeros((self.n_filter, self._n_star_template)) for i in xrange(self._n_star_template): sed_length = get_file_length(i, self.stars_sed_input) p_lam, p_val = read_file(i, self.stars_sed_input) for k in xrange(self.n_filter): p_val_fine = regrid_sed( 0.0, p_lam, p_val, self.filter_lgth_fine[k], sed_length, self.filter_lamb_fine[k]) mod_val = integrate_sed( self.filter_lgth_fine[k], p_val_fine, self.filter_lamb_fine[k], self.filter_thru_fine[k]) model_flux_stars[k][i] = mod_val self.model_flux_stars = model_flux_stars
def filter_calcs(self): ''' Reads in the models seds and filter throughput response curves, regrids the filters onto a finer grid for interpolation, and calls a routine to calculate the filter flux zero-points. Testing indicates details of regridding and interpolation scheme is not very important. ''' sed_length = 0 self.n_filter = get_num_files(self.filters_input) if self.n_filter < 2: raise ValueError print('Found %d Filters' % self.n_filter) self._n_star_template = get_num_files(self.stars_sed_input) self._n_gal_template = get_num_files(self.gals_sed_input) # find the longest SED file among the bunch # first the star SEDs for i in xrange(self._n_star_template): n = get_file_length(i, self.stars_sed_input) if n * 2 > sed_length: sed_length = n * 2 # do the same for the galaxies for i in xrange(self._n_gal_template): n = get_file_length(i, self.gals_sed_input) if n * 2 > sed_length: sed_length = n * 2 self.filter_lgth_fine = np.zeros(self.n_filter) self.norm = np.zeros(self.n_filter) self.filter_lamb_fine = {} self.filter_thru_fine = {} for i in xrange(self.n_filter): n = get_file_length(i, self.filters_input) filter_length = n regrid_factor = np.round(float(sed_length) / float(n)) filter_lgth_fine = n * regrid_factor filt_lamb, filt_thru = read_file(i, self.filters_input) filter_lamb_fine, filter_thru_fine = \ regrid_filter(filt_lamb, filt_thru, filter_length, filter_lgth_fine) norm = calc_normalization(filter_lamb_fine, filter_thru_fine, filter_lgth_fine) print("Filter %ld has (AB) zeropoint flux normalization: %f" % (i, norm)) self.filter_lgth_fine[i] = filter_lgth_fine self.norm[i] = norm self.filter_lamb_fine[i] = filter_lamb_fine self.filter_thru_fine[i] = filter_thru_fine