Exemplo n.º 1
0
    def spherical_gNFW_gas(self):
        print('--------------------------------------------------')
        print('spherical gNFW + gas model')
        # calculate gas mge profile
        if model['Mgas'] is None:
            raise RuntimeError('Gas mass must be provided')
        gas = util_gas.gas_exp(model['Mgas'])
        model['gas3d'] = gas.mge3d
        model['lnprob'] = lnprob_spherical_gNFW_gas
        model['type'] = 'spherical_gNFW_gas'
        model['ndim'] = 6
        model['JAMpars'] = ['cosinc', 'beta', 'ml', 'logrho_s', 'rs', 'gamma']
        # initialize the JAM class and pass to the global parameter
        model['JAM'] = \
            pyjam.axi_rms.jam(model['lum2d'], model['pot2d'],
                              model['distance'],
                              model['xbin'], model['ybin'], mbh=model['bh'],
                              quiet=True, sigmapsf=model['sigmapsf'],
                              pixsize=model['pixsize'], nrad=model['nrad'],
                              shape=model['shape'])

        printModelInfo(model)
        print('Gas Mass: {:.4e}'.format(model['Mgas']))
        printBoundaryPrior(model)
        nwalkers = model['nwalkers']
        threads = model['threads']
        ndim = model['ndim']
        JAMpars = model['JAMpars']
        if model['p0'] == 'flat':
            p0 = flat_initp(JAMpars, nwalkers)
        elif model['p0'] == 'fit':
            raise ValueError('Calculate maximum lnprob positon from '
                             'optimisiztion - not implemented yet')
        else:
            raise ValueError('p0 must be flat or fit, {} is '
                             'not supported'.format(model['p0']))
        initSampler = \
            emcee.EnsembleSampler(nwalkers, ndim, model['lnprob'],
                                  kwargs={'model': model}, threads=threads)
        sys.stdout.flush()
        sampler = _runEmcee(initSampler, p0)
        # pool.close()
        print('--------------------------------------------------')
        print('Finish! Total elapsed time: {:.2f}s'.format(time() -
                                                           self.startTime))
        rst = analyzeRst(sampler, model)
        sys.stdout.flush()
        model['rst'] = rst
        dump(model)
Exemplo n.º 2
0
 def massFollowLight(self):
     print('--------------------------------------------------')
     print('Mass follow light model')
     model['lnprob'] = lnprob_massFollowLight
     model['type'] = 'massFollowLight'
     model['ndim'] = 3
     model['JAMpars'] = ['cosinc', 'beta', 'ml']
     # initialize the JAM class and pass to the global parameter
     model['JAM'] = \
         pyjam.axi_rms.jam(model['lum2d'], model['pot2d'],
                           model['distance'],
                           model['xbin'], model['ybin'], mbh=model['bh'],
                           quiet=True, sigmapsf=model['sigmapsf'],
                           pixsize=model['pixsize'], nrad=model['nrad'],
                           shape=model['shape'])
     printModelInfo(model)
     printBoundaryPrior(model)
     nwalkers = model['nwalkers']
     threads = model['threads']
     ndim = model['ndim']
     JAMpars = model['JAMpars']
     if model['p0'] == 'flat':
         p0 = flat_initp(JAMpars, nwalkers)
     elif model['p0'] == 'fit':
         raise ValueError('Calculate maximum lnprob positon from '
                          'optimisiztion - not implemented yet')
     else:
         raise ValueError('p0 must be flat or fit, {} is '
                          'not supported'.format(model['p0']))
     # pool = MPIPool()
     # if not pool.is_master():
     #     pool.wait()
     #     sys.exit(0)
     # Initialize sampler
     initSampler = \
         emcee.EnsembleSampler(nwalkers, ndim, model['lnprob'],
                               kwargs={'model': model}, threads=threads)
     sys.stdout.flush()
     sampler = _runEmcee(initSampler, p0)
     # pool.close()
     print('--------------------------------------------------')
     print('Finish! Total elapsed time: {:.2f}s'.format(time() -
                                                        self.startTime))
     rst = analyzeRst(sampler, model)
     sys.stdout.flush()
     model['rst'] = rst
     dump(model)