posydon.CLI

posydon.CLI.io

Module for input/output operations in the CLI of Posydon.

posydon.CLI.io.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.CLI.io.create_bash_submit_rescue_script(filename, rescue_scripts)[source]

Generate a bash script to submit rescue scripts.

Parameters:
  • filename (str) – The name of the bash submission script to create

  • rescue_scripts (list of str) – The list of rescue script paths

posydon.CLI.io.create_bash_submit_script(filename, metallicities)[source]

Creates the bash submission script for all SLURM jobs.

Parameters:
  • filename (str) – The name of the bash submission script to create

  • metallicities (list of float) – The list of metallicities in solar units

posydon.CLI.io.create_batch_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.CLI.io.create_merge_script(ini_file)[source]

Creates a merge script for the population synthesis run.

The created merge script will combine the “evolution.combined.h5” files from the different job arrays in the “temp_directory” into a single “{MET}_Zsun_population.h5” file in the run directory.

Parameters:

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

posydon.CLI.io.create_merge_script_text(ini_file)[source]
posydon.CLI.io.create_python_scripts(ini_file)[source]

Creates the run and merge scripts for population synthesis.

Parameters:

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

posydon.CLI.io.create_run_script(ini_file)[source]

Creates a run script for the population synthesis run.

This function creates a script that will run the POSYDON population at a specific metallicity. The script takes a metallicity as a command-line input. It uses that metallicity to run the BinaryPopulation with.

Parameters:

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

posydon.CLI.io.create_run_script_text(ini_file)[source]
posydon.CLI.io.create_slurm_array(metallicity, job_array_length, partition, email, walltime, account, mem_per_cpu, path_to_posydon, path_to_posydon_data)[source]

Creates the slurm array 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.CLI.io.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.CLI.io.create_slurm_rescue(metallicity, missing_indices, job_array_length, partition, email, walltime, account, mem_per_cpu, path_to_posydon, path_to_posydon_data)[source]

Creates the slurm rescue script for resubmitting failed population synthesis jobs.

Creates a SLURM submission script file named “{str_met}_Zsun_rescue.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)

  • missing_indices (list of int) – List of failed job indices to resubmit

  • job_array_length (int) – The original 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.CLI.io.create_slurm_scripts(metallicity, args)[source]

Creates the slurm scripts for population synthesis.

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

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

posydon.CLI.io.print_error(message)[source]

Print an error message in red.

Parameters:

message (str) – The error message to print

posydon.CLI.io.print_separator_line()[source]

Print a separator line.

posydon.CLI.io.print_separator_section()[source]

Print a section separator line.

posydon.CLI.io.print_success(message)[source]

Print a success message in green.

Parameters:

message (str) – The success message to print