dflist,d = read_in_datafiles('file20.txt') dname = sorted(d.values()) dflist = stars_outside_2HMR(dflist,dname) #%% print the count the number of stars outside 2xHMR in a snapshot.... print (dname[5]) print (dflist[5].loc[10]['escaped'].value_counts()) #%% dflist = velocity_elements(dflist,dname) for n in range(20): dflist[n]['3D-vel'] = (np.sqrt(dflist[n]['velx']**2.+dflist[n]['vely']**2.+dflist[n]['velz']**2.)) dflist[n]['3D-veldist'] = (np.sqrt(dflist[n]['xvel']**2.+dflist[n]['yvel']**2.+dflist[n]['zvel']**2.)) dflist[n]['PM-vel'] = (np.sqrt(dflist[n]['velx']**2.+dflist[n]['vely']**2.)) dflist[n]['PM-veldist'] = (np.sqrt(dflist[n]['xvel']**2.+dflist[n]['yvel']**2.)) dflist[n].ESC = (dflist[n].loc[dflist[n]['escaped'] == True]) ESClist = [dflist[0].ESC, dflist[1].ESC, dflist[2].ESC, dflist[3].ESC, dflist[4].ESC,dflist[5].ESC,dflist[6].ESC,dflist[7].ESC,dflist[8].ESC,dflist[9].ESC,dflist[10].ESC, \ dflist[11].ESC, dflist[12].ESC, dflist[13].ESC, dflist[14].ESC, dflist[15].ESC, dflist[16].ESC, dflist[17].ESC, dflist[18].ESC,dflist[19].ESC] ESC = pd.concat(ESClist) #%% plots umulative velocity distribution for unbound stars at 5 Myr as PM-velocity and 3D-velocity
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Fri May 18 13:48:50 2018 @author: php17cs """ import numpy as np from function_file import read_in_any_datafiles, velocity_elements, plots_legend #reads in the .dat files from an inputfile list dflist, dname, nlines = read_in_any_datafiles('file.txt') #calculates the velocity (distance travelled/snapshot length dflist = velocity_elements(dflist, dname, nlines) #creates the legend for for plots of single simulations legend = plots_legend(dname) j = 50 velocity = 'PM-velxy' dflist_mean = np.empty(1000) for line in range(1000): dflist_sumlist = [] for n in range(nlines): dflist_sumlist.append( (dflist[n].loc[j].sort_values(velocity)[velocity]).iloc[line]) dflist_mean[line] = (np.mean(dflist_sumlist))
import pandas as pd import numpy as np import matplotlib.pyplot as plt from matplotlib.ticker import AutoMinorLocator #import F_COD_Radius_Nstars as CODRN #turn this on, if COD-correcion is required. from function_file import read_in_any_datafiles, velocity_elements, energy_stars, stars_in_outside_2HMR dflist, dname, nlines = read_in_any_datafiles( 'file.txt') #this reads in the .dat files from an inputfile list dflist = energy_stars( dflist, dname, nlines ) #this calculates the energy of each star in each snapshot an simulation and adds this in a column dflist = velocity_elements( dflist, dname, nlines ) #this calculates the velocity by using the distance travelled between each snapshot and divides it by snapshot length - this is an alternative to the provided velocities from the simulation dflist = stars_in_outside_2HMR( dflist, dname, nlines ) # this calculates the half-mass radius based on centre of density corrected locations and then adds a column identifying if the stars are inside or outside 2*HMR # different velocity distributions are calculated, e.g. 3D and PM for the original velocity data velx - velz and the velocities calculated by using the distance travelled between each snapshot. #both are expressed in km/s #%% this cell produces dataframes for each simulation containing the unbound/escaped stars, # this cell also creates dataframes for each simulation containing the high-mass and low-mass unbound and escaped stars. dflistUB = [] dflistESC = [] dflistHMUB = [] dflistHMESC = [] dflistHMall = []