コード例 #1
0
 def __init__(self, **kwargs):
     Matter.__init__(self, **kwargs)
     self.accepted_kwargs = {'world': None,
                             'coordinate_key': '0_0_0',
                             'impassible': True,
                             'layer': 1.2,
                             'float_offset': plist([0.5, 0.5]), 
                             'controllable': False
                                            }
     for key in self.accepted_kwargs.keys():
         if key in kwargs.keys():
             self.__setattr__(key, kwargs[key])
         else:
             self.__setattr__(key, self.accepted_kwargs[key]) 
     #Render related local variables..
     self.width   = sprite_manifest[self.image_key].frame_width
     self.height  = sprite_manifest[self.image_key].frame_height
     self.tall    = self.height
     self.frame = 0 #the rendered last frame in a "strip" of frames
     self.facing = 5
     self.pixel_offsets = self.determine_pixel_offset()
     #Thresholds for changes in milliseconds
     #Thresholds for changes in milliseconds
     self.move_threshold  = 500
     self.frame_threshold = self.move_threshold/5
     self.tick_accumulator = 0
     self.move_accumulator = 0
     self.path = None
コード例 #2
0
ファイル: Pk_gal.py プロジェクト: kilianbreathnach/PkABC
    def set_universe(self, Om=0.3, OL=0.7, ns=0.96,
                     sig_8=0.81, h=1.0, T_cmb=2.725, h_transf=0.7,
                     k=None, k_min=1.e-3, k_max=2.e3, kbins=1000,
                     lnM_min=np.log(1e11), lnM_max=np.log(1e15),
                     transfer_fit="EH",
                     hmf_fit="Tinker",
                     bias_fit="Tinker"):
        """
        Set the cosmological parameters and fitting functions used for the
        power spectrum calculation. This attribute is an instance of the
        Matter class defined in matter.py, which has functions for computing
        the required dark matter statistics.
        """
        self.universe = Matter(Om=Om, OL=OL, ns=ns,
                               sig_8=sig_8, h=h, T_cmb=T_cmb,
                               h_transf=h_transf,
                               k=k,
                               k_min=k_min, k_max=k_max, kbins=kbins,
                               lnM_min=lnM_min, lnM_max=lnM_max,
                               lnMbins=1000,
                               transfer_fit=transfer_fit,
                               hmf_fit=hmf_fit,
                               bias_fit=bias_fit)

        self.lnm = self.universe.lnM
コード例 #3
0
ファイル: item.py プロジェクト: Deep-Phield-Softworks/XeroSum
 def __init__(self, **kwargs):
     Matter.__init__(self, **kwargs)
     self.accepted_kwargs = {'tall': 0, 'float_offset': plist([0.5, 0.5]), 'layer': 1.5,
                             'frame': (0, 0), 'weight' : 0.0, 'use_sound' : 'explosion.ogg'}
     for key in self.accepted_kwargs.keys():
         if key in kwargs.keys():
             self.__setattr__(key, kwargs[key])
         else:
             self.__setattr__(key, self.accepted_kwargs[key])
コード例 #4
0
ファイル: solution.py プロジェクト: OhEvolve/RANDY
    def __init__(self, *args, **kwargs):
        """ Initialization of object """

        self.volume = '0 mL'  # volume of solution

        Matter.__init__(self, *args, **kwargs)  # update with arguments

        self.update(*args, **kwargs)  # update object attributes

        self.features += ['volume']  # add printed attributes
コード例 #5
0
ファイル: tile.py プロジェクト: Deep-Phield-Softworks/XeroSum
 def __init__(self, **kwargs):
     Matter.__init__(self, **kwargs)
     self.accepted_kwargs = {'speedModifier': 1.0, 'layer': 0.1, 'pathable': True}
     for key in self.accepted_kwargs.keys():
         if key in kwargs.keys():
             self.__setattr__(key, kwargs[key])
         else:
             self.__setattr__(key, self.accepted_kwargs[key])
     #No Tiles offset. Would create gaps. Only here as placeholder values.
     self.float_offset = plist([0.0,0.0])
     self.pixel_offsets = plist([0, 0])
