def update_model(self): '''Update absorption model ''' if len(self.abssys_widg.all_abssys) == 0: self.lls_model = None self.spec_widg.model = None return # all_tau_model = np.zeros(len(self.full_model.flux)) # Loop on LLS for lls in self.abssys_widg.all_abssys: # LL wv_rest = self.full_model.dispersion / (lls.zabs + 1) energy = wv_rest.to(u.eV, equivalencies=u.spectral()) # Get photo_cross and calculate tau tau_LL = (10.**lls.NHI / u.cm**2) * xatomi.photo_cross( 1, 1, energy) # Lyman tau_Lyman = xsv.voigt_model(self.full_model.dispersion, lls.lls_lines, flg_ret=2) tau_model = tau_LL + tau_Lyman # Kludge around the limit pix_LL = np.argmin(np.fabs(wv_rest - 911.3 * u.AA)) pix_kludge = np.where((wv_rest > 911.5 * u.AA) & (wv_rest < 912.8 * u.AA))[0] tau_model[pix_kludge] = tau_model[pix_LL] # Add all_tau_model += tau_model # Loop on forest lines for forest in self.all_forest: tau_Lyman = xsv.voigt_model(self.full_model.dispersion, forest.lines, flg_ret=2) all_tau_model += tau_Lyman # Flux and smooth flux = np.exp(-1. * all_tau_model) if self.smooth > 0: self.lls_model = lsc.convolve_psf(flux, self.smooth) else: self.lls_model = flux # Finish self.full_model.flux = self.lls_model * self.continuum.flux self.spec_widg.model = self.full_model
def update_model(self): '''Update absorption model ''' if len(self.abssys_widg.all_abssys) == 0: self.lls_model = None self.spec_widg.model = None return # all_tau_model = xialu.tau_multi_lls(self.full_model.dispersion, self.abssys_widg.all_abssys) # Loop on forest lines for forest in self.all_forest: tau_Lyman = xsv.voigt_model(self.full_model.dispersion, forest.lines, flg_ret=2) all_tau_model += tau_Lyman # Flux and smooth flux = np.exp(-1. * all_tau_model) if self.smooth > 0: self.lls_model = lsc.convolve_psf(flux, self.smooth) else: self.lls_model = flux # Finish self.full_model.flux = self.lls_model * self.continuum.flux self.spec_widg.model = self.full_model
def update_model(self): if self.parent is None: return all_comp = self.parent.comps_widg.all_comp #selected_components() if len(all_comp) == 0: self.model.flux[:] = 1. return # Setup lines wvmin = np.min(self.spec.dispersion) wvmax = np.max(self.spec.dispersion) gdlin = [] #QtCore.pyqtRemoveInputHook() #xdb.set_trace() #QtCore.pyqtRestoreInputHook() for comp in all_comp: for line in comp.lines: wvobs = (1+line.attrib['z'])*line.wrest if (wvobs>wvmin) & (wvobs<wvmax): gdlin.append(line) # Voigt self.model = xsv.voigt_model(self.spec.dispersion,gdlin, fwhm=self.fwhm)#,debug=True) #Define arrays for plotting residuals if self.plot_residuals: self.residual_limit = self.spec.sig * self.residual_normalization_factor self.residual = (self.spec.flux - self.model.flux) * self.residual_normalization_factor
def tau_multi_lls(wave, all_lls): '''Calculate opacities on an input observed wavelength grid Parameters: ----------- wave: Quantity array Wavelengths all_lls: List of LLS Class ''' from xastropy.atomic import ionization as xai from xastropy.spec import voigt as xsv # all_tau_model = np.zeros(len(wave)) # Loop on LLS for lls in all_lls: # LL wv_rest = wave / (lls.zabs + 1) energy = wv_rest.to(u.eV, equivalencies=u.spectral()) # Get photo_cross and calculate tau tau_LL = (10.**lls.NHI / u.cm**2) * xai.photo_cross(1, 1, energy) # Lyman tau_Lyman = xsv.voigt_model(wave, lls.lls_lines, flg_ret=2) tau_model = tau_LL + tau_Lyman # Kludge around the limit pix_LL = np.argmin(np.fabs(wv_rest - 911.3 * u.AA)) pix_kludge = np.where((wv_rest > 911.5 * u.AA) & (wv_rest < 912.8 * u.AA))[0] tau_model[pix_kludge] = tau_model[pix_LL] # Add all_tau_model += tau_model # Return return all_tau_model
def tau_multi_lls(wave, all_lls): '''Calculate opacities on an input observed wavelength grid Parameters: ----------- wave: Quantity array Wavelengths all_lls: List of LLS Class ''' from xastropy.atomic import ionization as xai from xastropy.spec import voigt as xsv # all_tau_model = np.zeros(len(wave)) # Loop on LLS for lls in all_lls: # LL wv_rest = wave / (lls.zabs+1) energy = wv_rest.to(u.eV, equivalencies=u.spectral()) # Get photo_cross and calculate tau tau_LL = (10.**lls.NHI / u.cm**2) * xai.photo_cross(1,1,energy) # Lyman tau_Lyman = xsv.voigt_model(wave, lls.lls_lines, flg_ret=2) tau_model = tau_LL + tau_Lyman # Kludge around the limit pix_LL = np.argmin( np.fabs( wv_rest- 911.3*u.AA ) ) pix_kludge = np.where( (wv_rest > 911.5*u.AA) & (wv_rest < 912.8*u.AA) )[0] tau_model[pix_kludge] = tau_model[pix_LL] # Add all_tau_model += tau_model # Return return all_tau_model
def update_model(self): '''Update absorption model ''' if len(self.abssys_widg.all_abssys) == 0: self.lls_model = None self.spec_widg.model = None return # all_tau_model = np.zeros(len(self.full_model.flux)) # Loop on LLS for lls in self.abssys_widg.all_abssys: # LL wv_rest = self.full_model.dispersion / (lls.zabs+1) energy = wv_rest.to(u.eV, equivalencies=u.spectral()) # Get photo_cross and calculate tau tau_LL = (10.**lls.NHI / u.cm**2) * xatomi.photo_cross(1,1,energy) # Lyman tau_Lyman = xsv.voigt_model(self.full_model.dispersion, lls.lls_lines, flg_ret=2) tau_model = tau_LL + tau_Lyman # Kludge around the limit pix_LL = np.argmin( np.fabs( wv_rest- 911.3*u.AA ) ) pix_kludge = np.where( (wv_rest > 911.5*u.AA) & (wv_rest < 912.8*u.AA) )[0] tau_model[pix_kludge] = tau_model[pix_LL] # Add all_tau_model += tau_model # Loop on forest lines for forest in self.all_forest: tau_Lyman = xsv.voigt_model(self.full_model.dispersion, forest.lines, flg_ret=2) all_tau_model += tau_Lyman # Flux and smooth flux = np.exp(-1. * all_tau_model) if self.smooth > 0: self.lls_model = lsc.convolve_psf(flux, self.smooth) else: self.lls_model = flux # Finish self.full_model.flux = self.lls_model * self.continuum.flux self.spec_widg.model = self.full_model
def flux_model(self, spec, smooth=0): """ Generate a LLS model given an input spectrum Parameters: spec: Spectrum1D smooth : (0) Number of pixels to smooth by Returns: Output model is passed back as a Spectrum """ reload(xsv) # ######## # LLS first # Energies in LLS rest-frame wv_rest = spec.dispersion / (self.zabs + 1) energy = wv_rest.to(u.eV, equivalencies=u.spectral()) # Get photo_cross and calculate tau tau_LL = (10.**self.NHI / u.cm**2) * xatomi.photo_cross(1, 1, energy) # ######## # Now the Lyman series # Check for lines if 'lls_lines' not in self.__dict__.keys(): self.fill_lls_lines() #xdb.set_trace() tau_Lyman = xsv.voigt_model(spec.dispersion, self.lls_lines, flg_ret=2) # Combine tau_model = tau_LL + tau_Lyman # Kludge around the limit pix_LL = np.argmin(np.fabs(wv_rest - 911.3 * u.AA)) pix_kludge = np.where((wv_rest > 911.5 * u.AA) & (wv_rest < 912.8 * u.AA))[0] tau_model[pix_kludge] = tau_model[pix_LL] # Fill in flux model = copy.deepcopy(spec) model.flux = np.exp(-1. * tau_model).value # Smooth? if smooth > 0: model.gauss_smooth(smooth) # Return return model
def flux_model(self,spec,smooth=0): """ Generate a LLS model given an input spectrum Parameters: spec: Spectrum1D smooth : (0) Number of pixels to smooth by Returns: Output model is passed back as a Spectrum """ reload(xsv) # ######## # LLS first # Energies in LLS rest-frame wv_rest = spec.dispersion / (self.zabs+1) energy = wv_rest.to(u.eV, equivalencies=u.spectral()) # Get photo_cross and calculate tau tau_LL = (10.**self.NHI / u.cm**2) * xatomi.photo_cross(1,1,energy) # ######## # Now the Lyman series # Check for lines if 'lls_lines' not in self.__dict__.keys(): self.fill_lls_lines() #xdb.set_trace() tau_Lyman = xsv.voigt_model(spec.dispersion, self.lls_lines, flg_ret=2) # Combine tau_model = tau_LL + tau_Lyman # Kludge around the limit pix_LL = np.argmin( np.fabs( wv_rest- 911.3*u.AA ) ) pix_kludge = np.where( (wv_rest > 911.5*u.AA) & (wv_rest < 912.8*u.AA) )[0] tau_model[pix_kludge] = tau_model[pix_LL] # Fill in flux model = copy.deepcopy(spec) model.flux = np.exp(-1. * tau_model).value # Smooth? if smooth > 0: model.gauss_smooth(smooth) # Return return model
def update_model(self): if self.parent is None: return all_comp = self.parent.comps_widg.selected_components() if len(all_comp) == 0: self.model.flux[:] = 1. return # Setup lines wvmin = np.min(self.spec.dispersion) wvmax = np.max(self.spec.dispersion) gdlin = [] #QtCore.pyqtRemoveInputHook() #xdb.set_trace() #QtCore.pyqtRestoreInputHook() for comp in all_comp: for line in comp.lines: wvobs = (1+line.attrib['z'])*line.wrest if (wvobs>wvmin) & (wvobs<wvmax): gdlin.append(line) # Voigt self.model = xsv.voigt_model(self.spec.dispersion,gdlin, fwhm=self.fwhm)#,debug=True)
def update_model(self): if self.parent is None: return all_comp = self.parent.comps_widg.selected_components() if len(all_comp) == 0: self.model.flux[:] = 1. return # Setup lines wvmin = np.min(self.spec.dispersion) wvmax = np.max(self.spec.dispersion) gdlin = [] #QtCore.pyqtRemoveInputHook() #xdb.set_trace() #QtCore.pyqtRestoreInputHook() for comp in all_comp: for line in comp.lines: wvobs = (1 + line.attrib['z']) * line.wrest if (wvobs > wvmin) & (wvobs < wvmax): gdlin.append(line) # Voigt self.model = xsv.voigt_model(self.spec.dispersion, gdlin, fwhm=self.fwhm) #,debug=True)