コード例 #1
0
ファイル: utils.py プロジェクト: albertfxwang/gsf
 def __setstate__(self, dict):
     """Unpickle."""
     self.__dict__.update(dict)
     self.agefunc, self.redshiftfunc, e_f, e_t  = \
                   cd.quick_age_function(zmax=1.1 * self.z_max, 
                                         zmin=self.z_min-0.05, 
                                         zstep=0.01,
                                         logspacing=True,
                                         return_inverse=True,
                                         **self.cosmo)
コード例 #2
0
ファイル: utils.py プロジェクト: roban/CosmoloPy
 def __setstate__(self, dict):
     """Unpickle."""
     self.__dict__.update(dict)
     self.agefunc, self.redshiftfunc, e_f, e_t = cd.quick_age_function(
         zmax=1.1 * self.z_max,
         zmin=self.z_min - 0.05,
         zstep=0.01,
         logspacing=True,
         return_inverse=True,
         **self.cosmo
     )
コード例 #3
0
ファイル: utils.py プロジェクト: roban/CosmoloPy
    def __init__(self, z_min, z_max, dt_yr=2e6, **cosmo):
        self.z_min = z_min
        self.z_max = z_max
        self.dt_yr = dt_yr
        self.cosmo = cosmo

        self.agefunc, self.redshiftfunc, e_f, e_t = cd.quick_age_function(
            zmax=1.1 * z_max, zmin=z_min - 0.05, zstep=0.01, logspacing=True, return_inverse=True, **cosmo
        )
        self.tmax = self.agefunc(z_min)
        self.tmin = self.agefunc(z_max)
        self.dt = self.dt_yr * cc.yr_s
        self.t = numpy.arange(self.tmin, self.tmax + 1.01 * self.dt, self.dt)
        self.t_yr = self.t / cc.yr_s
        self.z = self.redshiftfunc(self.t)
        print " Using %i points in t, dt = %.3g yr." % (len(self.t_yr), self.dt_yr)
コード例 #4
0
ファイル: __init__.py プロジェクト: sully90/seren3
def aout(zmin, zmax, noutput, zstep=0.001, **cosmo):
    '''
    Function which returns list of expansion factors to output at, evenly spaced in proper time
    '''
    import numpy as np
    import cosmolopy.distance as cd
    from seren3.array import SimArray

    age_func = cd.quick_age_function(1000, 0, zstep, False, **cosmo)
    z_func = cd.quick_redshift_age_function(1000, 0, zstep, **cosmo)

    age_start = age_func(zmin)
    age_end = age_func(zmax)

    age_out = np.linspace(age_start, age_end, noutput)
    z_out = z_func(age_out)
    a_out = 1. / (1. + z_out)

    return a_out[::-1]
コード例 #5
0
ファイル: utils.py プロジェクト: albertfxwang/gsf
 def __init__(self, z_min, z_max, dt_yr=2e6, **cosmo):
     self.z_min = z_min
     self.z_max = z_max
     self.dt_yr = dt_yr
     self.cosmo = cosmo
     
     self.agefunc, self.redshiftfunc, e_f, e_t  = \
                   cd.quick_age_function(zmax=1.1 * z_max, 
                                         zmin=z_min-0.05, 
                                         zstep=0.01,
                                         logspacing=True,
                                         return_inverse=True,
                                         **cosmo)
     self.tmax = self.agefunc(z_min)
     self.tmin = self.agefunc(z_max)
     self.dt = self.dt_yr * cc.yr_s
     self.t = numpy.arange(self.tmin, self.tmax + 1.01 * self.dt, self.dt)
     self.t_yr = self.t / cc.yr_s
     self.z = self.redshiftfunc(self.t)
     print(" Using %i points in t, dt = %.3g yr." % (len(self.t_yr),
                                                     self.dt_yr))
コード例 #6
0
# This program reads in master.txt which includes all gas particle ID's, scale factors, and radii for all snapshots and plots the particle trajectories for each

import numpy as np
import matplotlib.pyplot as plt
import matplotlib
import read_snap
import cosmolopy.distance as cd
import cosmolopy.constants as cc

cosmo = {'omega_M_0': 0.3, 'omega_lambda_0': 0.7, 'omega_k_0': 0.0, 'h': 0.674}
cosmo = cd.set_omega_k_0(cosmo)
agefunc = cd.quick_age_function(**cosmo)

# Specify galaxy
gal = 858

# Specify path
path = '/Volumes/Happy/Choi16_Fiducial/BH_trace/m0' + str(gal).zfill(3) + '/'

# Read in files
gasparticleID = np.loadtxt('/Users/sandyspicer02/Research/m0' +
                           str(gal).zfill(3) + '/r_vs_t/master.txt',
                           dtype='uint',
                           usecols=(0, ))
scalef = np.loadtxt('/Users/sandyspicer02/Research/m0' + str(gal).zfill(3) +
                    '/r_vs_t/master.txt',
                    usecols=(1, ))
radius = np.loadtxt('/Users/sandyspicer02/Research/m0' + str(gal).zfill(3) +
                    '/r_vs_t/master.txt',
                    usecols=(2, ))
cosmictime = np.loadtxt('/Users/sandyspicer02/Research/m0' +
コード例 #7
0
def z_to_age(zmax=20., zmin=0., return_inverse=False, **cosmo):
    """ Return functions to compute age/z from each other respectivly """
    import cosmolopy.distance as cd
    return cd.quick_age_function(zmax=zmax, zmin=zmin, return_inverse=return_inverse, **cosmo)