Python Scripts
scripts/plot_asloth.py
- scripts.plot_asloth.plot_comparison(UserFolder, UserLabels=None)
Function to plot results from A-SLOTH and compare them to literature or other runs.
We use the most recent folder to plot and compare to literature. If one or more folders are specified, they will all be plotted. This can also be used to plot just one specific folder.
- Parameters
UserFolder (list[str]) – List of folder names to be plotted.
UserLabels (list[str]) – List of labels. If none, UserFolders are used as labels
Returns: Beautiful plots
- scripts.plot_asloth.readMWproperties(UserFolder)
scripts/tau/plot_Vion.py
- tau.plot_Vion.plot_Vion(UserFolder, UserLabels, folder_output)
Function to plot ionisation histories and calculate tau
- Parameters
UserFolder (List[str]) – List of folder names to be plotted
UserLabels (List[str]) – List of labels. If none, UserFolders are used as labels
folder_output (str) – Folder in which plots will be saved
- Returns
tau0 (float) – optical depth to Thomson scattering
tau_sigma (float) – tau uncertainty
- tau.plot_Vion.get_tau_sigma(folder)
Function to calculate tau without plotting ionisation history
- Parameters
folder (str) – Folder in which plots will be saved
- Returns
tau0 (float) – optical depth to Thomson scattering
tau_sigma (float) – tau uncertainty
scripts/wrapper
This script allows to explore input parameters by automatically launching various runs. Users can set their specific path_output variable. If you want to run with NBODY merger trees, also set path_tree. If you think that disk I/O might be a bottleneck, you should also set your username in the function N_disk_sleep() to work correctly.
- wrapper.loop_trees.RunTrees(cats, NBODY)
This function loops over a set of merger trees and explores one combination of input parameters
We first define input parameters that are constant within this loop. Then, we define tree-specific input parameters. Then, we check if sufficient computing resources are available. Eventually, we launch the A-SLOTH run.
- Parameters
cats (list) – catalogue of merger trees [[name, nlev, RAM]]
NBODY (bool) – N-Body or EPS-generated merger trees
- wrapper.loop_trees.Get_CatList(NBODY=False, N=3)
Function to generate list of catalogues to loop over
- Parameters
NBODY (bool) – N-Body or EPS-generated merger trees
N (int) – number of random realisations in case of EPS-generated trees
- Returns
cats – list of lists of type [[name, nlev, RAM]]
- Return type
list
- wrapper.loop_trees.avail_mem_GB()
Funtion returns available RAM in GB
- wrapper.loop_trees.CPU_use()
Funtion returns available CPUs in %
- wrapper.loop_trees.N_disk_sleep()
Funtion returns number of processes that are idle due to I/O.
Change username accordingly
- wrapper.analyse_trees.get_p_from_folders(dir_prefix, ifEPS=True)
Function that calculates the p-value (and additional values).
Based on the directory prefix for the A-SLOTH output folder that should be analysed Function will you all folders that match this directory prefix.
- Parameters
dir_prefix (str) – directory prefix that should be used to search for data
- Returns
fit_asloth – class object that contains fit results
- Return type
- wrapper.tutorial_GridPlot.plot_tutorial2()
Plotting script to visualise results of the two scripts loop_scripts.py and analysis_trees.py.
The plot layout is not optimized for aesthetics, but it should simply demonstrate the versatility of A-SLOTH. The resulting plot is a modified version of Fig. 17 in Hartwig+22
scripts/tau/plot_tgas.py
- utilities.plot_tgas.plot_tgas(output_folder)
Illustrates time evolution of different baryonic quantities based on output file t_gas_substeps.dat. outout_folder has to be set manually.
- Parameters
output_folder (str) – folder that contains results of run that should be analysed
scripts/utility.py
- class utilities.utility.asloth_config
container class for writing config namelist files for ASLOTH
- set_config_to_default()
sets default parameters for the main configuration
- Parameters
self (asloth_config) – the configuration to be restored to defaults
- set_metals(metals)
sets metal configuration for a specified list of elements
- Parameters
self (asloth_config) – configuration
metals (list) – list of strings of the elements to be traced
- to_file(fname)
- class utilities.utility.asloth_fit
class for handling fitting parameters and results of A-SLOTH
- get_p()
‘ Calculates the goodness-of-fit parameters based on 6 different observables. Please see Hartwig+22 for more details.
- print_fit()
‘ Prints all class properties
- set_fit_to_default()
sets default parameters for the fit object
- Parameters
self (asloth_fit) – set all parameters to default values
- utilities.utility.get_p_from_sigma(sigma)
Get p-value from “how many sigma away”
- utilities.utility.write_namelist(f, list_name, var_dict)
function to write fortran namelists
- Parameters
f (file) – opened file to write the namelist to
list_name (str) – name of the namelist. Note that this must be the exact name used in the fortran code
var_dict (dictionary) – dictionary of variables to be written to the file
scripts/SMHM/plot_scatterSMHM.py
- SMHM.plot_scatterSMHM.plot_scatterSMHM(UserFolder, UserLabels, folder_output)
Function to read data and plot scatter SMHM relation.
If one or more folders are specified, they will all be plotted. This can also be used to plot just one specific folder.
- Parameters
UserFolder (str) – List of folder names to be plotted.
UserLabels (str) – List of labels. If none, UserFolders are used as labels.
folder_output (str) – where the plot is saved.
- Returns
None
- SMHM.plot_scatterSMHM.plot_CumuSMF(UserFolder, UserLabels, folder_output, if_plot)
Function to return ks statistics, p-values, and MW stellar masses
If one or more folders are specified, they will all be plotted. This can also be used to plot just one specific folder.
- Parameters
UserFolder (str) – List of folder names to be plotted.
UserLabels (str) – List of labels. If none, UserFolders are used as labels.
folder_output (str) – where the plot is saved.
- Returns
Lists of ks statistic, p-value and MW stellar mass.
- SMHM.plot_scatterSMHM.read_data(UserFolder, UserLabels, folder_output)
Function to read data to plot SMHM relation
If one or more folders are specified, they will all be plotted. This can also be used to plot just one specific folder.
- Parameters
UserFolder (str) – List of folder names to be plotted.
UserLabels (str) – List of labels. If none, UserFolders are used as labels
folder_output (str) – where the plot is saved
- Returns
Virial masses and stellar masses of galaxies in pandas.DataFrame format
- SMHM.plot_scatterSMHM.M_AM(M)
Function to compute expected stellar mass of the galaxy at given virial mas (Garrison-Kimmel et al. 2014).
- Parameters
M (float) – virial mass of the halo
- Returns
expected stellar mass
- SMHM.plot_scatterSMHM.f_bwc(x)
- SMHM.plot_scatterSMHM.AMtwodhistogram(df_list, y0, p_dir, output_name, WhichMass, climmax, if_imfana)
The actual function to plot scatter SMHM relation.
- Parameters
df_list (list of pd.DataFrame) – input data
y0 (float) – the observational completeness
p_dir (str) – output folder
Returns:
- SMHM.plot_scatterSMHM.CumulativeNumberOfSatellites(df_list, output_name, WhichMass, if_plot, p_dir)
The actual function to plot cumulative stellar mass function and compute ks statistic, p-value from the KS test.
- Parameters
df_list (list of pd.DataFrame) – input data
output_name (str) – figure name
WhichMass (float) – which stellar mass to use (the total or survival)
if_plot (bool) – whether to make plots or not
p_dir (str) – output folder
- Returns
lists of ks statistic, p-value, MW stellar mass
scripts/SMHM/plot_binnedSMHM.py
- SMHM.plot_binnedSMHM.plot_binnedSMHM(UserFolder, UserLabels, folder_output)
The function reads data from multiple folders and plot the binned SMHM relations
If one or more folders are specified, they will all be plotted as separate SMHM relations. This can also be used to plot just one specific folder.
- Parameters
UserFolder (str) – List of folder names to be plotted.
UserLabels (str) – List of labels. If none, UserFolders are used as labels
folder_output (str) – where the plot is saved
- Returns
plot of SMHM relation comparison
- SMHM.plot_binnedSMHM.IMFANA(AMBound, MX, MAMX, imf_list, y0, p_dir, imfname, WhichMass, climmax, cps, cs, ilabel, fname)
The function plots binned SMHM relation.
- Parameters
AMBound – boundary of the SMHM relation from abundance matching (AM)
MX – virial masses
MAMX – stellar masses obtained from the AM technique at given virial masses
imf_list (list of pd.DataFrame) – input data
y0 (float) – observational completeness
p_dir (str) – output folder
- Returns
plot of SMHM relation
- SMHM.plot_binnedSMHM.AM_BinMeanstd(df_list, WhichMass, tname, index_data, c=None)
The actual function to plot binned SMHM relation.
- Parameters
df_list (list of pd.DataFrame) – input data
WhichMass (float) – which stellar mass to use (the total or survival)
tnmae (str) – labels
index-data – index of the data
c – specific color for the SMHM relation
- Returns
adding a binned SMHM relation to the plot
- SMHM.plot_binnedSMHM.PlotNadler20SMHM()
The function plots SMHM relation from Nadler et al. 2020.
scripts/plot_mcrit.py
- utilities.plot_mcrit.plot_mcrit()
Function to plot ciritical mass of a halo at certain redshift, given by different models, and at different initial streaming velocities.
- Returns
Figure that shows M_crit v.s. z at different initial streaming velocities and from different models
- utilities.plot_mcrit.crit_mass(z, lw_mode, VBC)
Function to obtain ciritical mass of a halo at certain redshift, given by different models
We use lw_mode=5 (Schauer et al. 2021) as the fiducial model. Use can also choose lw_mode=4, which is a combined model from O’Shea et al. 2008, Stacy et al. 2011, and Hummel et al. 2012. lw_mode=7 corresponds to a model from Fialkov et al. 2013.
- Parameters
z (float) – redshift
lw_mode (int) – which M_crit model
VBC (float) – initial streaming velocity, in units of sigma_v
- Returns
Critical mass of a halo to have star formation
scripts/plot_stellarprop.py
- utilities.plot_stellarprop.plot_stellarproperties()
Function to reproduce the stellar properties plot
- Returns
Stellar masses v.s. stellar properties, e.g. stellar lifetime, carbon yields, iron yields, supernova energie.