예제 #1
0
    def __init__(self, galaxy, snap):
        # Set the galaxy name as a global variable
        self.gname = galaxy

        # Define Gravitational constant in our units
        self.G = c.G.to(u.kpc * u.km**2 / u.s**2 / u.Msun)

        # add a string of the filenumber to the value “000”
        ilbl = '000' + str(snap)
        # remove all but the last 3 digits
        ilbl = ilbl[-3:]

        # create the filename as a global variable
        self.filename = "{:s}_{:s}.txt".format(self.gname, ilbl)

        # Read in the file and particle type
        self.time, self.total, self.data = read(self.filename)

        # Store the mass of only the particles of the given type
        self.m = self.data['m']

        # Store the position values of only the particles of the given type
        self.X = self.data['x'] * u.kpc
        self.Y = self.data['y'] * u.kpc
        self.Z = self.data['z'] * u.kpc

        return None
예제 #2
0
def ParticleInfo(filename, par_type,
                 par_num):  #this defines the function ParticleInfor

    time, total, data = read(
        filename
    )  #This will read the file specifically the values for time, total, and data

    index = np.where(
        data['type'] ==
        par_type)  #Index for all particles with given property of par_type

    xnew = data['x'][index][par_num]  #the new x-value
    ynew = data['y'][index][par_num]  # the new y-value
    znew = data['z'][index][par_num]  # the new z-value
    vxnew = data['vx'][index][par_num]  # the new vx-value
    vynew = data['vy'][index][par_num]  # the new vy-value
    vznew = data['vz'][index][par_num]  # the new vz-value
    mnew = data['m'][index][par_num]  # the new m-value

    R = np.sqrt(xnew**2 + ynew**2 +
                znew**2) * u.kpc  # Radius or magnitude of the distance in kpc
    V = np.sqrt(vxnew**2 + vynew**2 + vznew**2
                ) * u.km / u.s  # Velocity or magnitude of the velocity in km/s
    M = mnew * u.solMass  # Mass in units of solar mass

    return R, V, M
예제 #3
0
def ComponentMass(FileName, PType):
    # Read the data from the file
    time, N_particles, data = read(FileName)

    # Selects data for particles of chosen type
    index = where(around(data['type'], 3) == PType)
    Particle = data[index]

    # Finds only the mass information
    # converts to proper units and sums
    mass = Particle['m'] * 10**10 * u.Msun
    Mass = around(sum(mass), 3)

    return Mass
예제 #4
0
    def __init__(self, filename, ptype):
        # Initialize the instance of this Class with the following properties:

        # read data in the given file using Read
        self.time, self.total, self.data = read(filename)

        #create an array to store indexes of particles of desired Ptype
        self.index = np.where(self.data['type'] == ptype)

        # store the mass, positions, velocities of only the particles of the given type
        self.m = self.data['m'][self.index]
        self.x = self.data['x'][self.index]
        self.y = self.data['y'][self.index]
        self.z = self.data['z'][self.index]
        self.vx = self.data['vx'][self.index]
        self.vy = self.data['vy'][self.index]
        self.vz = self.data['vz'][self.index]
예제 #5
0
    def __init__(self, galaxy, snap):
        # add a string of the filenumber to the value "000"
        ilbl = '000' + str(snap)
        # remove all but the last 3 digits
        ilbl = ilbl[-3:]
        self.filename = "%s_"%(galaxy) + ilbl + '.txt'
        
        
        # Reading in the data
        self.time, self.total, self.data = read(self.filename)
        self.type = self.data['type']
        self.m = self.data['m']
        self.x = self.data['x']*u.kpc
        self.y = self.data['y']*u.kpc
        self.z = self.data['z']*u.kpc

        self.gname = galaxy
예제 #6
0
def ComponentMass(filename, par_type):
    # Inputs:
    # filename, this designates the file from which data will be taken from
    # par_type designates the particle type, which are classified by numbers 1-3 with 1 being Halo type, 2 being Disk type, and 3 being Bulge type.

    #Returns:
    # M_tot, this is the total mass of a specific galaxy component

    time, total, data = read(
        filename)  #This will pull those 3 'data sets' from the ReadFile

    index = np.where(data['type'] ==
                     par_type)  # This creates an index for all the particles

    mnew = data['m'][
        index] * 1e10 * u.Msun  #This stores the components in the index and for final answer clarity sake was multiplied by 1e10 to clear up the 10^10 Msun that the masses are labeled as in the file

    M_tot = np.sum(mnew)  #This is the total mass
    return M_tot
예제 #7
0
    def __init__(self, filename, ptype):
        # Read in the file and particle type
        self.time, self.total, self.data = read(filename)

        # Create an array to store indexes of particles of desired Ptype
        self.index = np.where(self.data['type'] == ptype)

        # Store the mass of only the particles of the given type
        self.m = self.data['m'][self.index] * 1e10 * u.Msun

        # Store the position values of only the particles of the given type
        self.X = self.data['x'][self.index] * u.kpc
        self.Y = self.data['y'][self.index] * u.kpc
        self.Z = self.data['z'][self.index] * u.kpc

        # Store the velocity values of only the particles of the given type
        self.Vx = self.data['vx'][self.index] * u.km / u.s
        self.Vy = self.data['vy'][self.index] * u.km / u.s
        self.Vz = self.data['vz'][self.index] * u.km / u.s

        return None
예제 #8
0
# Homework 4