コード例 #6
0
    def __init__(self,*args,**kwargs):
        """ Initialization of object """

        self.species = ''                                      # species of population
        self.count = 0                                         # cell count
        self.contents = [Sequence(name='gDNA',form='genomic')] # contents of cell

        Matter.__init__(self)                                  # update with arguments

        self.update(*args,**kwargs)                            # update object attributes

        self.features += ['species','count']                   # add printed attributes
コード例 #7
0
ファイル: buffer.py プロジェクト: OhEvolve/RANDY
    def __init__(self, *args, **kwargs):
        """ Initialization of object """
        self.contents = []  # list to fill with matter
        self.instructions = ''  # preparation instructions
        self.reagents = {}  # reagents log

        Matter.__init__(self)  # update with arguments
        Mixture.__init__(self)  # update with arguments

        self.update(*args, **kwargs)  # update object attributes

        # list of features to print out on call
        self.features += ['instructions']
コード例 #8
0
    def __init__(self, *args, **kwargs):
        """ Initialization of object """
        self.container = ''  # container for sample
        self.contents = []  # list to fill with matter

        Matter.__init__(self)  # update with arguments
        Mixture.__init__(self)  # update with arguments

        self.update(*args, **kwargs)  # update object attributes

        self.volume = self.volume

        # list of features to print out on call
        self.features += ['container']
コード例 #9
0
    def __init__(self, *args, **kwargs):
        """ Initialization of object """

        self.sequence = ''  # species of population
        self.codon_set = 'standard'  # codon set (only supported: standard)
        self.elements = {}  # elements to display in your sequence
        self.material = 'dsDNA'  # dsDNA,ssDNA,dsRNA,ssRNA
        self.form = 'plasmid'  # plasmid,genomic
        self.shape = 'linear'  # linear,circular

        Matter.__init__(self)  # add class features
        Solute.__init__(self)  # add class features

        self.update(*args, **kwargs)  # update object attributes

        self.features += ['material', 'total_volume']  # add printed attributes
コード例 #10
0
 def __init__(self, **kwargs):
     Matter.__init__(self, **kwargs)
     self.accepted_kwargs = {'tall': 0,
                                               'float_offset': plist([0.5, 0.5]),
                                               'float_offset_ranges': plist(((0.25, 0.75),(0.25, 0.75))),
                                               'speed_modifier': 1.0,
                                               'layer': 1.0,
                                               'impassible': False,
                                               'blocksLOS': False 
                                             }
     for key in self.accepted_kwargs.keys():
         if key in kwargs.keys():
             self.__setattr__(key, kwargs[key])
         else:
             self.__setattr__(key, self.accepted_kwargs[key])
     self.pixel_offsets = self.determine_pixel_offset()
コード例 #11
0
    def __init__(self,*args,**kwargs):
        """ Initialization of object """

        self.molecular_weight = 0                        # molecular weight

        self._mass          = 0                          # mass of solute
        self._moles         = 0                          # mols of solute
        self._total_volume  = 0                          # hidden variable, for translating conc.

        self._concentration = 0                          # mass/volume of solute
        self._molarity      = 0                          # mols/volume of solute

        Matter.__init__(self)                            # update with arguments

        self.update(*args,**kwargs)                      # update object attributes

        # add printed attributes
        self.features += ['molecular_weight','mass','moles','concentration','molarity']  
コード例 #12
0
import time
import numpy as np
import matplotlib as mpl
import matplotlib.pyplot as plt
import matplotlib.colors as colors
import matplotlib.cm as cmx
from mpl_toolkits.mplot3d import Axes3D
from matter import Matter

testmat = Matter()

zs = np.arange(0, 2, 0.1)
cmap = plt.get_cmap("summer")
cNorm = colors.Normalize(vmin=np.min(zs), vmax=np.max(zs))
scalarMap = cmx.ScalarMappable(norm=cNorm, cmap=cmap)

