def meanDisp(self, R): ''' Calcualte the surface brightness weighted mean velocity dispersion within R [arcsec] ''' mge = util_mge.mge(self.lum2d, inc=self.inc, shape=self.shape, dist=self.dist) surf = mge.surfaceBrightness(self.xbin*self.pc, self.ybin*self.pc) r = np.sqrt(self.xbin**2 + self.ybin**2) i_in = (r < R) * self.goodbins sigma_R = np.average(self.rms[i_in], weights=surf[i_in]) return sigma_R
def mge_gNFW(self): print('--------------------------------------------------') print('mge_gNFW') self.model['lnprob'] = lnprob_mge_gNFW self.model['type'] = 'mge_gNFW' self.model['ndim'] = 4 self.model['parsNames'] = ['logalpha', 'logrho_s', 'rs', 'gamma'] printModelInfo(self.model) printBoundaryPrior(self.model) sys.stdout.flush() mass_mge = self.model['mge2d'].copy() mge = util_mge.mge(mass_mge, self.model['inc_rad'], dist=self.model['distance']) logrhoS_sps = np.log10(mge.meanDensity(self.model['r']*1e3)) + 9.0 logMS_sps = np.log10(mge.enclosed3Dluminosity(self.model['r']*1e3)) self.model['logrhoS_sps'] = logrhoS_sps self.model['logMS_sps'] = logMS_sps nwalkers = self.model['nwalkers'] threads = self.model['threads'] ndim = self.model['ndim'] parsNames = self.model['parsNames'] burnin = self.model['burnin'] runStep = self.model['runStep'] p0 = flat_initp(parsNames, nwalkers, boundary=self.boundary) sampler = emcee.EnsembleSampler(nwalkers, ndim, self.model['lnprob'], kwargs={'model': self.model}, threads=threads) startTime = time() print('Start burnin') # pos, prob, state = sampler.run_mcmc(p0, burnin) pos, prob, state = run_mcmc(sampler, p0, burnin, nprint=20) sampler.reset() print('Time for burnin: {:.2f}s'.format(time()-startTime)) print('Start running') sys.stdout.flush() # sampler.run_mcmc(pos, runStep) run_mcmc(sampler, pos, runStep, nprint=20) print('Finish! Total elapsed time: {:.2f}s'.format(time()-startTime)) self.model['chain'] = sampler.chain self.model['lnprobability'] = sampler.lnprobability try: self.model['acor'] = sampler.acor except: self.model['acor'] = None self.model['acceptance_fraction'] = sampler.acceptance_fraction dump(self.model)
def main(): '--------------------------------------------------' # create the true density profiles r = np.logspace(np.log10(0.6), np.log10(10.0), 20) mge2d, dist, xbin, ybin, rms, erms = np.load('data/mock_sgnfw_data.npy') mgeStellar = util_mge.mge(mge2d, inc=np.radians(85.0), dist=dist) profileStellar = np.zeros_like(r) for i in range(len(r)): profileStellar[i] = (3.8 * mgeStellar.meanDensity(r[i]*1e3)) * 1e9 logrho_s = 5.8 + np.log10(3.8) rs = 40.0 gamma = -1.2 dh = util_dm.gnfw1d(10**logrho_s, rs, gamma) profileDark = dh.densityProfile(r) profileTotal = profileDark + profileStellar true = {'stellarDens': np.log10(profileStellar), 'darkDens': np.log10(profileDark), 'totalDens': np.log10(profileTotal), 'r': r} '--------------------------------------------------' profile = util_profile.profile('mock_gNFW_out.dat', path='data', nlines=200) profile.plotProfiles(true=true, outpath='data') profile.save(outpath='data')
def __init__(self, name, path='.', burnin=0, nlines=200, r=None): super(profile, self).__init__(name, path=path, burnin=burnin, best='median') self.profiles = {} # dictionary containing profiles if r is None: r = np.logspace(np.log10(0.5), np.log10(100.0), 100) self.profiles['r'] = r # select a subchain to calculate density profile ntotal = self.flatchain.shape[0] step = ntotal // nlines if step == 0: print('Warning - nlines > total number of samples') step = 1 ii = np.zeros(ntotal, dtype=bool) ii[::step] = True self.profiles['nprofiles'] = ii.sum() if self.data['type'] in [ 'spherical_gNFW', 'spherical_gNFW_logml', 'spherical_gNFW_gas' ]: # Calculate stellar mass profiles stellarProfiles = np.zeros([len(r), ii.sum(), 2]) inc = np.arccos(self.flatchain[ii, 0].ravel()) if self.data['type'] == 'spherical_gNFW_logml': mls = 10**self.flatchain[ii, -4].ravel() else: mls = self.flatchain[ii, -4].ravel() mass, density = _extractProfile(self.LmMge, r) for i in range(ii.sum()): stellarProfiles[:, i, 0] = mls[i] * density stellarProfiles[:, i, 1] = mls[i] * mass self.profiles['stellar'] = stellarProfiles # Calculate dark matter profiles # if self.DmMge is None: # raise ValueError('No dark matter halo is found') darkProfiles = np.zeros_like(stellarProfiles) logrho_s = self.flatchain[ii, -3].ravel() rs = self.flatchain[ii, -2].ravel() gamma = self.flatchain[ii, -1].ravel() for i in range(ii.sum()): tem_dh = util_dm.gnfw1d(10**logrho_s[i], rs[i], gamma[i]) tem_mge = util_mge.mge(tem_dh.mge2d(), inc=inc[i]) mass, density = _extractProfile(tem_mge, r) darkProfiles[:, i, 0] = density darkProfiles[:, i, 1] = mass self.profiles['dark'] = darkProfiles totalProfiles = stellarProfiles + darkProfiles self.profiles['total'] = totalProfiles # elif self.data['type'] == 'spherical_gNFW_gradient': # # Calculate stellar mass profiles # stellarProfiles = np.zeros([len(r), ii.sum(), 2]) # inc = np.arccos(self.flatchain[ii, 0].ravel()) # mls = self.flatchain[ii, 2].ravel() # pot_ng = self.pot2d.copy() # pot_tem = np.zeros([1, 3]) # sigma = pot_ng[:, 1]/self.data['Re_arcsec'] # logdelta = self.flatchain[ii, 3].ravel() # mass = np.zeros([len(r), pot_ng.shape[0]]) # density = np.zeros([len(r), pot_ng.shape[0]]) # for i in range(pot_ng.shape[0]): # pot_tem[:, :] = pot_ng[i, :] # mge_pot = util_mge.mge(pot_tem, inc=self.inc, # shape=self.shape, dist=self.dist) # mass[:, i], density[:, i] = _extractProfile(mge_pot, r) # for i in range(ii.sum()): # ML = util_mge.ml_gradient_gaussian(sigma, 10**logdelta[i], # ml0=mls[i]) # stellarProfiles[:, i, 0] = np.sum(ML * density, axis=1) # stellarProfiles[:, i, 1] = np.sum(ML * mass, axis=1) # self.profiles['stellar'] = stellarProfiles # # Calculate dark matter profiles # darkProfiles = np.zeros_like(stellarProfiles) # logrho_s = self.flatchain[ii, 4].ravel() # rs = self.flatchain[ii, 5].ravel() # gamma = self.flatchain[ii, 6].ravel() # for i in range(ii.sum()): # tem_dh = util_dm.gnfw1d(10**logrho_s[i], rs[i], gamma[i]) # tem_mge = util_mge.mge(tem_dh.mge2d(), inc=inc[i]) # mass, density = _extractProfile(tem_mge, r) # darkProfiles[:, i, 0] = density # darkProfiles[:, i, 1] = mass # self.profiles['dark'] = darkProfiles # totalProfiles = stellarProfiles + darkProfiles # self.profiles['total'] = totalProfiles # elif self.data['type'] == 'spherical_total_dpl': # self.profiles['stellar'] = None # self.profiles['dark'] = None # totalProfiles = np.zeros([len(r), ii.sum(), 2]) # inc = np.arccos(self.flatchain[ii, 0].ravel()) # logrho_s = self.flatchain[ii, 2].ravel() # rs = self.flatchain[ii, 3].ravel() # gamma = self.flatchain[ii, 4].ravel() # for i in range(ii.sum()): # tem_dh = util_dm.gnfw1d(10**logrho_s[i], rs[i], gamma[i]) # tem_mge = util_mge.mge(tem_dh.mge2d(), inc=inc[i]) # mass, density = _extractProfile(tem_mge, r) # totalProfiles[:, i, 0] = density # totalProfiles[:, i, 1] = mass # self.profiles['total'] = totalProfiles # elif self.data['type'] == 'oblate_total_dpl': # self.profiles['stellar'] = None # self.profiles['dark'] = None # totalProfiles = np.zeros([len(r), ii.sum(), 2]) # inc = np.arccos(self.flatchain[ii, 0].ravel()) # logrho_s = self.flatchain[ii, 2].ravel() # rs = self.flatchain[ii, 3].ravel() # gamma = self.flatchain[ii, 4].ravel() # q = self.flatchain[ii, 5].ravel() # for i in range(ii.sum()): # tem_dh = util_dm.gnfw2d(10**logrho_s[i], rs[i], gamma[i], q[i]) # tem_mge = util_mge.mge(tem_dh.mge2d(inc[i]), inc=inc[i]) # mass, density = _extractProfile(tem_mge, r) # totalProfiles[:, i, 0] = density # totalProfiles[:, i, 1] = mass # self.profiles['total'] = totalProfiles else: raise ValueError('model type {} not supported'.format( self.data['type'])) # add black hole mass if self.data['bh'] is not None: self.profiles['total'][:, :, 1] += self.data['bh'] # add gas component self.gas3d = self.data.get('gas3d', None) # calculate mass within Re Re_kpc = self.data['Re_arcsec'] * self.pc / 1e3 stellar_Re, dark_Re, total_Re, fdm_Re = self.enclosed3DMass(Re_kpc) MassRe = {} MassRe['Re_kpc'] = Re_kpc MassRe['stellar'] = np.log10(stellar_Re) MassRe['dark'] = np.log10(dark_Re) MassRe['total'] = np.log10(total_Re) MassRe['fdm'] = fdm_Re self.profiles['MassRe'] = MassRe
def plotProfiles(self, outpath='.', figname='profiles.png', Range=None, true=None, nre=3.5, **kwargs): Re_kpc = self.data['Re_arcsec'] * self.pc / 1e3 dataRange = np.percentile(np.sqrt(self.xbin**2+self.ybin**2), 95) * \ self.pc / 1e3 if Range is None: Range = [0.5, nre * Re_kpc] MassRe = self.profiles['MassRe'] fig, axes = plt.subplots(2, 1, figsize=(6, 6), sharex=True) fig.subplots_adjust(left=0.12, bottom=0.08, right=0.98, top=0.98, wspace=0.1, hspace=0.1) r = self.profiles['r'] ii = (r > Range[0]) * (r < Range[1]) logr = np.log10(r[ii]) # plot stellar density if self.profiles['stellar'] is not None: stellarDens = np.log10(self.profiles['stellar'][ii, :, 0]) stellarMass = np.log10(self.profiles['stellar'][ii, :, 1]) axes[0].plot(logr, stellarDens, 'y', alpha=0.1, **kwargs) axes[1].plot(logr, stellarMass, 'y', alpha=0.1, **kwargs) # plot dark density if self.profiles['dark'] is not None: darkDens = np.log10(self.profiles['dark'][ii, :, 0]) darkMass = np.log10(self.profiles['dark'][ii, :, 1]) axes[0].plot(logr, darkDens, 'r', alpha=0.1, **kwargs) axes[1].plot(logr, darkMass, 'r', alpha=0.1, **kwargs) # plot total density if self.profiles['total'] is not None: totalDens = np.log10(self.profiles['total'][ii, :, 0]) totalMass = np.log10(self.profiles['total'][ii, :, 1]) axes[0].plot(logr, totalDens, 'c', alpha=0.1, **kwargs) axes[1].plot(logr, totalMass, 'c', alpha=0.1, **kwargs) # axes[1].plot(np.log10(Re_kpc), MassRe['total'], 'ok') # axes[1].plot(np.log10(Re_kpc), MassRe['stellar'], 'oy') # axes[1].plot(np.log10(Re_kpc), MassRe['dark'], 'or') util_fig.set_labels(axes[0]) util_fig.set_labels(axes[1]) axes[1].set_xlabel(r'$\mathbf{log_{10}\ \ \! R \, \ [kpc]}$', fontproperties=label_font) axes[1].set_ylabel(r'$\mathbf{log_{10}\ \ \! M(R) \, \ [M_{\odot}]}$', fontproperties=label_font) axes[0].set_ylabel( r'$\mathbf{log_{10}\ \ \! \rho \,' ' \ [M_{\odot}\ \ \! kpc^{-3}]}$', fontproperties=label_font) # plot gas density if self.gas3d is not None: gas2d = util_mge.projection(self.gas3d, self.inc) GasMge = util_mge.mge(gas2d, self.inc) mass, density = _extractProfile(GasMge, r) GasProfile = np.zeros([1, len(r), 2]) GasProfile[0, :, 0] = density GasProfile[0, :, 1] = mass self.profiles['gas'] = GasProfile axes[0].plot(logr, np.log10(density[ii]), 'b', alpha=0.8, **kwargs) axes[1].plot(logr, np.log10(mass[ii]), 'b', alpha=0.8, **kwargs) if true is not None: rtrue = true.get('r', None) if rtrue is None: raise RuntimeError('r must be provided for true profile') ii = (rtrue > Range[0]) * (rtrue < Range[1]) if 'stellarDens' in true.keys(): axes[0].plot(np.log10(rtrue[ii]), true['stellarDens'][ii], 'oy', markeredgecolor='k') if 'stellarMass' in true.keys(): axes[1].plot(np.log10(rtrue[ii]), true['stellarMass'][ii], 'oy', markeredgecolor='k') if 'darkDens' in true.keys(): axes[0].plot(np.log10(rtrue[ii]), true['darkDens'][ii], 'or', markeredgecolor='k') if 'darkMass' in true.keys(): axes[1].plot(np.log10(rtrue[ii]), true['darkMass'][ii], 'or', markeredgecolor='k') if 'totalDens' in true.keys(): axes[0].plot(np.log10(rtrue[ii]), true['totalDens'][ii], 'oc', markeredgecolor='k') if 'totalMass' in true.keys(): axes[1].plot(np.log10(rtrue[ii]), true['totalMass'][ii], 'oc', markeredgecolor='k') for ax in axes: ax.set_xlim([np.min(logr), np.max(logr)]) ax.axvline(np.log10(Re_kpc), ls="dashed", color='b', linewidth=2) ax.axvline(np.log10(dataRange), ls="dashed", color='g', linewidth=2) axes[0].text(0.05, 0.05, '$\mathbf{M^*(R_e)}$: %4.2f' % (MassRe['stellar']), transform=axes[0].transAxes, fontproperties=text_font) axes[0].text(0.35, 0.05, '$\mathbf{M^T(R_e)}$: %4.2f' % (MassRe['total']), transform=axes[0].transAxes, fontproperties=text_font) axes[0].text(0.05, 0.25, '$\mathbf{M^*/L}$: %4.2f' % (self.ml), transform=axes[0].transAxes, fontproperties=text_font) if MassRe['fdm'] is not None: axes[0].text(0.35, 0.25, '$\mathbf{f_{DM}(R_e)}$: %4.2f' % (MassRe['fdm']), transform=axes[0].transAxes, fontproperties=text_font) if MassRe['fdm'] is not None: axes[1].text(0.85, 0.05, 'Total', color='c', transform=axes[1].transAxes, fontproperties=text_font) axes[1].text(0.85, 0.15, 'Dark', color='r', transform=axes[1].transAxes, fontproperties=text_font) axes[1].text(0.85, 0.25, 'Stellar', color='y', transform=axes[1].transAxes, fontproperties=text_font) fig.savefig('{}/{}'.format(outpath, figname), dpi=100)
r = np.logspace(np.log10(0.1), np.log10(100), 500) logr = np.log10(r) # 3 parameters for gNFW profile gamma = -1.0 # usually between [-2.0, 0.0] rs = 30.0 # [kpc] rho_s = 1e5 # [M_solar/kpc^2] (1[M_solar/kpc^3] = 1e9[M_solar/pc^3]) gnfw_dh = udm.gnfw1d(rho_s, rs, gamma) # initialize a gNFW class profile = np.log10(gnfw_dh.densityProfile(r)) # get the density profile mge2d = gnfw_dh.mge2d() # fit the density profile using MGE # initialize the MGE class using the MGE from dark halo mge = umge.mge(mge2d, np.pi / 2.0, shape='oblate') print('--------------------') print('Enclosed Mass within 10kpc (gNFW profile): {:.3e}'.format( gnfw_dh.enclosedMass(1.0))) print('Enclosed Mass within 10kpc (MGE approximation): {:.3e}'.format( mge.enclosed3Dluminosity(10.0 * 1e3)[0])) # here are some unit conversion profile_mge = np.log10(mge.luminosityDensity(r * 1e3, 0) * 1e9) # plot the density profile of the dark halo and the mge approximation line_dh, = plt.plot(logr, profile, 'k') line_mge, = plt.plot(logr, profile_mge, 'r') plt.xlabel('logR [kpc]') plt.ylabel('logrho [M_solar/kpc^3]') plt.legend([line_dh, line_mge], ['gNFW halo', 'MGE approximation']) plt.savefig('profile.png')
def lnprob_mge_gNFW(pars, model=None, returnType='lnprob'): logalpha, logrho_s, rs, gamma = pars parsDic = {'logalpha': logalpha, 'logrho_s': logrho_s, 'rs': rs, 'gamma': gamma} # check if parameters are in the boundary if not check_boundary(parsDic, boundary=model['boundary']): rst = {} rst['lnprob'] = -np.inf rst['chi2'] = np.inf rst['profiles'] = None return rst[returnType] # fit option fit = model['fit'] # observed total density profile, error and goodbins logrhoT = model['logrhoT'] logrhoTerr = model['logrhoTerr'] logMT = model['logMT'] logMTerr = model['logMTerr'] good = model['good'] # model stellar profile logrhoS = model['logrhoS_sps'] + logalpha logMS = model['logMS_sps'] + logalpha # model dark matter profile dh = util_dm.gnfw1d(10**logrho_s, rs, gamma) logrhoD = np.log10(dh.densityProfile(model['r'])) # logMD = np.zeros(len(logMS)) # for i in range(len(logMD)): # logMD[i] = np.log10(dh.enclosedMass(model['r'][i])) tem_mge = util_mge.mge(dh.mge2d(), inc=np.pi/2.0) logMD = np.log10(tem_mge.enclosed3Dluminosity(model['r']*1e3)) # model total profile logrhoTmodel = np.log10(10**logrhoS + 10**logrhoD) logMTmodel = np.log10(10**logMS + 10**logMD) chi2_dens = np.sum(((logrhoT[good] - logrhoTmodel[good]) / logrhoTerr[good])**2) chi2_mass = np.sum(((logMT[good] - logMTmodel[good]) / logMTerr[good])**2) if fit == 'dens': chi2 = chi2_dens elif fit == 'mass': chi2 = chi2_mass elif fit == 'all': chi2 = chi2_dens + chi2_mass else: raise ValueError('Invalid fit option {}'.format(fit)) if returnType == 'profiles': # tem_mge = util_mge.mge(dh.mge2d(), inc=np.pi/2.0) # logMD = np.log10(tem_mge.enclosed3Dluminosity(model['r']*1e3)) rst = {} rst['r'] = model['r'] rst['rho_star'] = logrhoS rst['rho_dark'] = logrhoD rst['rho_total'] = logrhoTmodel rst['M_star'] = logMS rst['M_dark'] = logMD rst['M_total'] = logMTmodel rst['chi2'] = chi2 rst['rho_total_obs'] = logrhoT rst['M_total_obs'] = logMT rst['good'] = good rst['pars'] = parsDic return rst elif returnType == 'lnprob': return -0.5*chi2 elif returnType == 'chi2': return chi2 else: raise KeyError('Invalid returnType {}'.format(returnType))
def __init__(self, name, path='.', burnin=0, best='median'): self.data = load(name, path=path) # load model data into class self.ndim = self.data['ndim'] self.nwalkers = self.data['nwalkers'] self.chain = self.data['rst']['chain'] self.goodchains = self.data['rst']['goodchains'] # check good chain fraction if self.goodchains.sum()/float(self.nwalkers) < 0.6: self.goodchains = np.ones_like(self.goodchains, dtype=bool) print('Warning - goodchain fraction less than 0.6') print('Acceptance fraction:') print(self.data['rst']['acceptance_fraction']) self.lnprob = self.data['rst']['lnprobability'] self.flatchain = self.chain[self.goodchains, burnin:, :].reshape(-1, self.ndim) self.flatlnprob = self.lnprob[self.goodchains, burnin:].reshape(-1) # estimate the beset model parameters self.medianPars = estimatePrameters(self.flatchain, flatlnprob=self.flatlnprob) self.meanPars = estimatePrameters(self.flatchain, flatlnprob=self.flatlnprob, method='mean') self.peakPars = estimatePrameters(self.flatchain, flatlnprob=self.flatlnprob, method='peak') self.maxPars = estimatePrameters(self.flatchain, flatlnprob=self.flatlnprob, method='max') # estimate the errors percentile = np.percentile(self.flatchain, [16, 50, 84], axis=0) self.errPars = np.zeros([2, percentile.shape[1]]) self.errPars[0, :] = percentile[0, :] - percentile[1, :] self.errPars[1, :] = percentile[2, :] - percentile[1, :] # choose the best parameter type switch = {'median': self.medianPars, 'mean': self.meanPars, 'peak': self.peakPars, 'max': self.maxPars} bestPars = switch[best] self.bestPars_list = bestPars self.bestPars = {} for i, key in enumerate(self.data['JAMpars']): self.bestPars[key] = bestPars[i] # model inclination cosinc = self.bestPars.get('cosinc', np.pi/2.0) self.inc = np.arccos(cosinc) if 'ml' in self.bestPars.keys(): self.ml = self.bestPars['ml'] else: if 'logml' in self.bestPars.keys(): self.ml = 10**self.bestPars['logml'] else: print('Waring - do not find ml parameter, set to 1.0') self.ml = 1.0 # load observational data self.dist = self.data['distance'] self.pc = self.dist * np.pi / 0.648 self.lum2d = self.data['lum2d'] self.pot2d = self.data['pot2d'] self.xbin = self.data['xbin'] self.ybin = self.data['ybin'] self.rms = self.data['rms'].clip(0.0, 600.0) self.goodbins = self.data['goodbins'] self.symetrizedRms = self.rms.copy() self.symetrizedRms[self.goodbins] = \ symmetrize_velfield(self.xbin[self.goodbins], self.ybin[self.goodbins], self.rms[self.goodbins]) # run a JAM model with the choosen best model parameters JAMmodel = self.data['JAM'] # restore JAM model JAMlnprob = self.data['lnprob'] self.rmsModel = JAMlnprob(bestPars, model=self.data, returnType='rmsModel') self.flux = JAMlnprob(bestPars, model=self.data, returnType='flux') self.shape = self.data['shape'] # create stellar mass mge objected (used in mass profile) self.LmMge = util_mge.mge(self.pot2d, inc=self.inc, shape=self.shape, dist=self.dist) # set black hole mge object bh3dmge = JAMmodel.mge_bh if bh3dmge is None: self.BhMge = None else: bh2dmge = util_mge.projection(bh3dmge, inc=self.inc) self.BhMge = util_mge.mge(bh2dmge, inc=self.inc) if self.data['type'] == 'massFollowLight': self.labels = [r'$\mathbf{cosi}$', r'$\mathbf{\beta0}$', r'$R_a$', r'$a$', r'$\mathbf{M/L}$'] self.DmMge = None # no dark halo elif self.data['type'] == 'spherical_gNFW': self.labels = [r'$\mathbf{cosi}$', r'$\mathbf{\beta0}$', r'$R_a$', r'$a$', r'$\mathbf{M^*/L}$', r'$\mathbf{log\ \rho_s}$', r'$\mathbf{r_s}$', r'$\mathbf{\gamma}$'] # create dark halo mass mge object dh = JAMlnprob(bestPars, model=self.data, returnType='dh') dh_mge3d = dh.mge3d() self.DmMge = util_mge.mge(dh.mge2d(), inc=self.inc) # elif self.data['type'] == 'spherical_gNFW_logml': # self.labels = [r'$\mathbf{cosi}$', r'$\mathbf{\beta}$', # r'$\mathbf{logM^*/L}$', r'$\mathbf{log\ \rho_s}$', # r'$\mathbf{r_s}$', r'$\mathbf{\gamma}$'] # # create dark halo mass mge object # dh = JAMlnprob(bestPars, model=self.data, returnType='dh') # dh_mge3d = dh.mge3d() # self.DmMge = util_mge.mge(dh.mge2d(), inc=self.inc) # elif self.data['type'] == 'spherical_gNFW_gas': # inc = self.inc # Beta = np.zeros(self.lum2d.shape[0]) + bestPars[1] # ml = bestPars[2] # logrho_s = bestPars[3] # rs = bestPars[4] # gamma = bestPars[5] # dh = util_dm.gnfw1d(10**logrho_s, rs, gamma) # dh_mge3d = dh.mge3d() # gas3d = self.data['gas3d'] # dh_mge3d = np.append(gas3d, dh_mge3d, axis=0) # self.rmsModel = JAMmodel.run(inc, Beta, ml=ml, mge_dh=dh_mge3d) # self.flux = JAMmodel.flux # self.labels = [r'$\mathbf{cosi}$', r'$\mathbf{\beta}$', # r'$\mathbf{M^*/L}$', r'$\mathbf{log\ \rho_s}$', # r'$\mathbf{r_s}$', r'$\mathbf{\gamma}$'] # # create dark halo mass mge object # self.DmMge = util_mge.mge(dh.mge2d(), inc=self.inc) # elif self.data['type'] == 'spherical_gNFW_gradient': # self.labels = [r'$\mathbf{cosi}$', r'$\mathbf{\beta}$', # r'$\mathbf{M^*/L}$', # r'$\mathbf{\log \Delta_{IMF}}$', # r'$\mathbf{log\ \rho_s}$', # r'$\mathbf{r_s}$', r'$\mathbf{\gamma}$'] # # create dark halo mass mge object # dh = JAMlnprob(bestPars, model=self.data, returnType='dh') # dh_mge3d = dh.mge3d() # self.DmMge = util_mge.mge(dh.mge2d(), inc=self.inc) # elif self.data['type'] == 'spherical_total_dpl': # self.labels = [r'$\mathbf{cosi}$', r'$\mathbf{\beta}$', # r'$\mathbf{log\ \rho_s}$', # r'$\mathbf{r_s}$', r'$\mathbf{\gamma}$'] # # create dark halo mass mge object # dh = JAMlnprob(bestPars, model=self.data, returnType='dh') # dh_mge3d = dh.mge3d() # self.DmMge = util_mge.mge(dh.mge2d(), inc=self.inc) # elif self.data['type'] == 'oblate_total_dpl': # self.labels = [r'$\mathbf{cosi}$', r'$\mathbf{\beta}$', # r'$\mathbf{log\ \rho_s}$', r'$\mathbf{r_s}$', # r'$\mathbf{\gamma}$', r'$\mathbf{q}$'] # # create dark halo mass mge object # dh = JAMlnprob(bestPars, model=self.data, returnType='dh') # dh_mge3d = dh.mge3d() # self.DmMge = util_mge.mge(dh.mge2d(self.inc), inc=self.inc) else: raise ValueError('model type {} not supported' .format(self.data['type']))