def sio_model(xarr, vcen, width, tex, column, background=None, tbg=2.73): if hasattr(tex, 'unit'): tex = tex.value if hasattr(tbg, 'unit'): tbg = tbg.value if hasattr(column, 'unit'): column = column.value if column < 25: column = 10**column if hasattr(vcen, 'unit'): vcen = vcen.value if hasattr(width, 'unit'): width = width.value if background is not None: tbg = background # assume equal-width channels kwargs = dict(rest=ref_freq) equiv = u.doppler_radio(**kwargs) channelwidth = np.abs(xarr[1].to(u.Hz, equiv) - xarr[0].to(u.Hz, equiv)).value velo = xarr.to(u.km / u.s, equiv).value mol_model = np.zeros_like(xarr).value freqs_ = freqs.to(u.Hz).value Q = m.calculate_partitionfunction(result.data['States'], temperature=tex)[sio.Id] jnu_bg = lte_molecule.Jnu_cgs(xarr.to(u.Hz).value, tbg) bg_model = np.ones_like(xarr).value * jnu_bg for voff, A, g, nu, eu in zip(vdiff, aij, deg, freqs_, EU): tau_per_dnu = lte_molecule.line_tau_cgs(tex, column, Q, g, nu, eu, 10**A) s = np.exp(-(velo - vcen - voff)**2 / (2 * width**2)) * tau_per_dnu / channelwidth jnu_mol = lte_molecule.Jnu_cgs(nu, tex) # the "emission" model is generally zero everywhere, so we can just # add to it as we move along mol_model = mol_model + jnu_mol * (1 - np.exp(-s)) # background is assumed to start as a uniform value, then each # absorption line multiplies to reduce it. s is zero for most velocities, # so this is mostly bg_model *= 1 bg_model *= np.exp(-s) if background: # subtract jnu_bg because we *must* rezero for the case of # having multiple components, otherwise the backgrounds add, # which is nonsense model = bg_model + mol_model - jnu_bg else: model = mol_model return model
def ch3ocho_model(xarr, vcen, width, tex, column, background=None, tbg=2.73): if hasattr(tex,'unit'): tex = tex.value if hasattr(tbg,'unit'): tbg = tbg.value if hasattr(column, 'unit'): column = column.value if column < 25: column = 10**column if hasattr(vcen, 'unit'): vcen = vcen.value if hasattr(width, 'unit'): width = width.value ckms = constants.c.to(u.km/u.s).value # assume equal-width channels #kwargs = dict(rest=ref_freq) #equiv = u.doppler_radio(**kwargs) channelwidth = np.abs(xarr[1].to(u.Hz, ) - xarr[0].to(u.Hz, )).value #velo = xarr.to(u.km/u.s, equiv).value freq = xarr.to(u.Hz).value # same unit as nu below model = np.zeros_like(xarr).value freqs_ = freqs.to(u.Hz).value #Q = specmodel.calculate_partitionfunction(result.data['States'], # temperature=tex)[ch3ocho.Id] Q = (deg * np.exp(-EU*u.erg / (constants.k_B * tex*u.K))).sum() for A, g, nu, eu in zip(aij, deg, freqs_, EU): taudnu = lte_molecule.line_tau_cgs(tex, column, Q, g, nu, eu, 10**A) width_dnu = width / ckms * nu effective_linewidth_dnu = (2 * np.pi)**0.5 * width_dnu fcen = (1 - vcen/ckms) * nu tauspec = (np.exp(-(freq - fcen)**2 / (2 * width_dnu**2)) * taudnu/effective_linewidth_dnu) jnu = (lte_molecule.Jnu_cgs(nu, tex)-lte_molecule.Jnu_cgs(nu, tbg)) model = model + jnu*(1-np.exp(-tauspec)) if background is not None: return background-model return model
def hnco_model(xarr, vcen, width, tex, column, background=None, tbg=2.73): if hasattr(tex,'unit'): tex = tex.value if hasattr(tbg,'unit'): tbg = tbg.value if hasattr(column, 'unit'): column = column.value if column < 25: column = 10**column if hasattr(vcen, 'unit'): vcen = vcen.value if hasattr(width, 'unit'): width = width.value ckms = constants.c.to(u.km/u.s).value # assume equal-width channels #kwargs = dict(rest=ref_freq) #equiv = u.doppler_radio(**kwargs) channelwidth = np.abs(xarr[1].to(u.Hz, ) - xarr[0].to(u.Hz, )).value #velo = xarr.to(u.km/u.s, equiv).value freq = xarr.to(u.Hz).value # same unit as nu below model = np.zeros_like(xarr).value freqs_ = freqs.to(u.Hz).value Q = specmodel.calculate_partitionfunction(result.data['States'], temperature=tex)[hnco.Id] for A, g, nu, eu in zip(aij, deg, freqs_, EU): tau_per_dnu = lte_molecule.line_tau_cgs(tex, column, Q, g, nu, eu, 10**A) width_dnu = width / ckms * nu s = np.exp(-(freq-(1-vcen/ckms)*nu)**2/(2*width_dnu**2))*tau_per_dnu/channelwidth jnu = (lte_molecule.Jnu_cgs(nu, tex)-lte_molecule.Jnu_cgs(nu, tbg)) model = model + jnu*(1-np.exp(-s)) if background is not None: return background-model return model
def ch3cn_model(xarr, vcen, width, tex, column, background=None, tbg=2.73): if hasattr(tex,'unit'): tex = tex.value if hasattr(tbg,'unit'): tbg = tbg.value if hasattr(column, 'unit'): column = column.value if column < 25: column = 10**column if hasattr(vcen, 'unit'): vcen = vcen.value if hasattr(width, 'unit'): width = width.value # assume equal-width channels kwargs = dict(rest=ref_freq) equiv = u.doppler_radio(**kwargs) channelwidth = np.abs(xarr[1].to(u.Hz, equiv) - xarr[0].to(u.Hz, equiv)).value velo = xarr.to(u.km/u.s, equiv).value model = np.zeros_like(xarr).value freqs_ = freqs.to(u.Hz).value Q = m.calculate_partitionfunction(result.data['States'], temperature=tex)[ch3cn.Id] for voff, A, g, nu, eu in zip(vdiff, aij, deg, freqs_, EU): tau_per_dnu = lte_molecule.line_tau_cgs(tex, column, Q, g, nu, eu, 10**A) s = np.exp(-(velo-vcen-voff)**2/(2*width**2))*tau_per_dnu/channelwidth jnu = (lte_molecule.Jnu_cgs(nu, tex)-lte_molecule.Jnu_cgs(nu, tbg)) model = model + jnu*(1-np.exp(-s)) if background is not None: return background-model return model
def hnco_model(xarr, vcen, width, tex, column, background=None, tbg=2.73): if hasattr(tex, "unit"): tex = tex.value if hasattr(tbg, "unit"): tbg = tbg.value if hasattr(column, "unit"): column = column.value if column < 25: column = 10 ** column if hasattr(vcen, "unit"): vcen = vcen.value if hasattr(width, "unit"): width = width.value ckms = constants.c.to(u.km / u.s).value # assume equal-width channels # kwargs = dict(rest=ref_freq) # equiv = u.doppler_radio(**kwargs) channelwidth = np.abs(xarr[1].to(u.Hz) - xarr[0].to(u.Hz)).value # velo = xarr.to(u.km/u.s, equiv).value freq = xarr.to(u.Hz).value # same unit as nu below model = np.zeros_like(xarr).value freqs_ = freqs.to(u.Hz).value Q = specmodel.calculate_partitionfunction(result.data["States"], temperature=tex)[hnco.Id] for A, g, nu, eu in zip(aij, deg, freqs_, EU): tau_per_dnu = lte_molecule.line_tau_cgs(tex, column, Q, g, nu, eu, 10 ** A) width_dnu = width / ckms * nu s = np.exp(-(freq - (1 - vcen / ckms) * nu) ** 2 / (2 * width_dnu ** 2)) * tau_per_dnu / channelwidth jnu = lte_molecule.Jnu_cgs(nu, tex) - lte_molecule.Jnu_cgs(nu, tbg) model = model + jnu * (1 - np.exp(-s)) if background is not None: return background - model return model