Configuration API¶
Hierarchical configuration with pydantic v2 models.
Provides a single-source-of-truth PcleanConfig that can be
built from:
Direct Python construction (
PcleanConfig(image=ImageConfig(...))).A YAML file (
PcleanConfig.from_yaml('config.yaml')).Layered composition (
PcleanConfig.merge(base, overlay)).The flat
pclean()kwargs for backward compatibility (PcleanConfig.from_flat_kwargs(...)).
The resulting config can be converted to CASA-native dicts via the
to_casa_*() bridge methods, or to the legacy PcleanParams via
PcleanConfig.to_params() (deprecated).
- class pclean.config.SelectionConfig(*, vis='', field='', spw='', timerange='', uvrange='', antenna='', scan='', observation='', intent='', datacolumn='corrected')[source]¶
Bases:
BaseModelData selection parameters.
- Parameters:
- model_config = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class pclean.config.ImageConfig(*, imagename='', imsize=<factory>, cell='1arcsec', phasecenter='', stokes='I', projection='SIN', startmodel='', specmode='mfs', reffreq='', nchan=-1, start='', width='', outframe='LSRK', veltype='radio', restfreq=<factory>, interpolation='linear', perchanweightdensity=True, nterms=2)[source]¶
Bases:
BaseModelImage definition parameters.
- Parameters:
- model_config = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class pclean.config.GridConfig(*, gridder='standard', facets=1, wprojplanes=1, vptable='', mosweight=True, aterm=True, psterm=False, wbawp=True, conjbeams=False, cfcache='', usepointing=False, computepastep=360.0, rotatepastep=360.0, pointingoffsetsigdev=<factory>, pblimit=0.2, normtype='flatnoise', psfphasecenter='')[source]¶
Bases:
BaseModelGridding parameters.
- Parameters:
- model_config = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class pclean.config.WeightConfig(*, weighting='natural', robust=0.5, noise='1.0Jy', npixels=0, uvtaper=<factory>, fracbw=None)[source]¶
Bases:
BaseModelWeighting parameters.
- Parameters:
- model_config = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class pclean.config.DeconvolutionConfig(*, deconvolver='hogbom', scales=<factory>, nterms=2, smallscalebias=0.0, fusedthreshold=0.0, largestscale=-1, restoration=True, restoringbeam=<factory>, pbcor=False, usemask='user', mask='', pbmask=0.0, sidelobethreshold=3.0, noisethreshold=5.0, lownoisethreshold=1.5, negativethreshold=0.0, smoothfactor=1.0, minbeamfrac=0.3, cutthreshold=0.01, growiterations=100, dogrowprune=True, minpercentchange=0.0, verbose=False, fastnoise=True, python_automask=True)[source]¶
Bases:
BaseModelDeconvolution and masking parameters.
- Parameters:
deconvolver (str)
nterms (int)
smallscalebias (float)
fusedthreshold (float)
largestscale (int)
restoration (bool)
pbcor (bool)
usemask (str)
mask (str)
pbmask (float)
sidelobethreshold (float)
noisethreshold (float)
lownoisethreshold (float)
negativethreshold (float)
smoothfactor (float)
minbeamfrac (float)
cutthreshold (float)
growiterations (int)
dogrowprune (bool)
minpercentchange (float)
verbose (bool)
fastnoise (bool)
python_automask (bool)
- model_config = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class pclean.config.IterationConfig(*, niter=0, gain=0.1, threshold='0.0mJy', nsigma=0.0, cycleniter=-1, cyclefactor=1.0, minpsffraction=0.05, maxpsffraction=0.8, interactive=False, nmajor=-1, fullsummary=False)[source]¶
Bases:
BaseModelIteration control parameters.
- Parameters:
- model_config = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class pclean.config.MiscConfig(*, restart=True, savemodel='none', calcres=True, calcpsf=True, psfcutoff=0.35)[source]¶
Bases:
BaseModelMiscellaneous parameters.
- model_config = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class pclean.config.NormConfig(*, pblimit=0.2, normtype='flatnoise', psfcutoff=0.35)[source]¶
Bases:
BaseModelNormalization parameters.
- model_config = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class pclean.config.SlurmConfig(*, queue=None, account=None, walltime='24:00:00', job_mem='20GB', cores_per_job=1, job_name=None, job_extra_directives=<factory>, python=None, local_directory=None, log_directory='logs', job_script_prologue=<factory>)[source]¶
Bases:
BaseModelSLURM batch-job parameters (used when
cluster.type == 'slurm').- Parameters:
- model_config = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class pclean.config.SubmitConfig(*, workdir=None, pixi_project_dir=None, pixi_env='forge', coordinator_mem='8G', coordinator_cpus=2, coordinator_walltime='24:00:00', coordinator_job_name='pclean-coordinator', extra_sbatch=<factory>, log_dir=None, psrecord=True)[source]¶
Bases:
BaseModelSLURM coordinator (submit) job parameters.
These control the coordinator SLURM job that runs
python -m pclean --pconfig <yaml>and lets dask-jobqueue spawn per-channel worker jobs.- Parameters:
- model_config = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class pclean.config.ClusterConfig(*, type='local', nworkers=None, scheduler_address=None, threads_per_worker=1, memory_limit='0', local_directory=None, parallel=False, cube_chunksize=-1, keep_subcubes=False, keep_partimages=False, concat_mode='auto', slurm=<factory>, submit=<factory>)[source]¶
Bases:
BaseModelDask cluster configuration.
- Parameters:
type (Literal['local', 'slurm', 'address'])
nworkers (int | None)
scheduler_address (str | None)
threads_per_worker (int)
memory_limit (str)
local_directory (str | None)
parallel (bool)
cube_chunksize (int)
keep_subcubes (bool)
keep_partimages (bool)
concat_mode (Literal['auto', 'paged', 'virtual', 'movevirtual'])
slurm (SlurmConfig)
submit (SubmitConfig)
- type: Literal['local', 'slurm', 'address']¶
- concat_mode: Literal['auto', 'paged', 'virtual', 'movevirtual']¶
- slurm: SlurmConfig¶
- submit: SubmitConfig¶
- model_config = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class pclean.config.PcleanConfig(*, selection=<factory>, image=<factory>, grid=<factory>, weight=<factory>, deconvolution=<factory>, iteration=<factory>, normalization=<factory>, misc=<factory>, cluster=<factory>)[source]¶
Bases:
BaseModelTop-level hierarchical configuration for pclean.
All parameters are grouped into logical sub-configs. This is the single source of truth for the application.
- Parameters:
selection (SelectionConfig)
image (ImageConfig)
grid (GridConfig)
weight (WeightConfig)
deconvolution (DeconvolutionConfig)
iteration (IterationConfig)
normalization (NormConfig)
misc (MiscConfig)
cluster (ClusterConfig)
- selection: SelectionConfig¶
- image: ImageConfig¶
- grid: GridConfig¶
- weight: WeightConfig¶
- deconvolution: DeconvolutionConfig¶
- iteration: IterationConfig¶
- normalization: NormConfig¶
- misc: MiscConfig¶
- cluster: ClusterConfig¶
- classmethod merge(*configs)[source]¶
Deep-merge multiple configs, later values override earlier ones.
- Parameters:
configs (PcleanConfig) – Two or more configs to merge left-to-right.
- Return type:
- classmethod from_flat_kwargs(vis='', **kwargs)[source]¶
Build a
PcleanConfigfrom the flatpclean()keyword arguments.This is the backward-compatibility shim that maps the 80+ flat keyword arguments into the hierarchical structure.
- Parameters:
- Return type:
- to_casa_weightpars()[source]¶
Build CASA
setweighting-compatible weight parameter dict.- Return type:
- to_casa_iterpars()[source]¶
Build CASA
setupiteration-compatible iteration parameter dict.- Return type:
- to_casa_bundle()[source]¶
Produce a serializable dict of all CASA-native parameter dicts.
This is the worker-facing payload for continuum-parallel actors. Cube-parallel workers receive a serialized
PcleanConfiginstead.- Returns:
Dict with keys matching the former
PcleanParams.to_dict()format.- Return type:
- make_subcube_config(start, nchan, image_suffix, width=None)[source]¶
Return a copy tuned for a channel sub-range (cube parallelism).
- Parameters:
start (int | str) – Start channel (int) or frequency/velocity string.
nchan (int) – Number of channels in this subcube.
image_suffix (str) – Suffix appended to the base imagename.
width (int | str | None) – Channel width override. When start is converted to a frequency string the caller must also supply a matching frequency width so that CASA does not reject mixed unit types.
- Return type:
- to_params()[source]¶
Convert to the legacy
PcleanParamsused by engines.Deprecated since version Use: the
to_casa_*()methods or passPcleanConfigdirectly to engines instead.- Returns:
A fully constructed
PcleanParamsinstance.- Return type:
- model_config = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- pclean.config.load_defaults()[source]¶
Load the bundled
defaults.yamlreference snapshot.This is equivalent to
PcleanConfig()(all pydantic defaults) but read from the packaged YAML file for verification purposes.- Returns:
A
PcleanConfigwith the reference default values.- Return type:
- pclean.config.load_preset(name)[source]¶
Load a named preset from the bundled
configs/presets/directory.Searches first inside the installed package, then falls back to CWD-relative paths.
- Parameters:
name (str) – Preset name (without
.yamlextension).- Return type:
- pclean.config.get_adios2_config_path()[source]¶
Return the filesystem path of the bundled ADIOS2 XML config.
The file enables lossless blosc2/zstd compression and sets sensible buffer sizes for CASA Measurement Sets stored in ADIOS2 format. Point ADIOS2 at it via the environment variable before opening any MS:
import os from pclean.config import get_adios2_config_path path = get_adios2_config_path() if path is not None: os.environ.setdefault('ADIOS2_INIT_FILE', str(path))
- Returns:
Resolved filesystem
Path, orNoneif not found.- Return type:
Path | None