posydon_popsyn

posydon_popsyn.check_SN_MODEL_validity(ini_file, verbose_on_fail=True)[source]

Checks if the step_SN model is valid for this script

Parameters:
  • ini_file (str) – the path to the ini file

  • verbose_on_fail (bool (default: True)) – if True rerun the model selection with verbose mode if this failed

Returns:

True if the model is valid or use_interp_values=False, False otherwise

Return type:

bool

posydon_popsyn.check_batches(run_folder, metallicity, batch_folder_name)[source]

Check batch files for a specific metallicity when the population file is missing.

Parameters:
  • run_folder (str) – Path to the folder where the population run is located

  • metallicity (float) – Metallicity to check

  • batch_folder_name (str) – Name of the folder containing batch files

Returns:

Dictionary with batch information

Return type:

dict

posydon_popsyn.check_binary_counts(run_folder, metallicities, expected_count)[source]

Check if each population file has the expected number of binaries.

Parameters:
  • run_folder (str) – Path to the folder where the population run is located

  • metallicities (list of floats) – List of metallicities to check in solar units

  • expected_count (int) – Expected number of binaries per file

Returns:

  • bool – True if all counts match, False otherwise

  • dict – Dictionary with metallicity as key and binary count as value

posydon_popsyn.check_popsyn_function(args)[source]

Function to check the status of a population run.

Parameters:

args (argparse.Namespace) – The arguments passed to the function

posydon_popsyn.check_population_files(run_folder, metallicities)[source]

Check if all merged population files exist.

Parameters:
  • run_folder (str) – Path to the folder where the population run is located

  • metallicities (list of floats) – List of metallicities to check in solar units

Returns:

  • bool – True if all files exist, False otherwise

  • dict – Dictionary with metallicity as key and existence status as value

posydon_popsyn.clear_previous_lines(num_lines)[source]

Clear the specified number of previous lines in the terminal.

Parameters:

num_lines (int) – Number of lines to clear

posydon_popsyn.create_merge_script(ini_file)[source]

Creates a merge script for the population synthesis run.

Parameters:

ini_file (str) – Path to the .ini file containing population synthesis parameters.

posydon_popsyn.create_run_script(ini_file)[source]

Creates a run script for the population synthesis run.

Parameters:

ini_file (str) – Path to the .ini file containing population synthesis parameters.

posydon_popsyn.create_slurm_merge(metallicity, partition, email, merge_walltime, account, mem_per_cpu, path_to_posydon, path_to_posydon_data)[source]

Creates the slurm submit script for merging population synthesis results.

Creates a SLURM submission script file named “{str_met}_Zsun_merge_popsyn.slurm” where str_met is the metallicity converted to string format.

Parameters:
  • metallicity (float) – The metallicity in solar units (e.g., 0.02 for Z=0.02)

  • partition (str, optional) – SLURM partition to submit the job to

  • email (str, optional) – Email address for job notifications

  • merge_walltime (str) – Time limit for the merge job in SLURM format (e.g., “12:00:00”)

  • account (str, optional) – SLURM account to charge the job to

  • mem_per_cpu (str) – Memory per CPU allocation (e.g., “4G”)

  • path_to_posydon (str) – Path to the POSYDON installation

  • path_to_posydon_data (str) – Path to the POSYDON_DATA directory

posydon_popsyn.create_slurm_submit(metallicity, job_array_length, partition, email, walltime, account, mem_per_cpu, path_to_posydon, path_to_posydon_data)[source]

Creates the slurm submit script for population synthesis job arrays.

Creates a SLURM submission script file named “{str_met}_Zsun_slurm_array.slurm” where str_met is the metallicity converted to string format.

Parameters:
  • metallicity (float) – The metallicity in solar units (e.g., 0.02 for Z=0.02)

  • job_array_length (int) – The length of the job array (number of jobs)

  • partition (str, optional) – SLURM partition to submit the job to

  • email (str, optional) – Email address for job notifications

  • walltime (str) – Time limit for the job in SLURM format (e.g., “24:00:00”)

  • account (str, optional) – SLURM account to charge the job to

  • mem_per_cpu (str) – Memory per CPU allocation (e.g., “4G”)

  • path_to_posydon (str) – Path to the POSYDON installation

  • path_to_posydon_data (str) – Path to the POSYDON_DATA directory

posydon_popsyn.generate_rescue_script(args, batch_status)[source]

Generate a script to resubmit failed runs.

Parameters:
  • args (argparse.Namespace) – The arguments passed to the CLI

  • batch_status (dict) – Dictionary with batch status information

Returns:

Path to the generated rescue script

Return type:

str

posydon_popsyn.get_binary_params(ini_file)[source]

Read the binary population parameters from the INI file

Parameters:

ini_file (str) – The path to the INI file

Returns:

  • int – The number of metallicities

  • int – The number of binaries

  • list of floats – The list of metallicities in solar units

  • dict – The dictionary of population synthesis parameters from the INI file

posydon_popsyn.get_ini_file(args)[source]

Find and select the INI file for the population synthesis run.

Parameters:

args (argparse.Namespace) – Command line arguments that needs to containing the run_folder path.

Returns:

Path to the selected INI file.

Return type:

str

Raises:

FileNotFoundError – If no INI file is found in the run folder.

posydon_popsyn.rescue_popsyn_function(args)[source]

Function to rescue a failed population run.

Creates resubmission scripts for failed batch jobs.

Parameters:

args (argparse.Namespace) – The arguments passed to the function

posydon_popsyn.setup_popsyn_function(args)[source]

Function to setup the population synthesis run

Parameters:

args (argparse.Namespace) – the arguments passed to the function