# # test transfer function
# testmat.incl_baryons = False
# transfnc_nobaryons = testmat.T()
# testmat.incl_baryons = True
# transfnc = testmat.T()
# fig = plt.figure()
# ax = fig.add_subplot(111)
# ax.loglog(testmat.k, transfnc, 'b', testmat.k, transfnc_nobaryons, 'r')
# fig.savefig("transfncs.pdf")
#
# fig = plt.figure()
# ax = fig.add_subplot(111)
# ax.loglog(testmat.k, transfnc - transfnc_nobaryons)
# fig.savefig("transfnc_diff.pdf")
#
コード例 #13
0
ファイル: matter_test.py プロジェクト: kilianbreathnach/PkABC
import time
import numpy as np
import matplotlib as mpl
import matplotlib.pyplot as plt
import matplotlib.colors as colors
import matplotlib.cm as cmx
from mpl_toolkits.mplot3d import Axes3D
from matter import Matter


testmat = Matter()

zs = np.arange(0, 2, 0.1)
cmap = plt.get_cmap("summer")
cNorm = colors.Normalize(vmin=np.min(zs), vmax=np.max(zs))
scalarMap = cmx.ScalarMappable(norm=cNorm, cmap=cmap)

# # test transfer function
# testmat.incl_baryons = False
# transfnc_nobaryons = testmat.T()
# testmat.incl_baryons = True
# transfnc = testmat.T()
# fig = plt.figure()
# ax = fig.add_subplot(111)
# ax.loglog(testmat.k, transfnc, 'b', testmat.k, transfnc_nobaryons, 'r')
# fig.savefig("transfncs.pdf")
#
# fig = plt.figure()
# ax = fig.add_subplot(111)
# ax.loglog(testmat.k, transfnc - transfnc_nobaryons)
# fig.savefig("transfnc_diff.pdf")
コード例 #14
0
ファイル: Pk_gal.py プロジェクト: kilianbreathnach/PkABC
class Pwspec:
    """
    Object class for computing the analytic galaxy power spectrum as in the
    appendix to Schneider et al, 2006 and Van der Bosch et al, 2013.
    """
    def __init__(self, zvec, k=None, Mmin=1e11, Mmax=1e15):

        """
        - k is a 1-d numpy array of wavenumbers. (unit = Mpc^-1)
        - zvec is 1-d array of central values of the redshift bins
        - Mmin (Mmax) is the minimum (maximum) halo mass. (unit = Msun/h)
        """
        self.k = k
        self.zvec = zvec
