valska.external_tools.bayeseor.setup

Prepare BayesEoR run directories, configs, and submit scripts.

Functions

prepare_bayeseor_run(*, template_yaml, ...)

Prepare a BayesEoR run directory containing hypothesis-specific artefacts.

valska.external_tools.bayeseor.setup._apply_antenna_diameter_perturbation(cfg: ruamel.yaml.comments.CommentedMap, *, antenna_diameter_perturb_frac: float | None) dict[str, Any] | None
If provided, apply a multiplicative perturbation to antenna_diameter:

antenna_diameter <- antenna_diameter * (1 + antenna_diameter_perturb_frac)

valska.external_tools.bayeseor.setup._apply_fwhm_perturbation(cfg: ruamel.yaml.comments.CommentedMap, *, fwhm_perturb_frac: float | None) dict[str, Any] | None
If provided, apply a multiplicative perturbation to fwhm_deg in the config:

fwhm_deg <- fwhm_deg * (1 + fwhm_perturb_frac)

valska.external_tools.bayeseor.setup._as_flow_seq(seq: Any) ruamel.yaml.comments.CommentedSeq

Convert a sequence into a flow-style ruamel sequence, and ensure any nested sequences also become flow-style. This preserves the compact prior formatting.

valska.external_tools.bayeseor.setup._default_variant_from_template(template_yaml: Path) str

Derive a stable variant key from a template filename.

Rules (align with CLI):
  • take filename stem

  • remove first occurrence of “_template” if present

  • strip leading/trailing underscores

Examples:

validation_v1d0_template.yaml -> validation_v1d0 validation_v1d0_template_achromatic.yaml -> validation_v1d0_achromatic validation_achromatic_Gaussian.yaml -> validation_achromatic_Gaussian

valska.external_tools.bayeseor.setup._dump_yaml(data: Mapping[str, Any], path: Path) None

Write YAML using ruamel round-trip formatting.

valska.external_tools.bayeseor.setup._load_yaml(path: Path) ruamel.yaml.comments.CommentedMap

Load a YAML file preserving comments and formatting.

valska.external_tools.bayeseor.setup._materialise_hypothesis_config(base_cfg: ruamel.yaml.comments.CommentedMap, *, hypothesis: str, run_dir: Path) ruamel.yaml.comments.CommentedMap
Create a hypothesis-specific BayesEoR config:
  • sets output_dir under run_dir/output/<hypothesis>

  • selects priors from signal_fit_priors / no_signal_priors (fallback to priors)

  • removes hypothesis-specific prior keys from the rendered config

valska.external_tools.bayeseor.setup._runner_manifest(runner: CondaRunner | ContainerRunner) dict[str, Any]

Return a serializable runner description for the manifest.

valska.external_tools.bayeseor.setup._utc_stamp() str

Return a UTC timestamp suitable for directory naming.

valska.external_tools.bayeseor.setup.prepare_bayeseor_run(*, template_yaml: Path, install: BayesEoRInstall, runner: CondaRunner | ContainerRunner, results_root: Path, beam_model: str, sky_model: str, run_label: str, data_path: Path, overrides: Mapping[str, Any] | None = None, slurm: Mapping[str, object] | None = None, slurm_cpu: Mapping[str, object] | None = None, slurm_gpu: Mapping[str, object] | None = None, run_dir: Path | None = None, run_id: str = 'default', variant: str | None = None, unique: bool = False, fwhm_perturb_frac: float | None = None, antenna_diameter_perturb_frac: float | None = None, hypothesis: str = 'both') dict[str, Path]

Prepare a BayesEoR run directory containing hypothesis-specific artefacts.

Canonical non-sweep layout (when run_dir is None):

<results_root>/bayeseor/<beam_model>/<sky_model>/<variant>/<run_label>/<run_id>[/<UTCSTAMP>]

The variant defaults to a value derived from the template filename stem (first occurrence of _template removed). If unique=True, a UTC timestamp is appended beneath run_id.

At most one perturbation mode can be active. fwhm_perturb_frac applies a multiplicative perturbation to fwhm_deg. antenna_diameter_perturb_frac applies a multiplicative perturbation to antenna_diameter.

A single shared CPU precompute script is generated and pointed at an available hypothesis config (signal_fit preferred when both are present).

Returns

dict

Paths to created artefacts (configs, submit scripts, manifest), plus run_dir.