def create_nc(nc_params=None): if nc_params is None: nc_params = {"wl": WL} nc_params["broken_pl"] = False nc_params["slope1"] = draw_from_sample.gaussian( PARS["pl_slope_min"], PARS["pl_slope_max"]) max_template_flux = 1e-13 nc_params["norm_PL"] = draw_from_sample.gaussian( PARS["pl_norm_min"], max_template_flux) print("NC params: {}".format(nc_params)) nc = NuclearContinuumComponent(nc_params["broken_pl"]) # Make a Spectrum object with dummy flux spectrum = Spectrum(nc_params["wl"]) spectrum.dispersion = nc_params["wl"] nc.initialize(spectrum) if nc_params["broken_pl"] == True: comp_params = [ nc_params["wave_break"], nc_params["norm_PL"], nc_params["slope1"], nc_params["slope2"] ] else: comp_params = [nc_params["norm_PL"], nc_params["slope1"]] nc_flux = NuclearContinuumComponent.flux(nc, spectrum, comp_params) nc_err = nc_flux * 0.05 return nc_params["wl"], nc_flux, nc_err, nc_params
def create_fe(fe_params=None): """ Args: fe_params (dictionary): Iron component parameters. Required keys are: - no_templates (number of templates) - wl (wavelength range of Fe model, redshift must be accounted for already) - fe_width (in km/s) - fe_norm_{} (1,2,3 depending on number of templates) """ if fe_params is None: fe_params = {"no_templates": 3, "wl": WL} max_template_flux = 1.8119e-14 samples = draw_from_sample.gaussian(PARS["fe_norm_min"], max_template_flux, 3) fe_params["fe_norm_1"] = samples[0] fe_params["fe_norm_2"] = samples[1] fe_params["fe_norm_3"] = samples[2] sample = draw_from_sample.gaussian(PARS["fe_width_min"], PARS["fe_width_max"]) fe_params["fe_width"] = sample print("Fe params: {}".format(fe_params)) fe = FeComponent() # Make a Spectrum object with dummy flux spectrum = Spectrum(fe_params["wl"]) spectrum.dispersion = fe_params["wl"] fe.initialize(spectrum) comp_params = [ fe_params["fe_norm_{}".format(x)] for x in range(1, fe_params["no_templates"] + 1) ] + [fe_params["fe_width"]] fe_flux = FeComponent.flux(fe, spectrum, comp_params) fe_err = fe_flux * 0.05 # pl.errorbar(fe_params["wl"], fe_flux, fe_err) # pl.savefig("fe_data.png") return fe_params["wl"], fe_flux, fe_err, fe_params
def create_hg(hg_params=None): """ Args: hg_params (dictionary): Host galaxy component parameters. Required keys are: - no_templates (number of templates) - wl (wavelength range of HG model, redshift must be accounted for already) - hg_norm_{} (1,2,3 depending on number of templates) """ if hg_params is None: hg_params = {"no_templates": 3, "wl": WL} max_template_flux = 6e-12 samples = draw_from_sample.gaussian(PARS["hg_norm_min"], max_template_flux, 3) hg_params["hg_norm_1"] = samples[0] hg_params["hg_norm_2"] = samples[1] hg_params["hg_norm_3"] = samples[2] hg_params["hg_stellar_disp"] = draw_from_sample.gaussian( PARS["hg_stellar_disp_min"], PARS["hg_stellar_disp_max"]) print("HG params: {}".format(hg_params)) hg = HostGalaxyComponent() # Make a Spectrum object with dummy flux spectrum = Spectrum(hg_params["wl"]) spectrum.dispersion = hg_params["wl"] hg.initialize(spectrum) comp_params = [ hg_params["hg_norm_{}".format(x)] for x in range(1, hg_params["no_templates"] + 1) ] + [hg_params["hg_stellar_disp"]] hg_flux = HostGalaxyComponent.flux(hg, spectrum, comp_params) hg_err = hg_flux * 0.05 # pl.errorbar(hg_params["wl"], hg_flux, hg_err) # pl.savefig("hg_data.png") return hg_params["wl"], hg_flux, hg_err, hg_params
var_arr[jj, xx] = flux_errresize[sorted[1]]**2 flux = np.sum(fluxes_arr, axis=0) var = np.sum(var_arr, axis=0) flux_err = np.sqrt(var) print('sizes', np.shape(flux), np.shape(wavelengths)) #spectrum = Spectrum()#maskType="Emission lines reduced")#"Cont+Fe")# #spectrum.wavelengths = wavelengths #spectrum.flux = flux #spectrum.flux_error = flux_err mask = Mask(wavelengths=wavelengths, maskType=maskType) spectrum = Spectrum(flux) spectrum.mask = mask spectrum.dispersion = wavelengths spectrum.flux_error = flux_err # ------------ # Initialize model # ------------ model = Model() model.print_parameters = False #True# # ----------------- # Initialize components # ----------------- if PL: nuclear_comp = NuclearContinuumComponent() model.components.append(nuclear_comp)