from constrain_parameters import paraH2COmodel from masked_cubes import (cube303m,cube321m,cube303msm,cube321msm, cube303,cube321,cube303sm,cube321sm, sncube, sncubesm) from masked_cubes import mask as cube_signal_mask from co_cubes import cube13co, cube18co, cube13cosm, cube18cosm from noise import noise, noise_cube, sm_noise_cube from higal_gridded import column_regridded, dusttem_regridded from common_constants import logabundance,elogabundance import heating from gaussian_correction import gaussian_correction warnings.simplefilter('once') if 'mf' not in locals(): mf = paraH2COmodel() # For debugging, to make it faster # biggest_tree = dend[89] def get_root(structure): """ Identify the root of the tree """ if structure.parent is None: return structure else: return get_root(structure.parent) def measure_dendrogram_properties(dend=None, cube303=cube303, cube321=cube321, cube13co=cube13co, cube18co=cube18co, noise_cube=noise_cube, sncube=sncube,
from astropy.utils.console import ProgressBar from paths import hpath from constrain_parameters import paraH2COmodel from masked_cubes import cube303m, cube321m, cube303, cube321, mask from noise import noise, noise_cube from common_constants import logabundance, elogabundance from higal_gridded import column_regridded from ratio_cubes import ratio303321, eratio303321, noise_flat log.warn("Extremely slow for a very small fraction of overall data." "Try a different method: make_piecewise_temcube.py") nsigma = 5 # start big to minimize # of failures mf = paraH2COmodel() indices = np.where(mask) usable = ((eratio303321 * nsigma < ratio303321) & (eratio303321 > 0) & (ratio303321 > 0) & (noise_flat > 1e-10) & (noise_flat < 10) & (ratio303321 < 100)) assert len(usable) == len(indices) ngood = np.count_nonzero(usable) usable_indices = [ind[usable] for ind in indices] uz, uy, ux = usable_indices column_flat = column_regridded.data[uy, ux] uratio303321 = ratio303321[usable] ueratio303321 = eratio303321[usable] utline303 = cube303.flattened()[usable] utline321 = cube321.flattened()[usable]
error distribution EDIT 5/3/2015: After some further thinking, this approach doesn't really make sense. We already have the likelihood of the model given the data. This computes the distribution of the maximum-likelihood model, which simply isn't the same thing. However, I think we *can* take the modeled parconstraints and sample from within those to see what ratios we get out and whether that distribution matches the input distribution. """ import numpy as np from constrain_parameters import paraH2COmodel from astropy.utils.console import ProgressBar model = paraH2COmodel() ratio303321 = 0.3 eratio303321 = 0.01 logabundance = np.log10(1.2e-9) elogabundance = 1.0 logh2column = 22. elogh2column = 1. mindens = 4.5 emindens = 0.2 linewidth=5.0 model.set_constraints(ratio303321=ratio303321, eratio303321=eratio303321, logabundance=logabundance, elogabundance=elogabundance,
fig = pl.figure(1) pl.clf() ax = fig.gca() ax.plot(data, ratio_to_temperature(data), alpha=0.5, linewidth=2, label='LTE', ) ax.set_ylim(0,150) ax.set_xlabel("Ratio H$_2$CO $3_{2,1}-2_{2,0} / 3_{0,3}-2_{0,2}$") ax.set_ylabel("Temperature (K)") fig.savefig(paths.fpath('h2co_temperature_vs_ratio_lte.png')) pm = paraH2COmodel() densind = np.argmin(np.abs(pm.densityarr[0,:,0]-4.5)) colind = np.argmin(np.abs(pm.columnarr[0,:,0]-13.5)) ax.plot(pm.modelratio1[:,densind,colind], pm.temparr[:,densind,colind], 'r', alpha=0.5, linewidth=2, label='$n=10^{4.5}$ cm$^{-3}$, $N=10^{13.5}$ cm$^{-2}$', ) pl.legend(loc='best') fig.savefig(paths.fpath('h2co_temperature_vs_ratio_lte_and_radex.png'))
ax = fig.gca() ax.plot( data, ratio_to_temperature(data), alpha=0.5, linewidth=2, label='LTE', ) ax.set_ylim(0, 150) ax.set_xlabel("Ratio H$_2$CO $3_{2,1}-2_{2,0} / 3_{0,3}-2_{0,2}$") ax.set_ylabel("Temperature (K)") fig.savefig(paths.fpath('h2co_temperature_vs_ratio_lte.png')) pm = paraH2COmodel() densind = np.argmin(np.abs(pm.densityarr[0, :, 0] - 4.5)) colind = np.argmin(np.abs(pm.columnarr[0, :, 0] - 13.5)) ax.plot( pm.modelratio1[:, densind, colind], pm.temparr[:, densind, colind], 'r', alpha=0.5, linewidth=2, label='$n=10^{4.5}$ cm$^{-3}$, $N=10^{13.5}$ cm$^{-2}$', ) pl.legend(loc='best') fig.savefig(paths.fpath('h2co_temperature_vs_ratio_lte_and_radex.png'))