#        self.lnm = np.logspace(np.log(Mmin), np.log(Mmax), base=np.exp(1))
        self.set_universe()
	self.precompute()

    def set_universe(self, Om=0.3, OL=0.7, ns=0.96,
                     sig_8=0.81, h=1.0, T_cmb=2.725, h_transf=0.7,
                     k=None, k_min=1.e-3, k_max=2.e3, kbins=1000,
                     lnM_min=np.log(1e11), lnM_max=np.log(1e15),
                     transfer_fit="EH",
                     hmf_fit="Tinker",
                     bias_fit="Tinker"):
        """
        Set the cosmological parameters and fitting functions used for the
        power spectrum calculation. This attribute is an instance of the
        Matter class defined in matter.py, which has functions for computing
        the required dark matter statistics.
        """
        self.universe = Matter(Om=Om, OL=OL, ns=ns,
                               sig_8=sig_8, h=h, T_cmb=T_cmb,
                               h_transf=h_transf,
                               k=k,
                               k_min=k_min, k_max=k_max, kbins=kbins,
                               lnM_min=lnM_min, lnM_max=lnM_max,
                               lnMbins=1000,
                               transfer_fit=transfer_fit,
                               hmf_fit=hmf_fit,
                               bias_fit=bias_fit)

        self.lnm = self.universe.lnM


    def precompute(self):
        """
        Using the k-vector, redshift bins and mass range given to the Pwspec
        object, this function precomputes a list for the redshift values of
        halo mass functions, NFW fourier transforms and halo biases for use in
        computing the galaxy power spectra for various HOD models. These are
        computed using functions from the Matter class which the universe
        attribute is an instance of.
        """
        if not self.universe:
            print "You must first set the universe parameters"

        self.hmflist = []
        self.uglist = []
        self.biaslist = []

        for z in self.zvec:
            self.hmflist.append(self.universe.hmf(z))
            self.uglist.append(self.universe.u_g(z))
            self.biaslist.append(self.universe.bias(z))


    def set_HOD(self, params):
        """
        expects iterable of parameter values in the form
        [Mmin, siglogm, alpha, M_1, Mcut]
        where masses are in log10
        """
        self.HOD = params
        self.compute_nbarlist()


    def compute_nbarlist(self):
        """
        Use the halo mass function and HOD parameters to compute the galaxy
        number density at a given redshift.
        """
        self.nbarlist = []

        for z in self.zvec:
            self.nbarlist.append(nbar_g(self.universe.lnM, self.get_hmf(z), self.HOD))


    def zind(self, z):

        return np.where(self.zvec == z)[0]


    def get_nbar(self, z):

        return self.nbarlist[self.zind(z)]


    def get_hmf(self, z):

        return self.hmflist[self.zind(z)]


    def get_ug(self, z):

        return self.uglist[self.zind(z)]


    def get_Plin(self, z1, z2):
        """
        Compute variance per logarithmic interval in k as per Schneider et al
        """
        g1 = self.universe.gf(z1)
        g2 = self.universe.gf(z2)
        psp = self.universe.normal_p0_lin()

        return g1 * g2 * psp


    def get_bias(self, z):

        return self.biaslist[self.zind(z)]


    def _1h_int(self, z, k_i):
        """
        The integrand for the 1-halo term of the galaxy power spectrum.
        """
        return self.get_hmf(z) * \
                (N_sat(np.exp(self.lnm), self.HOD) ** 2 * \
                self.get_ug(z)[k_i, :] ** 2 + \
                 2 * N_cen(np.exp(self.lnm), self.HOD) * \
                     N_sat(np.exp(self.lnm), self.HOD) * \
                     self.get_ug(z)[k_i, :])


    def P_1h(self, z1, z2):
        """
        1-halo term in the galaxy power spectrum
        """
        if z1 != z2:
            return 0.
        else:
            plist = []
            for i in range(len(self.universe.k)):
                plist.append((1. /  self.get_nbar(z1) ** 2) * \
                              inty(self._1h_int(z1, i), self.lnm))

            return np.array(plist)


    def _I2inty(self, z, k_i):
        """
        The integrand for the 2-halo term of the galaxy power spectrum.
        """
        return self.get_hmf(z) * self.get_bias(z) * \
                (N_cen(np.exp(self.lnm), self.HOD) + \
                 N_sat(np.exp(self.lnm), self.HOD) * self.get_ug(z)[k_i, :])


    def I_2(self, z):
        """
        Integral 2-halo term in the galaxy power spectrum
        """
        ilist = []
        for i in range(len(self.universe.k)):
            ilist.append((1. / self.get_nbar(z)) * \
                          inty(self._I2inty(z, i), self.lnm))

        return np.array(ilist)


    def P_2h(self, z1, z2):
        """
        2-halo term in the galaxy power spectrum
        """
        # TODO : after finishing matter.py, modify this accordingly

        return self.get_Plin(z1, z2) * self.I_2(z1) * self.I_2(z2)


    def P_g(self, z1, z2):
        """
        Galaxy power spectrum
        Auto (Cross) power spectrum if z1=z2(z1!=z2)
        """
        if not (z1 in self.zvec) * (z2 in self.zvec):

            raise ValueError("These redshifts are not in the precomputed redshift values")

        return self.P_1h(z1, z2) + self.P_2h(z1, z2)