예제 #1
0
def default_model(recalc=False, pckl_fil=None, use_mcmc=False, write=False):
    """
    Pass back a default fN_model from Prochaska+13
      Tested against XIDL code by JXP on 09 Nov 2014

    Parameters:
    recalc : boolean (False)
      Recalucate the default model
    use_mcmc : boolean (False)
      Use the MCMC chain to generate the model
    write : boolean (False)
      Write out the model
    """
    if pckl_fil == None:
        pckl_fil = xa_path + '/igm/fN/fN_model_P13.p'

    if recalc is True:

        if use_mcmc == True:
            # MCMC Analysis
            chain_file = (os.environ.get('DROPBOX_DIR') +
                          'IGM/fN/MCMC/mcmc_spline_k13r13o13n12_8.fits.gz')
            outp = mcmc.chain_stats(chain_file)

            # Build a model
            NHI_pivots = [12., 15., 17.0, 18.0, 20.0, 21., 21.5, 22.]
            fN_model = fN_Model('Hspline',
                                zmnx=(0.5, 3.0),
                                pivots=NHI_pivots,
                                param=outp['best_p'])
        else:
            # Input the f(N) at z=2.4
            fN_file = (os.environ.get('DROPBOX_DIR') +
                       'IGM/fN/fN_spline_z24.fits.gz')
            hdu = fits.open(fN_file)
            fN_data = hdu[1].data
            #xdb.set_trace()
            # Instantiate
            fN_model = fN_Model('Hspline',
                                zmnx=(0.5, 3.0),
                                pivots=np.array(fN_data['LGN']).flatten(),
                                param=np.array(fN_data['FN']).flatten())
        # Write
        if write is True:
            print('default_model: Writing %s' % pckl_fil)
            pickle.dump(fN_model, open(pckl_fil, "wb"), -1)
    else:
        fN_model = pickle.load(open(pckl_fil, "rb"))

    # Return
    return fN_model
예제 #2
0
파일: model.py 프로젝트: jsribaud/xastropy
def default_model(recalc=False, pckl_fil=None, use_mcmc=False, write=False):
    """
    Pass back a default fN_model from Prochaska+13
      Tested against XIDL code by JXP on 09 Nov 2014

    Parameters:
    recalc: boolean (False)
      Recalucate the default model
    use_mcmc: boolean (False)
      Use the MCMC chain to generate the model
    write: boolean (False)
      Write out the model
    """
    if pckl_fil==None:
        pckl_fil = xa_path+'/igm/fN/fN_model_P13.p'

    if recalc is True:
        
        if use_mcmc == True:
            # MCMC Analysis
            chain_file = (os.environ.get('DROPBOX_DIR')+
                        'IGM/fN/MCMC/mcmc_spline_k13r13o13n12_8.fits.gz')
            outp = mcmc.chain_stats(chain_file)
    
            # Build a model
            NHI_pivots = [12., 15., 17.0, 18.0, 20.0, 21., 21.5, 22.]
            fN_model = fN_Model('Hspline', zmnx=(0.5,3.0),
                            pivots=NHI_pivots, param=outp['best_p'])
        else:
            # Input the f(N) at z=2.4
            fN_file = (os.environ.get('DROPBOX_DIR')+
                        'IGM/fN/fN_spline_z24.fits.gz')
            hdu = fits.open(fN_file)
            fN_data = hdu[1].data
            #xdb.set_trace()
            # Instantiate
            fN_model = fN_Model('Hspline', zmnx=(0.5,3.0),
                            pivots=np.array(fN_data['LGN']).flatten(),
                            param=np.array(fN_data['FN']).flatten())
        # Write
        if write is True:
            print('default_model: Writing %s' % pckl_fil)
            pickle.dump( fN_model, open( pckl_fil, "wb" ), -1)
    else: fN_model = pickle.load( open( pckl_fil, "rb" ) )
        
    # Return
    return fN_model
예제 #3
0
    from xastropy.igm.fN import model as xifm

    flg_test = 0
    #flg_test += 2**1 # Compare models
    #flg_test += 2**2 # Data
    #flg_test += 2**3 # l(X)
    #flg_test += 64 # Akio
    #flg_test += 2**7 # rho_HI
    flg_test += 2**8  # Create Pickle file
    #flg_test = 0 + 64

    if (flg_test % 2) == 1:
        # MCMC Analysis
        chain_file = os.environ.get(
            'DROPBOX_DIR') + 'IGM/fN/MCMC/mcmc_spline_k13r13o13n12_8.fits.gz'
        outp = mcmc.chain_stats(chain_file)

        # Build a model
        NHI_pivots = [12., 15., 17.0, 18.0, 20.0, 21., 21.5, 22.]
        fN_model = xifm.fN_Model('Hspline',
                                 zmnx=(0.5, 3.0),
                                 pivots=NHI_pivots,
                                 param=outp['best_p'])
        #xdb.set_trace()
        print(fN_model)

    # Compare default against P+13
    if (flg_test % 2**2) >= 2**1:
        fN_model = xifm.default_model()
        p13_file = (os.environ.get('DROPBOX_DIR') +
                    'IGM/fN/fN_spline_z24.fits.gz')
예제 #4
0
파일: model.py 프로젝트: jsribaud/xastropy
    
    from xastropy.igm.fN import data as fN_data
    from xastropy.igm.fN import model as xifm

    flg_test = 0 
    #flg_test += 2**1 # Compare models
    #flg_test += 2**2 # Data
    #flg_test += 2**3 # l(X)
    #flg_test += 64 # Akio
    flg_test += 2**7 # rho_HI
    #flg_test = 0 + 64
    
    if (flg_test % 2) == 1:
        # MCMC Analysis
        chain_file = os.environ.get('DROPBOX_DIR')+'IGM/fN/MCMC/mcmc_spline_k13r13o13n12_8.fits.gz'
        outp = mcmc.chain_stats(chain_file)

        # Build a model
        NHI_pivots = [12., 15., 17.0, 18.0, 20.0, 21., 21.5, 22.]
        fN_model = xifm.fN_Model('Hspline', zmnx=(0.5,3.0),
                            pivots=NHI_pivots, param=outp['best_p'])
        #xdb.set_trace()
        print(fN_model)

    # Compare default against P+13
    if (flg_test % 4) >= 2:
        fN_model = xifm.default_model()
        p13_file = (os.environ.get('DROPBOX_DIR')+'IGM/fN/fN_spline_z24.fits.gz')
        hdu = fits.open(p13_file)
        p13_data = hdu[1].data