# this code calculates and plots the cumulative PM and 3D velocity for all snaps in all simulations that are read in from an input text file

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 = []
Пример #2
0
# Code to plot x-y plane for 20 simulations to investigate unbound behaviour

import numpy as np
import matplotlib.pyplot as plt
from itertools import product
from fractions import Fraction
import matplotlib.ticker as ticker

#%%

from function_file import read_in_any_datafiles, energy_stars, plots_legend, velocity_elements
#reads in the .dat files from an inputfile list
dflist, dname, nlines = read_in_any_datafiles('file.txt')

#calculates energy of each star in each snapshot and adds this in a column
dflist = energy_stars(dflist, dname, nlines)

#calculates the radius/position of each star after COD-correction
#dflist = COD_corrected_location(dflist,dname,nlines)

#calculates the velocity (distance travelled/snapshot length
dflist = velocity_elements(dflist, dname, nlines)

#adds column identifying stars outside 2 half-mass radius
#dflist = stars_in_outside_2HMR(dflist, dname, nlines)

#creates the legend for for plots of single simulations
legend = plots_legend(dname)

#%%
# i,time(i),id(i),mass(i),rad(i,1:3),vel(i,1:3),ccname(i),cctime(i),d2cc(i)

# this code calculates and plots the cumulative radial velocity for all snaps


import pandas as pd
import numpy as np
import matplotlib.pyplot as plt

from function_file import read_in_datafiles, velocity_elements, energy_stars, stars_outside_2HMR

dflist,d  = read_in_datafiles('file20.txt')

dname = sorted(d.values())

dflist = energy_stars(dflist,dname)       
dflist = velocity_elements(dflist,dname)
dflist = stars_outside_2HMR(dflist,dname)
 


#%%

for n in range(20):
    dflist[n].UB = (dflist[n].loc[dflist[n]['Unbound'] == True])  
#    dflist[n].B = (dflist[n].loc[dflist[n]['Unbound'] == False])  
#    dflist[n].ESC = (dflist[n].loc[dflist[n]['escaped'] == True])  
            


#%%