Loading etl/mdl/inferred_densities/densities_G14.yml 0 → 100644 +110 −0 Changes for etl/mdl/inferred_densities/densities_G14.yml: 110 added lines, 0 removed lines. Original line number Diff line number Diff line core_ch3oh_01: best_fit: - 5.506012024048096 - 5.30561122244489 uncertainty: - - 5.308457884245733 - 5.620273251828876 - 5.6523476238215125 - 5.737450846560269 - - 5.184603363637183 - 5.466544742185944 core_ch3oh_02: best_fit: - 5.265531062124248 uncertainty: - - 4.9995972435533815 - 5.411495064890987 core_cont_01: best_fit: - 5.435871743486974 uncertainty: - - 5.1971898410349215 - 5.6033053008334335 core_cont_02: best_fit: - 5.556112224448897 - 5.736472945891784 uncertainty: - - 5.439857421990805 - 5.669732075187526 - - 5.60920956508612 - 5.931053408006326 core_cont_03: best_fit: - 5.385771543086172 - 4.894789579158317 uncertainty: - - 5.047777341096332 - 5.533173640295094 - - 4.798984420327147 - 5.007065522568655 - 5.133487678451977 - 5.535203758966563 core_cont_04: best_fit: - 5.195390781563126 uncertainty: - - 5.039545577189866 - 5.421205025902912 core_cont_05: best_fit: - 4.844689378757515 - 5.706412825651302 uncertainty: - - 4.592578842237235 - 4.9544187019263966 - 5.038050767672958 - 5.10421119375137 - - 5.475658082829205 - 5.848914340153295 core_cont_06: best_fit: - 5.385771543086172 uncertainty: - - 5.152335155920468 - 5.635953154672785 core_cont_07: best_fit: - 5.556112224448897 - 5.5360721442885765 uncertainty: - - 5.436818539815753 - 5.696305068121153 - - 4.871722313350981 - 4.9616558189715985 - 5.225169893769645 - 5.6467090697174145 envelope_01: best_fit: - 4.654308617234468 - 4.654308617234468 uncertainty: - - 4.517856530451969 - 4.979020484557805 - - 4.517856530451969 - 4.979020484557805 envelope_02: best_fit: - 5.31563126252505 uncertainty: - - 5.153934404930495 - 5.502378030107496 envelope_03: best_fit: - 4.744488977955912 uncertainty: - - 4.6371981749120925 - 4.8537355939806615 envelope_04: best_fit: - 4.754509018036072 uncertainty: - - 4.599679962969447 - 4.991477313527025 envelope_05: best_fit: - 4.754509018036072 uncertainty: - - 4.646286533612978 - 4.928200210530544 etl/mdl/inferred_densities/densities_G28.yml 0 → 100644 +461 −0 Changes for etl/mdl/inferred_densities/densities_G28.yml: 461 added lines, 0 removed lines. Original line number Diff line number Diff line core_cont_01: best_fit: - 4.724448897795591 uncertainty: - !!python/object/apply:numpy._core.multiarray._reconstruct args: - &id001 !!python/name:numpy.ndarray '' - !!python/tuple - 0 - !!binary | Yg== state: !!python/tuple - 1 - !!python/tuple - 2 - &id002 !!python/object/apply:numpy.dtype args: - f8 - false - true state: !!python/tuple - 3 - < - null - null - null - -1 - -1 - 0 - false - !!binary | eYsUc0Z4EkB9JakZCdgUQA== core_cont_02: best_fit: - 4.68436873747495 uncertainty: - !!python/object/apply:numpy._core.multiarray._reconstruct args: - *id001 - !!python/tuple - 0 - !!binary | Yg== state: !!python/tuple - 1 - !!python/tuple - 2 - *id002 - false - !!binary | 5nXSJMFGEkAymqaA9nAUQA== core_cont_03: best_fit: - 4.744488977955912 uncertainty: - !!python/object/apply:numpy._core.multiarray._reconstruct args: - *id001 - !!python/tuple - 0 - !!binary | Yg== state: !!python/tuple - 1 - !!python/tuple - 2 - *id002 - false - !!binary | fz1vQZKZEkC3TQrc/METQA== core_cont_04: best_fit: - 4.804609218436873 - 4.904809619238477 - 4.934869739478958 uncertainty: - !!python/object/apply:numpy._core.multiarray._reconstruct args: - *id001 - !!python/tuple - 0 - !!binary | Yg== state: !!python/tuple - 1 - !!python/tuple - 4 - *id002 - false - !!binary | lrr0vWKaEkDHVSto1akTQFmrbgIxIBRAFksvBupuFEA= - !!python/object/apply:numpy._core.multiarray._reconstruct args: - *id001 - !!python/tuple - 0 - !!binary | Yg== state: !!python/tuple - 1 - !!python/tuple - 4 - *id002 - false - !!binary | Lq/LBwKDEkBSlZY8nqgSQBbo3H6RzxJA+FORDyAWFEA= - !!python/object/apply:numpy._core.multiarray._reconstruct args: - *id001 - !!python/tuple - 0 - !!binary | Yg== state: !!python/tuple - 1 - !!python/tuple - 2 - *id002 - false - !!binary | 5CLaBuQpE0A9UGcjR2gUQA== core_cont_05: best_fit: - 4.69438877755511 uncertainty: - !!python/object/apply:numpy._core.multiarray._reconstruct args: - *id001 - !!python/tuple - 0 - !!binary | Yg== state: !!python/tuple - 1 - !!python/tuple - 2 - *id002 - false - !!binary | TrsrWmpNEkCHkC1vFnUTQA== core_cont_06: best_fit: - 4.914829659318637 - 5.185370741482966 uncertainty: - !!python/object/apply:numpy._core.multiarray._reconstruct args: - *id001 - !!python/tuple - 0 - !!binary | Yg== state: !!python/tuple - 1 - !!python/tuple - 2 - *id002 - false - !!binary | wDL2qyo6E0CRs1wZPjAUQA== - !!python/object/apply:numpy._core.multiarray._reconstruct args: - *id001 - !!python/tuple - 0 - !!binary | Yg== state: !!python/tuple - 1 - !!python/tuple - 4 - *id002 - false - !!binary | SYJErmhZFECni7n/QgUWQIVmA3/dUhZAlgRCTPw8F0A= core_cont_07: best_fit: - 4.984969939879759 - 4.944889779559118 uncertainty: - !!python/object/apply:numpy._core.multiarray._reconstruct args: - *id001 - !!python/tuple - 0 - !!binary | Yg== state: !!python/tuple - 1 - !!python/tuple - 6 - *id002 - false - !!binary | klDydOaHE0AESvAldFAUQCdUkAFzgRRAglDs1Z15FUBgCLHArcoVQBBPBSsEMBZA - !!python/object/apply:numpy._core.multiarray._reconstruct args: - *id001 - !!python/tuple - 0 - !!binary | Yg== state: !!python/tuple - 1 - !!python/tuple - 2 - *id002 - false - !!binary | nj9xhQdCE0ANgd9GI0QUQA== core_cont_08: best_fit: - 5.185370741482966 - 5.245490981963927 - 4.99498997995992 - 5.445891783567134 uncertainty: - !!python/object/apply:numpy._core.multiarray._reconstruct args: - *id001 - !!python/tuple - 0 - !!binary | Yg== state: !!python/tuple - 1 - !!python/tuple - 2 - *id002 - false - !!binary | Ff5wID4PE0Aqzky5L7sVQA== - !!python/object/apply:numpy._core.multiarray._reconstruct args: - *id001 - !!python/tuple - 0 - !!binary | Yg== state: !!python/tuple - 1 - !!python/tuple - 4 - *id002 - false - !!binary | JQbjkqlME0BHoz7GtPITQE9SO+4fNhRA6E/zYzLdFUA= - !!python/object/apply:numpy._core.multiarray._reconstruct args: - *id001 - !!python/tuple - 0 - !!binary | Yg== state: !!python/tuple - 1 - !!python/tuple - 2 - *id002 - false - !!binary | BVnGt5V1E0Cd9cItbeIUQA== - !!python/object/apply:numpy._core.multiarray._reconstruct args: - *id001 - !!python/tuple - 0 - !!binary | Yg== state: !!python/tuple - 1 - !!python/tuple - 4 - *id002 - false - !!binary | UkrClOzbFECNlQv+0xYXQGnKbRkzqRdABlZUmhM5GEA= envelope_01: best_fit: - 4.674348697394789 uncertainty: - !!python/object/apply:numpy._core.multiarray._reconstruct args: - *id001 - !!python/tuple - 0 - !!binary | Yg== state: !!python/tuple - 1 - !!python/tuple - 2 - *id002 - false - !!binary | kKLTqzlDEkDhlqdZDEwUQA== envelope_02: best_fit: - 4.674348697394789 uncertainty: - !!python/object/apply:numpy._core.multiarray._reconstruct args: - *id001 - !!python/tuple - 0 - !!binary | Yg== state: !!python/tuple - 1 - !!python/tuple - 2 - *id002 - false - !!binary | BhqW2Bc/EkDb+4Li7+kTQA== envelope_03: best_fit: - 4.854709418837675 uncertainty: - !!python/object/apply:numpy._core.multiarray._reconstruct args: - *id001 - !!python/tuple - 0 - !!binary | Yg== state: !!python/tuple - 1 - !!python/tuple - 4 - *id002 - false - !!binary | k/Qz2/0AE0BK9CPCfuYTQEO3YR+YKxRAfn2KSyzUFEA= envelope_04: best_fit: - 4.734468937875752 uncertainty: - !!python/object/apply:numpy._core.multiarray._reconstruct args: - *id001 - !!python/tuple - 0 - !!binary | Yg== state: !!python/tuple - 1 - !!python/tuple - 2 - *id002 - false - !!binary | oYECqNluEkCQn231BS4UQA== envelope_05: best_fit: - 4.744488977955912 uncertainty: - !!python/object/apply:numpy._core.multiarray._reconstruct args: - *id001 - !!python/tuple - 0 - !!binary | Yg== state: !!python/tuple - 1 - !!python/tuple - 2 - *id002 - false - !!binary | Yyj0nap1EkC9UUkkLAwUQA== envelope_06: best_fit: - 4.714428857715431 uncertainty: - !!python/object/apply:numpy._core.multiarray._reconstruct args: - *id001 - !!python/tuple - 0 - !!binary | Yg== state: !!python/tuple - 1 - !!python/tuple - 6 - *id002 - false - !!binary | OFmHV/sLEkBV3CPvACASQHeZ8fEvJRJAwNHz5vU+EkDKhPTlo0MSQLl31QvtmRNA envelope_07: best_fit: - 4.69438877755511 - 5.365731462925852 - 5.215430861723447 uncertainty: - !!python/object/apply:numpy._core.multiarray._reconstruct args: - *id001 - !!python/tuple - 0 - !!binary | Yg== state: !!python/tuple - 1 - !!python/tuple - 2 - *id002 - false - !!binary | LWC9cVF1EkB3ukZ4d48UQA== - !!python/object/apply:numpy._core.multiarray._reconstruct args: - *id001 - !!python/tuple - 0 - !!binary | Yg== state: !!python/tuple - 1 - !!python/tuple - 2 - *id002 - false - !!binary | Kg090FufFEDb1vTxaoQWQA== - !!python/object/apply:numpy._core.multiarray._reconstruct args: - *id001 - !!python/tuple - 0 - !!binary | Yg== state: !!python/tuple - 1 - !!python/tuple - 2 - *id002 - false - !!binary | fGWDNhsAFEBd4YioY10VQA== envelope_core_01: best_fit: - 4.934869739478958 uncertainty: - !!python/object/apply:numpy._core.multiarray._reconstruct args: - *id001 - !!python/tuple - 0 - !!binary | Yg== state: !!python/tuple - 1 - !!python/tuple - 4 - *id002 - false - !!binary | Ky603wovE0AdzWWSYkwUQGKhazdYjRRAEt8Ao9uMFUA= etl/mdl/inferred_densities/densities_G332.96.yml 0 → 100644 +245 −0 Changes for etl/mdl/inferred_densities/densities_G332.96.yml: 245 added lines, 0 removed lines. Original line number Diff line number Diff line core_cont_01: best_fit: - 4.774549098196393 uncertainty: - !!python/object/apply:numpy._core.multiarray._reconstruct args: - &id001 !!python/name:numpy.ndarray '' - !!python/tuple - 0 - !!binary | Yg== state: !!python/tuple - 1 - !!python/tuple - 2 - &id002 !!python/object/apply:numpy.dtype args: - f8 - false - true state: !!python/tuple - 3 - < - null - null - null - -1 - -1 - 0 - false - !!binary | 2/XSZL+yEkAC5y+BqzQVQA== core_cont_02: best_fit: - 4.874749498997996 uncertainty: - !!python/object/apply:numpy._core.multiarray._reconstruct args: - *id001 - !!python/tuple - 0 - !!binary | Yg== state: !!python/tuple - 1 - !!python/tuple - 2 - *id002 - false - !!binary | W6M4TaonEkC67t6DteETQA== core_cont_03: best_fit: - 4.764529058116232 uncertainty: - !!python/object/apply:numpy._core.multiarray._reconstruct args: - *id001 - !!python/tuple - 0 - !!binary | Yg== state: !!python/tuple - 1 - !!python/tuple - 2 - *id002 - false - !!binary | HU6Y/AB+EkAlX2G33OUTQA== envelope_01: best_fit: - 4.724448897795591 - 4.724448897795591 uncertainty: - !!python/object/apply:numpy._core.multiarray._reconstruct args: - *id001 - !!python/tuple - 0 - !!binary | Yg== state: !!python/tuple - 1 - !!python/tuple - 2 - *id002 - false - !!binary | T9/WWT15EkCNDaZXOLIUQA== - !!python/object/apply:numpy._core.multiarray._reconstruct args: - *id001 - !!python/tuple - 0 - !!binary | Yg== state: !!python/tuple - 1 - !!python/tuple - 2 - *id002 - false - !!binary | T9/WWT15EkCNDaZXOLIUQA== envelope_02: best_fit: - 4.924849699398798 - 4.924849699398798 - 4.924849699398798 uncertainty: - !!python/object/apply:numpy._core.multiarray._reconstruct args: - *id001 - !!python/tuple - 0 - !!binary | Yg== state: !!python/tuple - 1 - !!python/tuple - 2 - *id002 - false - !!binary | ojET3L8qE0D+vQhh+u0UQA== - !!python/object/apply:numpy._core.multiarray._reconstruct args: - *id001 - !!python/tuple - 0 - !!binary | Yg== state: !!python/tuple - 1 - !!python/tuple - 2 - *id002 - false - !!binary | ojET3L8qE0D+vQhh+u0UQA== - !!python/object/apply:numpy._core.multiarray._reconstruct args: - *id001 - !!python/tuple - 0 - !!binary | Yg== state: !!python/tuple - 1 - !!python/tuple - 2 - *id002 - false - !!binary | ojET3L8qE0D+vQhh+u0UQA== envelope_03: best_fit: - 4.9649298597194385 uncertainty: - !!python/object/apply:numpy._core.multiarray._reconstruct args: - *id001 - !!python/tuple - 0 - !!binary | Yg== state: !!python/tuple - 1 - !!python/tuple - 4 - *id002 - false - !!binary | q19PcBNzE0BN9OALlzAUQMEckJIOwRRAvnYAqCzOFUA= envelope_04: best_fit: - 5.00501002004008 uncertainty: - !!python/object/apply:numpy._core.multiarray._reconstruct args: - *id001 - !!python/tuple - 0 - !!binary | Yg== state: !!python/tuple - 1 - !!python/tuple - 2 - *id002 - false - !!binary | 5OYqbU2AE0CTEAJL2t0UQA== envelope_05_global: best_fit: - 4.654308617234468 - 4.654308617234468 - 4.654308617234468 uncertainty: - !!python/object/apply:numpy._core.multiarray._reconstruct args: - *id001 - !!python/tuple - 0 - !!binary | Yg== state: !!python/tuple - 1 - !!python/tuple - 2 - *id002 - false - !!binary | WdFFgz4mEkDSdiNnaYoTQA== - !!python/object/apply:numpy._core.multiarray._reconstruct args: - *id001 - !!python/tuple - 0 - !!binary | Yg== state: !!python/tuple - 1 - !!python/tuple - 2 - *id002 - false - !!binary | WdFFgz4mEkDSdiNnaYoTQA== - !!python/object/apply:numpy._core.multiarray._reconstruct args: - *id001 - !!python/tuple - 0 - !!binary | Yg== state: !!python/tuple - 1 - !!python/tuple - 2 - *id002 - false - !!binary | WdFFgz4mEkDSdiNnaYoTQA== etl/mdl/mdl_extract_ch3oh_spectra.py +39 −8 Changes for etl/mdl/mdl_extract_ch3oh_spectra.py: 39 added lines, 8 removed lines. Original line number Diff line number Diff line Loading @@ -4,6 +4,7 @@ import matplotlib import matplotlib.pyplot as plt import numpy as np from sklearn.neighbors import KernelDensity from scipy.integrate import cumulative_trapezoid from astropy import units as u from astropy.io import fits from astropy.wcs import WCS Loading Loading @@ -43,6 +44,30 @@ def filter_dict_by_key(d, key_root): return {k: v for k, v in d.items() if k.startswith(key_root)} def find_zeros(x, y): """ Finds the zeros of a discretely sampled function using linear interpolation. Parameters: x (array-like): The x-values of the sampled function. y (array-like): The y-values of the sampled function. Returns: np.ndarray: The estimated x-values where the function crosses zero. """ x = np.asarray(x) y = np.asarray(y) zeros = [] for i in range(len(y) - 1): if y[i] * y[i + 1] < 0: # Sign change indicates a zero crossing # Linear interpolation formula: x_zero = x1 - y1 * (x2 - x1) / (y2 - y1) x_zero = x[i] - y[i] * (x[i + 1] - x[i]) / (y[i + 1] - y[i]) zeros.append(float(x_zero)) return zeros sources = ['G14', 'G28', 'G332.96'] species = 'CH3OH' samples = 100 Loading @@ -62,12 +87,12 @@ def compute_density_pdf(density, density_axis=None): _density = density[~np.isnan(density)] kde.fit(np.log10(_density).reshape(-1, 1)) pdf = np.exp(kde.score_samples(list(_density_axis.reshape(-1, 1)))) norm = np.trapz(pdf, _density_axis) norm = np.trapezoid(pdf, _density_axis) return _density_axis, pdf / norm for source in sources: moment_map = fits.open(f'moment_zero_{source}_{species}.fits')[0] moment_map = fits.open(os.path.join('prs', 'figures', 'moments', f'moment_zero_{source}_{species}.fits'))[0] wcs = WCS(moment_map.header) vlsr = source_properties[source]['vlsr'] * u.km / u.s rms = source_properties[source][species]['rms'] Loading Loading @@ -115,7 +140,7 @@ for source in sources: line_guesses = [] tied = [] densities[region] = [] densities[region] = {'best_fit': [], 'uncertainty': []} fwhms[region] = [] for component in range(components): idx_shift = component * pars_per_component Loading Loading @@ -187,10 +212,13 @@ for source in sources: density_axis, pdf = compute_density_pdf(density) density_pdfs[ratio_string] = {'density': density_axis, 'pdf': pdf} final_density_pdf = density_pdfs['87-86']['pdf'] * density_pdfs['88-86']['pdf'] norm = np.trapz(final_density_pdf, density_axis) norm = np.trapezoid(final_density_pdf, density_axis) final_density_pdf /= norm probability_mass = cumulative_trapezoid(final_density_pdf, density_axis) if fwhm.value < 5: densities[region].append(density_axis[np.argmax(final_density_pdf)]) hpd = find_zeros(density_axis, final_density_pdf - 0.67) densities[region]['best_fit'].append(float(density_axis[np.argmax(final_density_pdf)])) densities[region]['uncertainty'].append(hpd) fwhms[region].append(fwhm.value) # plt.clf() Loading Loading @@ -242,11 +270,14 @@ for source in sources: for region in regions[source]: if not region.startswith('core_ch3oh'): color = 'blue' if region.startswith('core') else 'cyan' max_idx = np.argmax(densities[region]) plt.scatter(densities[region], fwhms[region], label=region, edgecolors=color) max_idx = np.argmax(densities[region]['best_fit']) plt.scatter(densities[region]['best_fit'], fwhms[region], label=region, edgecolors=color) plt.legend() plt.savefig(os.path.join(plotdir, f'aperture_spectra_extraction_density_FWHM_{source}_{species}.svg')) with open(os.path.join('mdl', 'inferred_densities', f'densities_{source}.yml'), 'w') as outfile: yaml.dump(densities, outfile, default_flow_style=False) region_types = ['envelope', 'core'] for rtype in region_types: Loading @@ -262,7 +293,7 @@ for source in sources: patch = Circle(regions_to_plot[reg][0:2], regions_to_plot[reg][2], edgecolor='black', facecolor='none', zorder=10) patches.append(patch) density_values.append(np.max(densities[reg])) density_values.append(np.max(densities[reg]['best_fit'])) pc = PatchCollection(patches, cmap=matplotlib.cm.hot, zorder=10) pc.set_array(density_values) pc.set_facecolor('none') Loading etl/prs/prs_mom0_dust.py +1 −1 Changes for etl/prs/prs_mom0_dust.py: 1 added line, 1 removed line. Original line number Diff line number Diff line Loading @@ -72,7 +72,7 @@ for species in ['N2H+', 'CH3OH']: moment_zero_header['BUNIT'] = 'K km s-1' moment_zero_header['BTYPE'] = 'MOMENT0' fits.writeto(f'moment_zero_{source}_{species}.fits', data=moment_zero.value, header=moment_zero_header, overwrite=True) fits.writeto(os.path.join('prs', 'figures', 'moments',f'moment_zero_{source}_{species}.fits'), data=moment_zero.value, header=moment_zero_header, overwrite=True) hdu_cont = fits.open(os.path.join(datadir, continuum_fits[source]))[0] continuum_data = np.where(hdu_cont.data >= 2.5e-4, hdu_cont.data, np.nan) Loading Loading
etl/mdl/inferred_densities/densities_G14.yml 0 → 100644 +110 −0 Changes for etl/mdl/inferred_densities/densities_G14.yml: 110 added lines, 0 removed lines. Original line number Diff line number Diff line core_ch3oh_01: best_fit: - 5.506012024048096 - 5.30561122244489 uncertainty: - - 5.308457884245733 - 5.620273251828876 - 5.6523476238215125 - 5.737450846560269 - - 5.184603363637183 - 5.466544742185944 core_ch3oh_02: best_fit: - 5.265531062124248 uncertainty: - - 4.9995972435533815 - 5.411495064890987 core_cont_01: best_fit: - 5.435871743486974 uncertainty: - - 5.1971898410349215 - 5.6033053008334335 core_cont_02: best_fit: - 5.556112224448897 - 5.736472945891784 uncertainty: - - 5.439857421990805 - 5.669732075187526 - - 5.60920956508612 - 5.931053408006326 core_cont_03: best_fit: - 5.385771543086172 - 4.894789579158317 uncertainty: - - 5.047777341096332 - 5.533173640295094 - - 4.798984420327147 - 5.007065522568655 - 5.133487678451977 - 5.535203758966563 core_cont_04: best_fit: - 5.195390781563126 uncertainty: - - 5.039545577189866 - 5.421205025902912 core_cont_05: best_fit: - 4.844689378757515 - 5.706412825651302 uncertainty: - - 4.592578842237235 - 4.9544187019263966 - 5.038050767672958 - 5.10421119375137 - - 5.475658082829205 - 5.848914340153295 core_cont_06: best_fit: - 5.385771543086172 uncertainty: - - 5.152335155920468 - 5.635953154672785 core_cont_07: best_fit: - 5.556112224448897 - 5.5360721442885765 uncertainty: - - 5.436818539815753 - 5.696305068121153 - - 4.871722313350981 - 4.9616558189715985 - 5.225169893769645 - 5.6467090697174145 envelope_01: best_fit: - 4.654308617234468 - 4.654308617234468 uncertainty: - - 4.517856530451969 - 4.979020484557805 - - 4.517856530451969 - 4.979020484557805 envelope_02: best_fit: - 5.31563126252505 uncertainty: - - 5.153934404930495 - 5.502378030107496 envelope_03: best_fit: - 4.744488977955912 uncertainty: - - 4.6371981749120925 - 4.8537355939806615 envelope_04: best_fit: - 4.754509018036072 uncertainty: - - 4.599679962969447 - 4.991477313527025 envelope_05: best_fit: - 4.754509018036072 uncertainty: - - 4.646286533612978 - 4.928200210530544
etl/mdl/inferred_densities/densities_G28.yml 0 → 100644 +461 −0 Changes for etl/mdl/inferred_densities/densities_G28.yml: 461 added lines, 0 removed lines. Original line number Diff line number Diff line core_cont_01: best_fit: - 4.724448897795591 uncertainty: - !!python/object/apply:numpy._core.multiarray._reconstruct args: - &id001 !!python/name:numpy.ndarray '' - !!python/tuple - 0 - !!binary | Yg== state: !!python/tuple - 1 - !!python/tuple - 2 - &id002 !!python/object/apply:numpy.dtype args: - f8 - false - true state: !!python/tuple - 3 - < - null - null - null - -1 - -1 - 0 - false - !!binary | eYsUc0Z4EkB9JakZCdgUQA== core_cont_02: best_fit: - 4.68436873747495 uncertainty: - !!python/object/apply:numpy._core.multiarray._reconstruct args: - *id001 - !!python/tuple - 0 - !!binary | Yg== state: !!python/tuple - 1 - !!python/tuple - 2 - *id002 - false - !!binary | 5nXSJMFGEkAymqaA9nAUQA== core_cont_03: best_fit: - 4.744488977955912 uncertainty: - !!python/object/apply:numpy._core.multiarray._reconstruct args: - *id001 - !!python/tuple - 0 - !!binary | Yg== state: !!python/tuple - 1 - !!python/tuple - 2 - *id002 - false - !!binary | fz1vQZKZEkC3TQrc/METQA== core_cont_04: best_fit: - 4.804609218436873 - 4.904809619238477 - 4.934869739478958 uncertainty: - !!python/object/apply:numpy._core.multiarray._reconstruct args: - *id001 - !!python/tuple - 0 - !!binary | Yg== state: !!python/tuple - 1 - !!python/tuple - 4 - *id002 - false - !!binary | lrr0vWKaEkDHVSto1akTQFmrbgIxIBRAFksvBupuFEA= - !!python/object/apply:numpy._core.multiarray._reconstruct args: - *id001 - !!python/tuple - 0 - !!binary | Yg== state: !!python/tuple - 1 - !!python/tuple - 4 - *id002 - false - !!binary | Lq/LBwKDEkBSlZY8nqgSQBbo3H6RzxJA+FORDyAWFEA= - !!python/object/apply:numpy._core.multiarray._reconstruct args: - *id001 - !!python/tuple - 0 - !!binary | Yg== state: !!python/tuple - 1 - !!python/tuple - 2 - *id002 - false - !!binary | 5CLaBuQpE0A9UGcjR2gUQA== core_cont_05: best_fit: - 4.69438877755511 uncertainty: - !!python/object/apply:numpy._core.multiarray._reconstruct args: - *id001 - !!python/tuple - 0 - !!binary | Yg== state: !!python/tuple - 1 - !!python/tuple - 2 - *id002 - false - !!binary | TrsrWmpNEkCHkC1vFnUTQA== core_cont_06: best_fit: - 4.914829659318637 - 5.185370741482966 uncertainty: - !!python/object/apply:numpy._core.multiarray._reconstruct args: - *id001 - !!python/tuple - 0 - !!binary | Yg== state: !!python/tuple - 1 - !!python/tuple - 2 - *id002 - false - !!binary | wDL2qyo6E0CRs1wZPjAUQA== - !!python/object/apply:numpy._core.multiarray._reconstruct args: - *id001 - !!python/tuple - 0 - !!binary | Yg== state: !!python/tuple - 1 - !!python/tuple - 4 - *id002 - false - !!binary | SYJErmhZFECni7n/QgUWQIVmA3/dUhZAlgRCTPw8F0A= core_cont_07: best_fit: - 4.984969939879759 - 4.944889779559118 uncertainty: - !!python/object/apply:numpy._core.multiarray._reconstruct args: - *id001 - !!python/tuple - 0 - !!binary | Yg== state: !!python/tuple - 1 - !!python/tuple - 6 - *id002 - false - !!binary | klDydOaHE0AESvAldFAUQCdUkAFzgRRAglDs1Z15FUBgCLHArcoVQBBPBSsEMBZA - !!python/object/apply:numpy._core.multiarray._reconstruct args: - *id001 - !!python/tuple - 0 - !!binary | Yg== state: !!python/tuple - 1 - !!python/tuple - 2 - *id002 - false - !!binary | nj9xhQdCE0ANgd9GI0QUQA== core_cont_08: best_fit: - 5.185370741482966 - 5.245490981963927 - 4.99498997995992 - 5.445891783567134 uncertainty: - !!python/object/apply:numpy._core.multiarray._reconstruct args: - *id001 - !!python/tuple - 0 - !!binary | Yg== state: !!python/tuple - 1 - !!python/tuple - 2 - *id002 - false - !!binary | Ff5wID4PE0Aqzky5L7sVQA== - !!python/object/apply:numpy._core.multiarray._reconstruct args: - *id001 - !!python/tuple - 0 - !!binary | Yg== state: !!python/tuple - 1 - !!python/tuple - 4 - *id002 - false - !!binary | JQbjkqlME0BHoz7GtPITQE9SO+4fNhRA6E/zYzLdFUA= - !!python/object/apply:numpy._core.multiarray._reconstruct args: - *id001 - !!python/tuple - 0 - !!binary | Yg== state: !!python/tuple - 1 - !!python/tuple - 2 - *id002 - false - !!binary | BVnGt5V1E0Cd9cItbeIUQA== - !!python/object/apply:numpy._core.multiarray._reconstruct args: - *id001 - !!python/tuple - 0 - !!binary | Yg== state: !!python/tuple - 1 - !!python/tuple - 4 - *id002 - false - !!binary | UkrClOzbFECNlQv+0xYXQGnKbRkzqRdABlZUmhM5GEA= envelope_01: best_fit: - 4.674348697394789 uncertainty: - !!python/object/apply:numpy._core.multiarray._reconstruct args: - *id001 - !!python/tuple - 0 - !!binary | Yg== state: !!python/tuple - 1 - !!python/tuple - 2 - *id002 - false - !!binary | kKLTqzlDEkDhlqdZDEwUQA== envelope_02: best_fit: - 4.674348697394789 uncertainty: - !!python/object/apply:numpy._core.multiarray._reconstruct args: - *id001 - !!python/tuple - 0 - !!binary | Yg== state: !!python/tuple - 1 - !!python/tuple - 2 - *id002 - false - !!binary | BhqW2Bc/EkDb+4Li7+kTQA== envelope_03: best_fit: - 4.854709418837675 uncertainty: - !!python/object/apply:numpy._core.multiarray._reconstruct args: - *id001 - !!python/tuple - 0 - !!binary | Yg== state: !!python/tuple - 1 - !!python/tuple - 4 - *id002 - false - !!binary | k/Qz2/0AE0BK9CPCfuYTQEO3YR+YKxRAfn2KSyzUFEA= envelope_04: best_fit: - 4.734468937875752 uncertainty: - !!python/object/apply:numpy._core.multiarray._reconstruct args: - *id001 - !!python/tuple - 0 - !!binary | Yg== state: !!python/tuple - 1 - !!python/tuple - 2 - *id002 - false - !!binary | oYECqNluEkCQn231BS4UQA== envelope_05: best_fit: - 4.744488977955912 uncertainty: - !!python/object/apply:numpy._core.multiarray._reconstruct args: - *id001 - !!python/tuple - 0 - !!binary | Yg== state: !!python/tuple - 1 - !!python/tuple - 2 - *id002 - false - !!binary | Yyj0nap1EkC9UUkkLAwUQA== envelope_06: best_fit: - 4.714428857715431 uncertainty: - !!python/object/apply:numpy._core.multiarray._reconstruct args: - *id001 - !!python/tuple - 0 - !!binary | Yg== state: !!python/tuple - 1 - !!python/tuple - 6 - *id002 - false - !!binary | OFmHV/sLEkBV3CPvACASQHeZ8fEvJRJAwNHz5vU+EkDKhPTlo0MSQLl31QvtmRNA envelope_07: best_fit: - 4.69438877755511 - 5.365731462925852 - 5.215430861723447 uncertainty: - !!python/object/apply:numpy._core.multiarray._reconstruct args: - *id001 - !!python/tuple - 0 - !!binary | Yg== state: !!python/tuple - 1 - !!python/tuple - 2 - *id002 - false - !!binary | LWC9cVF1EkB3ukZ4d48UQA== - !!python/object/apply:numpy._core.multiarray._reconstruct args: - *id001 - !!python/tuple - 0 - !!binary | Yg== state: !!python/tuple - 1 - !!python/tuple - 2 - *id002 - false - !!binary | Kg090FufFEDb1vTxaoQWQA== - !!python/object/apply:numpy._core.multiarray._reconstruct args: - *id001 - !!python/tuple - 0 - !!binary | Yg== state: !!python/tuple - 1 - !!python/tuple - 2 - *id002 - false - !!binary | fGWDNhsAFEBd4YioY10VQA== envelope_core_01: best_fit: - 4.934869739478958 uncertainty: - !!python/object/apply:numpy._core.multiarray._reconstruct args: - *id001 - !!python/tuple - 0 - !!binary | Yg== state: !!python/tuple - 1 - !!python/tuple - 4 - *id002 - false - !!binary | Ky603wovE0AdzWWSYkwUQGKhazdYjRRAEt8Ao9uMFUA=
etl/mdl/inferred_densities/densities_G332.96.yml 0 → 100644 +245 −0 Changes for etl/mdl/inferred_densities/densities_G332.96.yml: 245 added lines, 0 removed lines. Original line number Diff line number Diff line core_cont_01: best_fit: - 4.774549098196393 uncertainty: - !!python/object/apply:numpy._core.multiarray._reconstruct args: - &id001 !!python/name:numpy.ndarray '' - !!python/tuple - 0 - !!binary | Yg== state: !!python/tuple - 1 - !!python/tuple - 2 - &id002 !!python/object/apply:numpy.dtype args: - f8 - false - true state: !!python/tuple - 3 - < - null - null - null - -1 - -1 - 0 - false - !!binary | 2/XSZL+yEkAC5y+BqzQVQA== core_cont_02: best_fit: - 4.874749498997996 uncertainty: - !!python/object/apply:numpy._core.multiarray._reconstruct args: - *id001 - !!python/tuple - 0 - !!binary | Yg== state: !!python/tuple - 1 - !!python/tuple - 2 - *id002 - false - !!binary | W6M4TaonEkC67t6DteETQA== core_cont_03: best_fit: - 4.764529058116232 uncertainty: - !!python/object/apply:numpy._core.multiarray._reconstruct args: - *id001 - !!python/tuple - 0 - !!binary | Yg== state: !!python/tuple - 1 - !!python/tuple - 2 - *id002 - false - !!binary | HU6Y/AB+EkAlX2G33OUTQA== envelope_01: best_fit: - 4.724448897795591 - 4.724448897795591 uncertainty: - !!python/object/apply:numpy._core.multiarray._reconstruct args: - *id001 - !!python/tuple - 0 - !!binary | Yg== state: !!python/tuple - 1 - !!python/tuple - 2 - *id002 - false - !!binary | T9/WWT15EkCNDaZXOLIUQA== - !!python/object/apply:numpy._core.multiarray._reconstruct args: - *id001 - !!python/tuple - 0 - !!binary | Yg== state: !!python/tuple - 1 - !!python/tuple - 2 - *id002 - false - !!binary | T9/WWT15EkCNDaZXOLIUQA== envelope_02: best_fit: - 4.924849699398798 - 4.924849699398798 - 4.924849699398798 uncertainty: - !!python/object/apply:numpy._core.multiarray._reconstruct args: - *id001 - !!python/tuple - 0 - !!binary | Yg== state: !!python/tuple - 1 - !!python/tuple - 2 - *id002 - false - !!binary | ojET3L8qE0D+vQhh+u0UQA== - !!python/object/apply:numpy._core.multiarray._reconstruct args: - *id001 - !!python/tuple - 0 - !!binary | Yg== state: !!python/tuple - 1 - !!python/tuple - 2 - *id002 - false - !!binary | ojET3L8qE0D+vQhh+u0UQA== - !!python/object/apply:numpy._core.multiarray._reconstruct args: - *id001 - !!python/tuple - 0 - !!binary | Yg== state: !!python/tuple - 1 - !!python/tuple - 2 - *id002 - false - !!binary | ojET3L8qE0D+vQhh+u0UQA== envelope_03: best_fit: - 4.9649298597194385 uncertainty: - !!python/object/apply:numpy._core.multiarray._reconstruct args: - *id001 - !!python/tuple - 0 - !!binary | Yg== state: !!python/tuple - 1 - !!python/tuple - 4 - *id002 - false - !!binary | q19PcBNzE0BN9OALlzAUQMEckJIOwRRAvnYAqCzOFUA= envelope_04: best_fit: - 5.00501002004008 uncertainty: - !!python/object/apply:numpy._core.multiarray._reconstruct args: - *id001 - !!python/tuple - 0 - !!binary | Yg== state: !!python/tuple - 1 - !!python/tuple - 2 - *id002 - false - !!binary | 5OYqbU2AE0CTEAJL2t0UQA== envelope_05_global: best_fit: - 4.654308617234468 - 4.654308617234468 - 4.654308617234468 uncertainty: - !!python/object/apply:numpy._core.multiarray._reconstruct args: - *id001 - !!python/tuple - 0 - !!binary | Yg== state: !!python/tuple - 1 - !!python/tuple - 2 - *id002 - false - !!binary | WdFFgz4mEkDSdiNnaYoTQA== - !!python/object/apply:numpy._core.multiarray._reconstruct args: - *id001 - !!python/tuple - 0 - !!binary | Yg== state: !!python/tuple - 1 - !!python/tuple - 2 - *id002 - false - !!binary | WdFFgz4mEkDSdiNnaYoTQA== - !!python/object/apply:numpy._core.multiarray._reconstruct args: - *id001 - !!python/tuple - 0 - !!binary | Yg== state: !!python/tuple - 1 - !!python/tuple - 2 - *id002 - false - !!binary | WdFFgz4mEkDSdiNnaYoTQA==
etl/mdl/mdl_extract_ch3oh_spectra.py +39 −8 Changes for etl/mdl/mdl_extract_ch3oh_spectra.py: 39 added lines, 8 removed lines. Original line number Diff line number Diff line Loading @@ -4,6 +4,7 @@ import matplotlib import matplotlib.pyplot as plt import numpy as np from sklearn.neighbors import KernelDensity from scipy.integrate import cumulative_trapezoid from astropy import units as u from astropy.io import fits from astropy.wcs import WCS Loading Loading @@ -43,6 +44,30 @@ def filter_dict_by_key(d, key_root): return {k: v for k, v in d.items() if k.startswith(key_root)} def find_zeros(x, y): """ Finds the zeros of a discretely sampled function using linear interpolation. Parameters: x (array-like): The x-values of the sampled function. y (array-like): The y-values of the sampled function. Returns: np.ndarray: The estimated x-values where the function crosses zero. """ x = np.asarray(x) y = np.asarray(y) zeros = [] for i in range(len(y) - 1): if y[i] * y[i + 1] < 0: # Sign change indicates a zero crossing # Linear interpolation formula: x_zero = x1 - y1 * (x2 - x1) / (y2 - y1) x_zero = x[i] - y[i] * (x[i + 1] - x[i]) / (y[i + 1] - y[i]) zeros.append(float(x_zero)) return zeros sources = ['G14', 'G28', 'G332.96'] species = 'CH3OH' samples = 100 Loading @@ -62,12 +87,12 @@ def compute_density_pdf(density, density_axis=None): _density = density[~np.isnan(density)] kde.fit(np.log10(_density).reshape(-1, 1)) pdf = np.exp(kde.score_samples(list(_density_axis.reshape(-1, 1)))) norm = np.trapz(pdf, _density_axis) norm = np.trapezoid(pdf, _density_axis) return _density_axis, pdf / norm for source in sources: moment_map = fits.open(f'moment_zero_{source}_{species}.fits')[0] moment_map = fits.open(os.path.join('prs', 'figures', 'moments', f'moment_zero_{source}_{species}.fits'))[0] wcs = WCS(moment_map.header) vlsr = source_properties[source]['vlsr'] * u.km / u.s rms = source_properties[source][species]['rms'] Loading Loading @@ -115,7 +140,7 @@ for source in sources: line_guesses = [] tied = [] densities[region] = [] densities[region] = {'best_fit': [], 'uncertainty': []} fwhms[region] = [] for component in range(components): idx_shift = component * pars_per_component Loading Loading @@ -187,10 +212,13 @@ for source in sources: density_axis, pdf = compute_density_pdf(density) density_pdfs[ratio_string] = {'density': density_axis, 'pdf': pdf} final_density_pdf = density_pdfs['87-86']['pdf'] * density_pdfs['88-86']['pdf'] norm = np.trapz(final_density_pdf, density_axis) norm = np.trapezoid(final_density_pdf, density_axis) final_density_pdf /= norm probability_mass = cumulative_trapezoid(final_density_pdf, density_axis) if fwhm.value < 5: densities[region].append(density_axis[np.argmax(final_density_pdf)]) hpd = find_zeros(density_axis, final_density_pdf - 0.67) densities[region]['best_fit'].append(float(density_axis[np.argmax(final_density_pdf)])) densities[region]['uncertainty'].append(hpd) fwhms[region].append(fwhm.value) # plt.clf() Loading Loading @@ -242,11 +270,14 @@ for source in sources: for region in regions[source]: if not region.startswith('core_ch3oh'): color = 'blue' if region.startswith('core') else 'cyan' max_idx = np.argmax(densities[region]) plt.scatter(densities[region], fwhms[region], label=region, edgecolors=color) max_idx = np.argmax(densities[region]['best_fit']) plt.scatter(densities[region]['best_fit'], fwhms[region], label=region, edgecolors=color) plt.legend() plt.savefig(os.path.join(plotdir, f'aperture_spectra_extraction_density_FWHM_{source}_{species}.svg')) with open(os.path.join('mdl', 'inferred_densities', f'densities_{source}.yml'), 'w') as outfile: yaml.dump(densities, outfile, default_flow_style=False) region_types = ['envelope', 'core'] for rtype in region_types: Loading @@ -262,7 +293,7 @@ for source in sources: patch = Circle(regions_to_plot[reg][0:2], regions_to_plot[reg][2], edgecolor='black', facecolor='none', zorder=10) patches.append(patch) density_values.append(np.max(densities[reg])) density_values.append(np.max(densities[reg]['best_fit'])) pc = PatchCollection(patches, cmap=matplotlib.cm.hot, zorder=10) pc.set_array(density_values) pc.set_facecolor('none') Loading
etl/prs/prs_mom0_dust.py +1 −1 Changes for etl/prs/prs_mom0_dust.py: 1 added line, 1 removed line. Original line number Diff line number Diff line Loading @@ -72,7 +72,7 @@ for species in ['N2H+', 'CH3OH']: moment_zero_header['BUNIT'] = 'K km s-1' moment_zero_header['BTYPE'] = 'MOMENT0' fits.writeto(f'moment_zero_{source}_{species}.fits', data=moment_zero.value, header=moment_zero_header, overwrite=True) fits.writeto(os.path.join('prs', 'figures', 'moments',f'moment_zero_{source}_{species}.fits'), data=moment_zero.value, header=moment_zero_header, overwrite=True) hdu_cont = fits.open(os.path.join(datadir, continuum_fits[source]))[0] continuum_data = np.where(hdu_cont.data >= 2.5e-4, hdu_cont.data, np.nan) Loading