Pipeline library#
Pipeline orchestration, configuration, step implementations, and result reporting.
Pipeline entry point#
- class avica.pipe.main.AvicaPipeline(pipe_params=None, steps=None)#
Bases:
AvicaPipelineCore- LEGACY_MPI_PARAMS = {'mpi_cores_avgms': 'avica_avg.mpi_cores', 'mpi_cores_importfitsidi': 'fits_to_ms.mpi_cores', 'mpi_cores_rpicard': 'rpicard.mpi_cores', 'mpi_cores_snrating': 'avica_snr.mpi_cores', 'mpi_cores_splitms': 'avica_split_ms.mpi_cores'}#
- DEFAULT_STEPS = [<class 'avica.pipe.steps.PreProcessFitsIdi'>, <class 'avica.pipe.steps.FitsIdiToMS'>, <class 'avica.pipe.steps.Phaseshift'>, <class 'avica.pipe.steps.AverageMS'>, <class 'avica.pipe.steps.AvicaMetaMS'>, <class 'avica.pipe.steps.SnRating'>, <class 'avica.pipe.steps.FillInputMs'>, <class 'avica.pipe.steps.FinalSplitMs'>, <class 'avica.pipe.steps.Calibration'>]#
- step_names()#
- steps_from(step_name)#
- config_report(*step_names)#
Configuration#
- class avica.pipe.config.LogFramework(primary_colname='', primary_value='', csv_file='pipeline_out.csv', working_col='', polars=False, gsc=None, verbose=False)#
Bases:
objectA DataFrame based utility for tracking pipeline step results against rows identified by a primary key column.
Supports pandas and polars backends, CSV persistence, and optional google sheet support.
Parameters#
- primary_colnamestr
Column name used as the unique row identifier.
- primary_valuestr
The value in primary_colname that identifies the current row.
- working_colstr
Default column to read/write when no colname is explicitly given.
- csv_filestr
Path to the CSV file used as the data source and persistence target.
- polarsbool
If True, use polars as the internal backend. Falls back to pandas if unavailable.
- gscoptional
A gspread-backed connection object. Pass None to work in CSV-only mode.
- property is_googlesheet#
- property df_sheet#
mutable sheet obj.
- property df_sheet0#
shet df for diffs
- get_pandas()#
- Return type:
pandas.DataFrame
- get_polars()#
- Return type:
polars.DataFrame
- get_value(colname='', where=None)#
Returns the cell value for colname (or working_col) at the current primary_value row. Returns empty string when not found.
- isvalue(value, colname='')#
Returns True if the cell value matches value.
- put_value(value, colname='', count=0, where=None, force=False)#
Writes value into colname (or working_col) for the current primary_value row. Skips the write if the cell is already populated and force=False. Returns count + 1 on a successful write.
- update_csv(count, failed, csvfile=None)#
Persists the current frame to CSV if anything changed since last save.
- update_sheet(count, failed, by_cell=True, comment_col='Comment', csvfile=None)#
syncs changes to Google Sheets if a gsc instance was provided.
falls back to CSV on failure. Rate-limited to stay under 60 req/min.
no-ops cleanly when gsc is None.
- avica.pipe.config.setup_casa_path(casadir)#
Inject CASA’s site-packages (and lib dirs) into the current interpreter so that CASA modules can be imported in-process.
Also records what was added so that run_subprocess can propagate the same paths into child processes via PYTHONPATH / LD_LIBRARY_PATH.
- Parameters:
casadir (str)
- Return type:
None
- avica.pipe.config.populate_default_csv()#
Core types and task wrappers#
- avica.pipe.core.catalog_search_from_fits(fitsfile, df_catalog, seplimit, thres_sep, source_name_col='Obsname', frame='icrs', include_not_found=False, verbose=False, outdir='')#
- avica.pipe.core.df_search_brightcalib_fromascii_catalogfile(fitsfile, rfc_filepath, class_filepath, scanlist_arr, targets=[], seplimit=5000.0, thres_sep=10000.0, crossmatch_sep=600, outfile='', nfilter_sources=20)#
TODO: Increase seplimit for sources which were not found by the seplimit class_filepath e.g ‘/data/avi/d/smile/smile_complete_table.txt’
- avica.pipe.core.split_by_catalog_search(fitsfilepath, outfitsfilepath, targets, scanlist_arr, calibrator_catalog_file, coord_inpfile, matched_coord_outfile, metafolder)#
uses scanlist information to check if sources, dont have any data in UV_DATA. searches for source information by coordinate from fits in the calibrator fille,
if provided uses true coordinates from coordinate file to make separation limits to calibrators, also saves output file containing separation (in mas) between provided and observed file coordinate
- avica.pipe.core.split_in_freqid(fitsfiles, verbose=False)#
- avica.pipe.core.update_ifolderdata_from_new_ifolder(old_ifolder, new_ifolder, *inpfilenames)#
- avica.pipe.core.merge_obs_data(base_dict, *new_dicts)#
provide time sorted dicts to create a merged dicts of listobs.
- Parameters:
base_dict (
_type_) – _description_- Returns:
_description_
- Return type:
_type_
- class avica.pipe.core.StepResult(name: str, success_count: int, failed_count: int, start_stamp: datetime.datetime, detail: Dict, desc: List[str] = <factory>, success: List[bool] = <factory>, end_stamp: datetime.datetime = <factory>)#
Bases:
object- Parameters:
- class avica.pipe.core.ColName(working_col, comment_col, timestamp_col)#
Bases:
NamedTuple
- class avica.pipe.core.AvicaResult(initlist=None)#
Bases:
UserList[StepResult]- to_polars()#
- Return type:
polars.DataFrame
- summary()#
- Return type:
polars.DataFrame
- avica.pipe.core.append_step_result_csv(result, csvfile)#
- Parameters:
result (StepResult)
- Return type:
- avica.pipe.core.step_stage(name, **context)#
Wraps a stage inside run(), logs entry and enriches any exception with context.
- Parameters:
name (str)
- class avica.pipe.core.PipelineContext#
Bases:
object- result: StepResult | None = None#
- classmethod reset_params()#
- avica.pipe.core.casa_logfiles(wd, step_name, start_stamp)#
(logfile, errfile) for CASA tasks of a step. Inside a pipeline run this is the single run-level pair in casa.logs/ (issue #58); outside a run (e.g. a step called directly) it falls back to per-step files in wd.
- class avica.pipe.core.WorkDirMeta(wd_ifolder)#
Bases:
object- get_inp(band='', target='', inpfile='observation.inp')#
Returns (obs_dic, arr_dic, flag_dic, arr_finetune_dic, constants_dic)
- Return type:
- get_diclistobs()#
- to_dict()#
- class avica.pipe.core.PipelineStepValidatorBase#
Bases:
ABC- result: PipelineStepValidatorResult = PipelineStepValidatorResult(success=[False], msg='')#
- abstract run(**kwargs)#
- Return type:
- class avica.pipe.core.PipelineStepBase#
Bases:
ABC
- All the intialized arguments outside the step should be passed in initialized_config.
this makes easy checking for missing requirements when .run() is called.
Everything else goes as function arguments.
- result: StepResult#
- abstract run(step_name, wd_ifolder, pipe_params)#
- Parameters:
- Return type:
- class avica.pipe.core.InitVariables#
Bases:
PipelineStepValidatorBase- run(lf, target, targets, init_params)#
- class avica.pipe.core.CasaSetup#
Bases:
PipelineStepValidatorBase- run(lf, casadir, use_casadir_pythonpath)#
- class avica.pipe.core.ColValidation#
Bases:
PipelineStepValidatorBase- run(lf, working_col, first_col, skip_cols=True)#
- class avica.pipe.core.RowValidation#
Bases:
PipelineStepValidatorBase- run(fitsfile)#
- class avica.pipe.core.RunValidation#
Bases:
PipelineStepValidatorBase- run(working_col, first_col, skip_cols=True)#
- class avica.pipe.core.UpdateResults#
Bases:
PipelineStepValidatorBase- run(lf, count, failed, fitsfile_name, result_csv_file=None)#
- class avica.pipe.core.UpdateSheet#
Bases:
PipelineStepValidatorBase- run(lf, count, failed, fitsfile_name, csv_file=None)#
- class avica.pipe.core.AvicaPipelineCore(pipe_params, steps, provided_pipe_params=None)#
Bases:
object- register_steps()#
- get_kwargs(step)#
- get_config_requirements(*steps_to_check)#
- check_config_requirements(step)#
- filter_steps(*keys)#
- execute(loglevel='INFO')#
- Return type:
- class avica.pipe.core.PicardCMD(picard_input_template: str, input_template: str, logfile: str, errfile: str, args: Dict[str, Any], args_type: Dict[str, str], mpi_cores: int = 10, verbose: bool = False)#
Bases:
object- Parameters:
- class avica.pipe.core.CasaTaskCMD(casadir: str, task_casa: str, logfile: str, errf: str, args: Dict[str, Any], args_type: Dict[str, str], mpi_cores: int = 0)#
Bases:
object- Parameters:
- class avica.pipe.core.CasaStep(meta: Dict[str, Any], cmd: avica.pipe.core.CasaTaskCMD)#
Bases:
object- Parameters:
cmd (CasaTaskCMD)
- cmd: CasaTaskCMD#
- class avica.pipe.core.CasaConfigGen(tasks_list: List[avica.pipe.core.CasaStep] = <factory>)#
Bases:
object- to_dict()#
- avica.pipe.core.antab_spws(values)#
Zero-based spectral windows in INDEX/INDEX2 (cf. update_map).
- avica.pipe.core.antab_spw_count(values)#
- class avica.pipe.core.GenerateAndAppendAntab(fitsfiles, metafolder, verbose, wd, valid_perc=5, artifact_dirs=None, use_local_antab=True, local_antab_require_full_array=False)#
Bases:
object- find_and_attach_antab(fitsfile, fitsfiles, antabfile, attach_all, verbose=False)#
- attach_antab(only_first=True, attach_all=False)#
- attach_partial_antab(fitsfile)#
TSYS exists but not for every antenna, or gain curves are missing: use a local ANTAB that calibrates at least one of those antennas. Never downloads (the archive fallback is only for files without any TSYS).
- sort_by_time(reverse=False)#
- sort_by_tsys()#
- validate()#
tsys_exists_in_fitsfiles(fitsfile, self.fitsfiles) gc_exists_in_fitsfiles(fitsfile, self.fitsfiles) other things are already checked
- class avica.pipe.core.ImportFITSIdi(vis: str = '', fitsidifile: List[str] = <factory>, constobsid: bool = True, scanreindexgap_s: float = 15.0)#
Bases:
CasaTask
- class avica.pipe.core.FringeFit(vis: str = '', caltable: str = '', field: str = '', spw: str = '', selectdata: bool = True, timerange: str = '', antenna: str = '', scan: str = '', observation: str = '', msselect: str = '', solint: str = 'inf', combine: str = 'spw', refant: str = '', minsnr: str = '', zerorates: bool = False, globalsolve: bool = False, append: bool = False, docallib: bool = False, callib: str = '', gaintable: List | str = '', gainfield: List | str = '', interp: str = '', corrdepflags: bool = True, concatspws: bool = True, corrcomb: str = 'none', parang: bool = True)#
Bases:
CasaTask- Parameters:
vis (str)
caltable (str)
field (str)
spw (str)
selectdata (bool)
timerange (str)
antenna (str)
scan (str)
observation (str)
msselect (str)
solint (str)
combine (str)
refant (str)
minsnr (str)
zerorates (bool)
globalsolve (bool)
append (bool)
docallib (bool)
callib (str)
interp (str)
corrdepflags (bool)
concatspws (bool)
corrcomb (str)
parang (bool)
- class avica.pipe.core.MsTransform(vis: str = '', outputvis: str = '', datacolumn: str = 'data', field: str = '', spw: str = '', antenna: str = '', scan: str = '', correlation: str = '', chanaverage: bool = False, chanbin: int | List[int] = 1, timeaverage: bool = False, timebin: str = '0s', hanning: bool = False, reindex: bool = True, keepflags: bool = True, createmms: bool = True)#
Bases:
CasaTask- Parameters:
- class avica.pipe.core.FlagData(vis: str = '', mode: str = 'manual', inpfile: str = '', action: str = 'apply', flagbackup: bool = True, savepars: bool = False, datacolumn: str = 'data', field: str = '', spw: str = '', antenna: str = '', scan: str = '', reason: str = 'any')#
Bases:
CasaTask- Parameters:
- class avica.pipe.core.FlagManager(vis: str = '', mode: str = 'save', versionname: str = '', comment: str = '', merge: str = 'replace')#
Bases:
CasaTask
- class avica.pipe.core.IterativeSubprocess(cmd_list, clean_env=True, verbose=True)#
Bases:
object- get_stderr()#
- close()#
- class avica.pipe.core.PersistentMpiCasaRunner(casadir, mpi_cores=10, verbose=False, logfile=None, errfile=None)#
Bases:
object- run_task(task_name, args, args_type, block=False, target_server=None, logfile='', run_on_master=False, label='')#
- close()#
- avica.pipe.core.run_subprocess(cmd_list, inp_data, mode='stdin', clean_env=True, verbose=True)#
- class avica.pipe.core.SubprocessPayload(inp_data, cmd_list=None, host='localhost', port=5030)#
Bases:
object
- class avica.pipe.core.PicardStepParser(casadir: str, logfile: str, errf: str)#
Bases:
object- parse(task)#
- Parameters:
task (PicardTask)
- Return type:
- class avica.pipe.core.PicardPayload(task)#
Bases:
SubprocessPayload- Parameters:
task (PicardTask)
Pipeline steps#
- class avica.pipe.steps.PreProcessFitsIdi#
Bases:
PipelineStepBase
Fix minor problems in the fits.
Check scanlist, print listobs if scanlist output file not found in metadata.
Split sources to contain only desired sources.
Fix remaining problems.
Split in frequency id and attach missing tsys, gain curve table.
Fill optional metadata in the pipeline input files.
- py_env = ''#
- description: str = 'Fixes FITS-IDI data and headers, selects sources, splits by frequency ID, and attaches local ANTAB calibration or falls back to downloading and converting VLBA calibration.'#
- validate_by: List = [<class 'avica.pipe.core.InitVariables'>, <class 'avica.pipe.core.RunValidation'>, <class 'avica.pipe.core.UpdateResults'>, <class 'avica.pipe.core.UpdateSheet'>]#
- result: StepResult = StepResult(name='preprocess_fitsidi', success_count=0, failed_count=0, start_stamp=datetime.datetime(2026, 10, 10, 1, 49, 24, 772207), detail={}, desc=[], success=[], end_stamp=datetime.datetime(2026, 10, 10, 1, 49, 24, 772212))#
- run(lf, fitsfiles, target, wd_ifolder, source_extract_multi_fitsfiles=False, removables=[], rm_only=False, rm_pre=False, delete_removables=False, artifact_dirs=[], use_local_antab=True, local_antab_require_full_array=False, force_reset=False, verbose=False)#
- class avica.pipe.steps.FitsIdiToMS#
Bases:
PipelineStepBase
uses the last used fitsfiled to run importfitsidi
runs iteratively for files requiring different vis output.
casa tasks is triggered with the correct python environment using payload service
logs “vis exists!” when the visiblity file is already present.
- py_env = ''#
- validate_by: List = [<class 'avica.pipe.core.InitVariables'>, <class 'avica.pipe.core.RunValidation'>, <class 'avica.pipe.core.UpdateResults'>, <class 'avica.pipe.core.UpdateSheet'>]#
- result: StepResult = StepResult(name='fits_to_ms', success_count=0, failed_count=0, start_stamp=datetime.datetime(2026, 10, 10, 1, 49, 24, 772240), detail={}, desc=[], success=[], end_stamp=datetime.datetime(2026, 10, 10, 1, 49, 24, 772242))#
- run(lf, casadir, wd_ifolder, target='', apply_flag_from_idi=True, mpi_cores=5, flag_source='ms', removables=[], rm_only=False, rm_pre=False, delete_removables=False, apply_flag_to_existing_vis=False, apply_flag_from_artifacts=True, artifact_dirs=None, artifact_flag_extensions='.fg;.uvflag;.uvflg;.uvfg;.flag;.flg;.uvflags;.uvflgs;.uvfgs;.flags;.flgs', artifact_flagfiles=None)#
- class avica.pipe.steps.Phaseshift#
Bases:
PipelineStepBase
works if coordinate file was provided e.g class_search_coord.ascii
match sources by coordinate and phaseshift if not coordinates within 1 arcsecond
casa tasks is triggered with the correct python environment using payload service
- py_env = 'casa-6.7'#
- description: str = 'uses the coodinate search file result from previous step, performs phaseshift when source is off by 1 arcsecond'#
- validate_by: List = [<class 'avica.pipe.core.InitVariables'>, <class 'avica.pipe.core.RunValidation'>, <class 'avica.pipe.core.UpdateResults'>, <class 'avica.pipe.core.UpdateSheet'>]#
- result: StepResult = StepResult(name='phaseshift', success_count=0, failed_count=0, start_stamp=datetime.datetime(2026, 10, 10, 1, 49, 24, 772262), detail={}, desc=[], success=[], end_stamp=datetime.datetime(2026, 10, 10, 1, 49, 24, 772263))#
- run(lf, wd_ifolder, fitsfile, target, separation_thres, class_search_asciifile, removables=[], rm_only=False, rm_pre=False, delete_removables=False, verbose=False)#
- class avica.pipe.steps.AverageMS#
Bases:
PipelineStepBase
When required average data to 2s and 500KHz in time and frequency resolution.
split the averaged data by removing filtered anenna.
- py_env = 'casa-6.7'#
- description: str = 'Average the Measurement Set to have INTTIM=2sec, CHWIDTH=500KHz | uses CASA task mstransform'#
- validate_by: List = [<class 'avica.pipe.core.InitVariables'>, <class 'avica.pipe.core.RunValidation'>, <class 'avica.pipe.core.CasaSetup'>, <class 'avica.pipe.core.UpdateResults'>, <class 'avica.pipe.core.UpdateSheet'>]#
- result: StepResult = StepResult(name='avica_avg', success_count=0, failed_count=0, start_stamp=datetime.datetime(2026, 10, 10, 1, 49, 24, 772278), detail={}, desc=[], success=[], end_stamp=datetime.datetime(2026, 10, 10, 1, 49, 24, 772278))#
- run(lf, wd_ifolder, casadir, targets, target, mpi_cores=5, drop_dead_pol='auto', removables=[], rm_only=False, rm_pre=False, delete_removables=False, verbose=True)#
- class avica.pipe.steps.AvicaMetaMS#
Bases:
PipelineStepBase
Creates metadata by identifying sources from MS file per band.
Saves msmeta and sources avica files per band.
- py_env = 'casa-6.7'#
- validate_by: List = [<class 'avica.pipe.core.InitVariables'>, <class 'avica.pipe.core.RunValidation'>, <class 'avica.pipe.core.CasaSetup'>, <class 'avica.pipe.core.UpdateResults'>, <class 'avica.pipe.core.UpdateSheet'>]#
- result: StepResult = StepResult(name='avicameta_ms', success_count=0, failed_count=0, start_stamp=datetime.datetime(2026, 10, 10, 1, 49, 24, 772291), detail={}, desc=[], success=[], end_stamp=datetime.datetime(2026, 10, 10, 1, 49, 24, 772291))#
- run(lf, wd_ifolder, init_params, rfc_catalogfile, target, flux_threshold_phref=0.15, removables=[], rm_only=False, rm_pre=False, delete_removables=False, verbose=True)#
- class avica.pipe.steps.SnRating#
Bases:
PipelineStepBase
iteratively run s/n rating through each workdir
- py_env = 'casa-6.7'#
- validate_by: List = [<class 'avica.pipe.core.InitVariables'>, <class 'avica.pipe.core.RunValidation'>, <class 'avica.pipe.core.CasaSetup'>, <class 'avica.pipe.core.UpdateResults'>, <class 'avica.pipe.core.UpdateSheet'>]#
- result: StepResult = StepResult(name='avica_snr', success_count=0, failed_count=0, start_stamp=datetime.datetime(2026, 10, 10, 1, 49, 24, 772305), detail={}, desc=[], success=[], end_stamp=datetime.datetime(2026, 10, 10, 1, 49, 24, 772307))#
- run(lf, wd_ifolder, init_params, casadir, target, n_refant=5, n_calib=6, removables=[], rm_only=False, rm_pre=False, delete_removables=False, multiband_snrating=True, mpi_cores=5, n_scan_snrting=7, verbose=True)#
- class avica.pipe.steps.FillInputMs#
Bases:
PipelineStepBase
Fills input folder using metadata from the s/n rating if exists.
- py_env = 'casa-6.7'#
- validate_by: List = [<class 'avica.pipe.core.InitVariables'>, <class 'avica.pipe.core.RunValidation'>, <class 'avica.pipe.core.CasaSetup'>, <class 'avica.pipe.core.UpdateResults'>, <class 'avica.pipe.core.UpdateSheet'>]#
- result: StepResult = StepResult(name='avica_fill_input', success_count=0, failed_count=0, start_stamp=datetime.datetime(2026, 10, 10, 1, 49, 24, 772319), detail={}, desc=[], success=[], end_stamp=datetime.datetime(2026, 10, 10, 1, 49, 24, 772320))#
- run(lf, wd_ifolder, rfc_catalogfile, target, n_calib=6, snr_threshold_phref=7, hi_freq_ref=11, removables=[], rm_only=False, rm_pre=False, delete_removables=False, min_channel_flagging=32, sci_solints='auto', solint_max_scan_partitions=8, verbose=True)#
- class avica.pipe.steps.FinalSplitMs#
Bases:
PipelineStepBase
Uses mstransform to split the input visibility to contain only the final selected sources.
- py_env = 'casa-6.7'#
- validate_by: List = [<class 'avica.pipe.core.InitVariables'>, <class 'avica.pipe.core.RunValidation'>, <class 'avica.pipe.core.CasaSetup'>, <class 'avica.pipe.core.UpdateResults'>, <class 'avica.pipe.core.UpdateSheet'>]#
- result: StepResult = StepResult(name='avica_split_ms', success_count=0, failed_count=0, start_stamp=datetime.datetime(2026, 10, 10, 1, 49, 24, 772332), detail={}, desc=[], success=[], end_stamp=datetime.datetime(2026, 10, 10, 1, 49, 24, 772333))#
- run(lf, wd_ifolder, casadir, target, removables=[], rm_only=False, rm_pre=False, delete_removables=False, verbose=True, mpi_cores=10)#
- class avica.pipe.steps.Calibration#
Bases:
PipelineStepBase
Runs the complete rPicard calibrtion framework.
- py_env = 'casa-6.7'#
- validate_by: List = [<class 'avica.pipe.core.InitVariables'>, <class 'avica.pipe.core.RunValidation'>, <class 'avica.pipe.core.UpdateResults'>, <class 'avica.pipe.core.UpdateSheet'>]#
- result: StepResult = StepResult(name='rpicard', success_count=0, failed_count=0, start_stamp=datetime.datetime(2026, 10, 10, 1, 49, 24, 772344), detail={}, desc=[], success=[], end_stamp=datetime.datetime(2026, 10, 10, 1, 49, 24, 772345))#
- run(lf, wd_ifolder, casadir, target, verbose=True, removables=[], rm_only=False, picard_input_template_update='', delete_previous_data=True, rm_pre=False, delete_removables=False, mpi_cores=10)#
Helpers#
- avica.pipe.helpers.get_targets_filenames(lf, filename_col, targetname_col)#
- avica.pipe.helpers.select_existing_wd(fitsfiles, target_dir, ifolder)#
Return the workdir that setup_workdir would reuse for fitsfiles, or None.
Never creates anything, so it is safe to call before the pipeline runs (e.g. to locate the result CSV for
--resume).
- avica.pipe.helpers.get_wd_ifolder_multiplefits(fitsfiles, target_dir, ifolder)#
Reuse a complete input set, preferring preprocessed, newer workdirs.
- avica.pipe.helpers.safe_name_part(value)#
Make value usable as one __-separated field of a file name: path separators and whitespace become -, and runs of _ are squeezed so a field can never contain the __ separator.
- Return type:
- avica.pipe.helpers.parse_result_csv_name(name)#
Inverse of result_csv_name. Returns
{'target', 'project_code', 'workdir'}or None for names that do not follow the pattern.
- avica.pipe.helpers.legacy_result_csv_path(target_dir, target)#
Pre-#59 name: {target}_result.csv.
- Return type:
- avica.pipe.helpers.find_result_csvs(target_dir, target, project_code=None, workdir=None)#
Result CSVs in target_dir for target, optionally narrowed by project code and/or workdir name. Newest (by modification time) first.
- avica.pipe.helpers.resolve_result_csv(target_dir, target, fitsfilenames, folder_for_fits, picard_input_template)#
Work out, without creating anything, which result CSV a run with these inputs will write to. Returns None when the workdir does not exist yet.
- avica.pipe.helpers.search_input_template(picard_input_template, ifolder, depth=4)#
- avica.pipe.helpers.setup_workdir(lf, target_dir, fitsfilenames, allfitsfile, picard_input_template)#
- avica.pipe.helpers.fits_has_target(fitsfiles, target)#
- avica.pipe.helpers.add_O(src_name)#
- avica.pipe.helpers.normalize_strlist(value)#
Coerce a config list to a list of strings.
read_inputfile has no list syntax, so a list-valued option arrives as the raw text – [], [a, b] or a, b – and has to be unpacked here.
- avica.pipe.helpers.parse_params(lf, params)#
- avica.pipe.helpers.get_logfilename(fnname='fitsidiutil', start_stamp=datetime.datetime(2026, 10, 10, 1, 49, 24, 750599), module_name='avica')#
Return
{fnname}_{module_name}_log-{start_stamp.strftime(“%Y%m%d_%H%M%S”)}.log
fnn
- avica.pipe.helpers.read_avica_sources_msmeta(metafile)#
- avica.pipe.helpers.alls_fromobs(obs_b)#
- avica.pipe.helpers.read_avica_sources(avicametafile=None, s=None)#
- avica.pipe.helpers.update_constants(wd_ifolder, filename=None, val_dict={}, new_wd=None)#
- avica.pipe.helpers.read_avicameta(wd_ifolder=None, avicametafile=None)#
- avica.pipe.helpers.update_from_avicameta(wd_ifolder, filename=None, inpfile='', val_dict=None, new_wd=None, reference_ifolder='')#
- avica.pipe.helpers.array_finetune_write(p)#
- avica.pipe.helpers.update_array_finetune(wd_ifolder, new_wd=None, dic_p={})#
- avica.pipe.helpers.update_array_finetune_values(p)#
- avica.pipe.helpers.fillinp_fromiwd(iwd, iwd_b)#
- avica.pipe.helpers.update_obsfrom_avicameta(wd_ifolder, sources_dict=None, new_wd=None, band=None)#
- avica.pipe.helpers.fill_input_byvalues(wd_ifolder, iwd_b, vis, target, flux_thres, n_calib, caliblist_file, sourcesf, refantsf, sourcesf_snr, band=None, min_channel_flagging=32, sci_solints='auto', solint_max_scan_partitions=8, pipe_params=None, hi_freq_ref=11)#
- avica.pipe.helpers.casa_quote(value)#
Single-quote a CASA flagcmd value.
- avica.pipe.helpers.contiguous_ranges(values)#
Return inclusive contiguous ranges for sorted integer values.
- avica.pipe.helpers.format_timerange(base_time, timerang_days)#
Convert FITS-IDI TIMERANG day offsets to CASA timerange syntax.
- Parameters:
base_time (datetime)
timerang_days (numpy.ndarray)
- Return type:
- avica.pipe.helpers.casa_time_from_seconds(seconds)#
- avica.pipe.helpers.antenna_names(hdul)#
- Parameters:
hdul (astropy.io.fits.HDUList)
- Return type:
- avica.pipe.helpers.source_names(hdul)#
- Parameters:
hdul (astropy.io.fits.HDUList)
- Return type:
- avica.pipe.helpers.format_antenna(ants, ant_names)#
- Parameters:
ants (numpy.ndarray)
- Return type:
str | None
- avica.pipe.helpers.format_spw(bands, chans, nband, nchan)#
Convert FITS-IDI BANDS/CHANS to a CASA spw selector.
FITS-IDI BANDS and CHANS use one-based numbering. A zero channel range means all channels.
- Parameters:
bands (numpy.ndarray)
chans (numpy.ndarray)
nband (int)
nchan (int)
- Return type:
str | None
- avica.pipe.helpers.format_correlation(pflags)#
- Parameters:
pflags (numpy.ndarray)
- Return type:
str | None
- avica.pipe.helpers.flag_row_to_command(row, *, base_time, nband, nchan, ant_names, src_names)#
- avica.pipe.helpers.convert_flag_table(idifits, output)#
- avica.pipe.helpers.convert_ms_flag_cmd_table(vis, output)#
- avica.pipe.helpers.get_allfitsfiles(folder_for_fits, depth=3, extensions=['*fits', '*FITS', '*.idifits', '*.IDIFITS', '*.idi*', '*.IDI*'])#
- avica.pipe.helpers.build_path(filepath)#
- avica.pipe.helpers.symlink_bywd(wd, fitsfile, create=True)#
- avica.pipe.helpers.get_project(fitsfile)#
- avica.pipe.helpers.iwd_for_fitsfile(fitsfile, target_dir, ifolder=None, create=False, splitted=False, allwds=False)#
looks for wd using project name
- avica.pipe.helpers.get_wd_ifolder(fitsfile, target_dir, ifolder)#
- avica.pipe.helpers.single_ifcheck(nchan, chwidth, nchan_default=16, chwidth_bound=500.0)#
- avica.pipe.helpers.split_band_and_data(x)#
- avica.pipe.helpers.split_and_stack_multiple_cols(dfsheet, cols)#
Only for columns containing values = [f”{band}: float]
Splits and stacks multiple columns in a DataFrame.
- Params:
dfsheet (pd.DataFrame): The input DataFrame. cols (list): List of column names to process.
- Returns:
A DataFrame with split and stacked rows for all specified columns.
- Return type:
pd.DataFrame
- avica.pipe.helpers.calc_vis_perc(fitsfile, calibrated=False)#
- avica.pipe.helpers.proj_search(url, proj)#
- avica.pipe.helpers.find_url_tsys(fitsfile, proj='')#
TODO: if it is EVLA observation you need ppppcal.y for VLA refer https://science.nrao.edu/facilities/vlba/calibration-and-tools/caliblogs
- avica.pipe.helpers.del_fl(wd, count=0, fl='*ms*', rm=False)#
delete files from the input folder
- Parameters:
wd (
str) – where to look for the filecount (
int, optional) – _description_. Defaults to 0.fl (
str, optional) – _description_. Defaults to ‘ms’.rm (
bool, optional) – _description_. Defaults to False.
- Returns:
_description_
- Return type:
_type_
- avica.pipe.helpers.find_tsys(wd_ifolder, fitsfile, count, failed)#
- avica.pipe.helpers.overlap_percentage(A_start, A_end, B_start, B_end)#
- avica.pipe.helpers.tsys_exists(fitsfile, valid_perc=5, verbose=False)#
- avica.pipe.helpers.tsys_exists_in_fitsfiles(fitsfile, fitsfiles, valid_perc=5, verbose=True)#
- avica.pipe.helpers.read_calibration_tables(fitsfile)#
read_idi of only the antenna and calibration tables (headers of all HDUs).
read_idi reports errors instead of raising and can return a truncated HDU list (seen while a file was being rewritten); every FITS-IDI file has UV_DATA, so its absence is treated as a failed read.
- avica.pipe.helpers.tsys_antenna_coverage(fitsfile, valid_perc=5, hdul=None)#
{ANNAME: percent of the UV_DATA time range covered by valid TSYS}.
A TSYS row is valid if any TSYS_* value is finite and > 0 (single-hand bands carry -999.9 in the other hand). Antennas without valid rows get 0.0. Time reference and overlap follow tsys_exists.
- avica.pipe.helpers.gain_curve_antennas(fitsfile, hdul=None)#
Antenna names that have at least one GAIN_CURVE row.
- avica.pipe.helpers.uncalibrated_antennas(fitsfile, valid_perc=5)#
{‘tsys’: […], ‘gain’: […]}: antennas lacking TSYS coverage or any gain curve.
- avica.pipe.helpers.attach_antab(self, only_first=True, attach_all=False)#
- avica.pipe.helpers.meta_from_fitsfile(fitsfile, target, wd_ifolder, metafolder, reference_ifolder, do_manual_selection)#
- avica.pipe.helpers.meta_from_fitsfile_freqid(fitsfiles, target, wd_ifolder, metafolder, reference_ifolder, do_manual_selection)#
assumes wd_ifolder exists
- avica.pipe.helpers.count_freqids(fitsfile)#
- avica.pipe.helpers.check_target_in_ms(vis, target)#
Artifact flags#
Discover station UVFLG artifacts and build additive CASA manual flags.
Uses the JIVE keyin parser also used by casavlbitools.convert_flags. TIMEOFF and DTIMRANG follow AIPS UVFLG INTEXT semantics (seconds, persistent nonzero values): https://www.aips.nrao.edu/cgi-bin/ZXHLP2.PL?UVFLG Unsupported selectors are rejected rather than silently broadening a flag.
- avica.pipe.artifact_flags.discover_flagfiles(directories, extensions='.fg;.uvflag;.uvflg;.uvfg;.flag;.flg;.uvflags;.uvflgs;.uvfgs;.flags;.flgs', explicit=None)#
Explicit files override discovery; each resolved path is visited once.
- avica.pipe.artifact_flags.read_uvflg(path)#
- avica.pipe.artifact_flags.fits_flag_contexts(fitsfiles)#
Read antennas, IF dimensions and actual UV time ranges per input file.
- avica.pipe.artifact_flags.row_commands(row, contexts)#
- avica.pipe.artifact_flags.build_artifact_flagcmd(fitsfiles, output, directories, extensions='.fg;.uvflag;.uvflg;.uvfg;.flag;.flg;.uvflags;.uvflgs;.uvfgs;.flags;.flgs', explicit=None)#
Return command count and per-file provenance without modifying input data.
Reports#
Rendering of AVICA pipeline result CSVs.
A result CSV is written incrementally by
avica.pipe.core.append_step_result_csv(), one row per step attempt, to
<target_dir>/result__{target}__{project_code}__{workdir}.csv
(see avica.pipe.helpers.result_csv_name()), with the column layout of
avica.pipe.core.StepResult:
name, success_count, failed_count, start_stamp, detail, desc, success, end_stamp
The file is APPEND-ONLY: re-running a step appends a further row, so a step
name may appear several times. latest_per_step() collapses to the most
recent attempt; render_history() shows every attempt.
Four layouts are provided:
render_ladder(): one row per pipeline step in canonical order, with a status tally and the command needed to resume.render_detail(): fulldesctext in panels for steps that did not fully succeed.render_history(): every attempt of every step, grouped by step.render_oneline(): a single compact status line for scripts and CI.
render_result() composes them according to the flags passed by
avica pipe result.
Reading uses the standard-library csv module so that inspecting a result file never requires the heavier pipeline imports.
- avica.pipe.report.read_result_csv(csvfile)#
Read every attempt recorded in a result CSV, oldest first.
Returns an empty list when the file is missing or has no usable rows, so callers can distinguish “nothing ran” from “something failed”.
- avica.pipe.report.classify(row)#
Status of a single attempt.
‘ok’ is the same condition as cli_new._is_successful_result(); ‘partial’ additionally distinguishes a step that produced some output but also recorded failures, which a success/fail flag alone cannot express.
- avica.pipe.report.latest_per_step(rows)#
Collapse the append-only log to the most recent attempt of each step.
- avica.pipe.report.resume_step(rows)#
First pipeline step that has not completed successfully, i.e. the step avica pipe run –resume would start from. None when all steps are done.
- avica.pipe.report.render_result(rows, target='', history=False, oneline=False, detail=True, console=None)#
Render a result CSV according to the flags of avica pipe result.
oneline a single status line, and nothing else history every attempt, instead of the collapsed ladder detail append failure panels when a step did not fully succeed
- avica.pipe.report.render_ladder(console, rows, target='', note=None)#
One row per pipeline step, in canonical order rather than CSV order, so steps that never ran are shown as pending instead of being absent.
note defaults to showing the condensed failure note only when the terminal is wide enough to carry it.
- avica.pipe.report.render_detail(console, rows, target='')#
Full desc text for every step that did not fully succeed, one panel each.
desc holds complete exception traces; rendering it in a table cell would dictate the width of every other column, so it is given its own block.
- avica.pipe.report.render_history(console, rows, target='')#
Every recorded attempt, grouped by step. The step name is printed only on the first row of each group and groups are separated by a rule, following the grouping style of avica pipe config –summary.