From 3f9951ceb3fc0e464d2b2df4fc290b94e7f177bd Mon Sep 17 00:00:00 2001 From: tgalvin Date: Thu, 20 Jun 2024 11:54:43 +0800 Subject: [PATCH 1/6] initial commit of rename ms and columns / tests --- flint/ms.py | 67 ++++++++++++++++++++++++++++++++++++++++++++++-- tests/test_ms.py | 61 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 126 insertions(+), 2 deletions(-) diff --git a/flint/ms.py b/flint/ms.py index 50863ecc..08a5dc69 100644 --- a/flint/ms.py +++ b/flint/ms.py @@ -4,11 +4,12 @@ annotations, ) +from curses.ascii import controlnames +import shutil from argparse import ArgumentParser from contextlib import contextmanager from os import PathLike from pathlib import Path -from shutil import rmtree from typing import List, NamedTuple, Optional, Tuple, Union import astropy.units as u @@ -174,7 +175,7 @@ def critical_ms_interaction( # If we get to here, things worked successfully, and we # should return things back to normal. if copy: - rmtree(input_ms) + shutil.rmtree(input_ms) output_ms.rename(input_ms) else: output_ms.rename(target=input_ms) @@ -758,6 +759,68 @@ def copy_and_preprocess_casda_askap_ms( return ms.with_options(column=data_column) +def rename_ms_and_columns_for_selfcal( + ms: MS, + target: Union[str, Path], + corrected_data: str = "CORRECTED_DATA", + data: str = "DATA", +) -> MS: + """Take an existing measurement set, rename it, and appropriately + rename the "DATA" and "CORRECTED_DATA" columns to support a new + round of imaging and self-calibration. + + This could be considered for larger measurement sets where holding + multiple copies throughout rounds of self-calibration is not advisable. + + Args: + ms (MS): The subject measurement set to rename + target (Union[str, Path]): The targett path the measurement set will be renamed to. This shoudl not already exist. + corrected_data (str, optional): The name of the column with the latest calibrated data. This becomes the `data` column. Defaults to "CORRECTED_DATA". + data (str, optional): The name of the column that will be subsequently processed. If it exists it will be removed. Defaults to "DATA". + + Raises: + FileExistsError: Raised if `target` already exists + FileNotFoundError: Raise if `ms.path` does not exist + + Returns: + MS: Updated MS container with new path and appropriate data column + """ + + ms = MS.cast(ms) + target = Path(target) + + if target.exists(): + raise FileExistsError(f"{target} already exists!") + if not ms.path.exists() or not ms.path.is_dir(): + raise FileNotFoundError( + f"{ms.path} does not exists or is not a directory (hence measurement set)." + ) + + logger.info(f"Renaming {ms.path} to {target=}") + ms.path.rename(target=target) + + # Just some sanity incase None is passed through + if not (corrected_data or data): + return ms.with_options(path=target) + + # Now move the corrected data column into the column to be imaged. + # For casa it really needs to be DATA + with table(str(target), readonly=False, ack=False) as tab: + colnames = tab.colnames() + + if all([col in colnames for col in (corrected_data, data)]): + logger.info(f"Removing {data} and renaming {corrected_data}") + tab.removecols(columnnames=data) + tab.renamecol(oldname=corrected_data, newname=data) + elif corrected_data in colnames and data not in controlnames: + logger.info(f"Renaming {corrected_data=} to {data=}") + tab.renamecol(oldname=corrected_data, newname=data) + elif corrected_data not in colnames and data in colnames: + logger.warning(f"No {corrected_data=}, and {data=} seems to be present") + + return ms.with_options(path=target, column=data) + + def find_mss( mss_parent_path: Path, expected_ms_count: Optional[int] = 36 ) -> Tuple[MS, ...]: diff --git a/tests/test_ms.py b/tests/test_ms.py index 3ee9aa6e..3416cb14 100644 --- a/tests/test_ms.py +++ b/tests/test_ms.py @@ -7,14 +7,17 @@ import numpy as np import pytest +from casacore.tables import table from flint.calibrate.aocalibrate import ApplySolutions from flint.exceptions import MSError from flint.ms import ( MS, + check_column_in_ms, copy_and_preprocess_casda_askap_ms, find_mss, get_phase_dir_from_ms, + rename_ms_and_columns_for_selfcal, ) from flint.utils import get_packaged_resource_path @@ -125,6 +128,64 @@ def ms_example(tmpdir): return ms_path +def test_check_column_in_ms(ms_example): + """See whether columns are present in the MS, and whether the order of checking is correct""" + ms = MS(path=Path(ms_example), column="DATA") + + assert check_column_in_ms(ms=ms) + assert not check_column_in_ms(ms=ms, column="NoExists") + + with pytest.raises(ValueError): + check_column_in_ms(ms=ms.with_options(column=None)) + + +def _get_columns(ms_path): + + with table(str(ms_path), readonly=True, ack=False) as tab: + return tab.colnames() + + +def test_rename_ms_and_columns_for_selfcal_correct2data(ms_example, tmpdir): + """Sanity around renaming a MS and handlign the columns that should be renamed""" + ms = MS.cast(Path(ms_example)) + with table(str(ms.path), readonly=False, ack=False) as tab: + tab.renamecol("DATA", "CORRECTED_DATA") + + colnames = _get_columns(ms_path=ms.path) + + assert "DATA" not in colnames + assert "CORRECTED_DATA" in colnames + + target = Path(tmpdir) / "target_directory" + target.mkdir(parents=True) + target = target / ms.path.name + + new_ms = rename_ms_and_columns_for_selfcal(ms=ms, target=target) + new_colnames = _get_columns(ms_path=new_ms.path) + + assert new_ms.path == target + assert "DATA" in new_colnames + assert "CORRECTED_DATA" not in new_colnames + + +def test_rename_ms_and_columns_for_selfcal(ms_example, tmpdir): + """Sanity around renaming a MS and handlign the columns that should be renamed""" + ms = MS.cast(Path(ms_example)) + colnames = _get_columns(ms_path=ms.path) + + assert "DATA" in colnames + + target = Path(tmpdir) / "target_directory" + target.mkdir(parents=True) + target = target / ms.path.name + + new_ms = rename_ms_and_columns_for_selfcal(ms=ms, target=target) + new_colnames = _get_columns(ms_path=new_ms.path) + + assert new_ms.path == target + assert "DATA" in new_colnames + + def test_phase_dir(ms_example): pos = get_phase_dir_from_ms(ms=ms_example) From 4b3a5f93bfc4e57a264597a3fb0a5debaefb18c1 Mon Sep 17 00:00:00 2001 From: tgalvin Date: Thu, 20 Jun 2024 14:00:56 +0800 Subject: [PATCH 2/6] added a rename ms option to use throughout the self-cal imaging rounds --- CHANGELOG.md | 1 + flint/imager/wsclean.py | 28 ------ flint/ms.py | 20 +++- flint/options.py | 2 + flint/prefect/common/imaging.py | 9 +- flint/prefect/flows/continuum_pipeline.py | 8 ++ flint/selfcal/casa.py | 111 +++++++++++++--------- flint/utils.py | 11 ++- 8 files changed, 107 insertions(+), 83 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 752f622c..04f04f6e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ - added in skip rounds for masking and selfcal - Basic handling of CASDA measurement sets (preprocessing) - Basic handling of environment variables in Options, only supported in WSCleanOptions (no need for others yet) +- basic renaming of MS and shuffling column names in place of straight up copying the MS ## 0.2.4 diff --git a/flint/imager/wsclean.py b/flint/imager/wsclean.py index 64c53e57..66a6f19f 100644 --- a/flint/imager/wsclean.py +++ b/flint/imager/wsclean.py @@ -488,34 +488,6 @@ def wsclean_imager( return wsclean_cmd -def create_template_wsclean_options( - input_wsclean_options: WSCleanOptions, -) -> WSCleanOptions: - """Construct a simple instance of WSClean options that will not - actually clean. This is intended to be used to get a representations - FITS header with appropriate WSC information. - - Args: - input_wsclean_options (WSCleanOptions): The base set of wsclean options to use - - Returns: - WSCleanOptions: Template options to use for the wsclean fits header creation - """ - - template_options = WSCleanCommand( - size=input_wsclean_options.size, - channels_out=1, - nmiter=0, - niter=1, - data_column=input_wsclean_options.data_column, - scale=input_wsclean_options.scale, - name=f"{input_wsclean_options.name}_template", - ) - logger.info(f"Template options are {template_options}") - - return template_options - - def get_parser() -> ArgumentParser: parser = ArgumentParser(description="Routines related to wsclean") diff --git a/flint/ms.py b/flint/ms.py index 08a5dc69..fd429405 100644 --- a/flint/ms.py +++ b/flint/ms.py @@ -808,7 +808,10 @@ def rename_ms_and_columns_for_selfcal( with table(str(target), readonly=False, ack=False) as tab: colnames = tab.colnames() - if all([col in colnames for col in (corrected_data, data)]): + if ( + all([col in colnames for col in (corrected_data, data)]) + and corrected_data != data + ): logger.info(f"Removing {data} and renaming {corrected_data}") tab.removecols(columnnames=data) tab.renamecol(oldname=corrected_data, newname=data) @@ -817,6 +820,21 @@ def rename_ms_and_columns_for_selfcal( tab.renamecol(oldname=corrected_data, newname=data) elif corrected_data not in colnames and data in colnames: logger.warning(f"No {corrected_data=}, and {data=} seems to be present") + elif ( + all([col in colnames for col in (corrected_data, data)]) + and corrected_data == data + and corrected_data != "DATA" + ): + data = "DATA" + logger.info(f"Renaming {corrected_data} to DATA") + tab.renamecol(corrected_data, data) + + # This is a safe guard against my bad handling of the above / mutineers + # There could be interplay with these columns when potato peel is used + # as some MSs will have CORRECYED_DATA and others may not. + assert ( + data == "DATA" + ), f"Somehow data column is not DATA, instead {data=}. Likely a problem for casa." return ms.with_options(path=target, column=data) diff --git a/flint/options.py b/flint/options.py index 46013bd2..44679748 100644 --- a/flint/options.py +++ b/flint/options.py @@ -104,3 +104,5 @@ class FieldOptions(NamedTuple): """Path that SBID archive tarballs will be created under. If None no archive tarballs are created. See ArchiveOptions. """ sbid_copy_path: Optional[Path] = None """Path that final processed products will be copied into. If None no copying of file products is performed. See ArchiveOptions. """ + rename_ms: bool = False + """Rename MSs throught rounds of imaging and self-cal instead of creating copies. This will delete data-columns throughout. """ diff --git a/flint/prefect/common/imaging.py b/flint/prefect/common/imaging.py index 3a197863..3942acac 100644 --- a/flint/prefect/common/imaging.py +++ b/flint/prefect/common/imaging.py @@ -213,20 +213,22 @@ def task_zip_ms(in_item: WSCleanCommand) -> Path: @task def task_gaincal_applycal_ms( - wsclean_cmd: WSCleanCommand, + ms: Union[MS, WSCleanCommand], round: int, update_gain_cal_options: Optional[Dict[str, Any]] = None, archive_input_ms: bool = False, skip_selfcal: bool = False, + rename_ms: bool = False, ) -> MS: """Perform self-calibration using CASA gaincal and applycal. Args: - wsclean_cmd (WSCleanCommand): A resulting wsclean output. This is used purely to extract the ``.ms`` attribute. + ms (Union[MS, WSCleanCommand]): A resulting wsclean output. This is used purely to extract the ``.ms`` attribute. round (int): Counter indication which self-calibration round is being performed. A name is included based on this. update_gain_cal_options (Optional[Dict[str, Any]], optional): Options used to overwrite the default ``gaincal`` options. Defaults to None. archive_input_ms (bool, optional): If True the input measurement set is zipped. Defaults to False. skip_selfcal (bool, optional): Should this self-cal be skipped. If `True`, the a new MS is created but not calibrated the appropriate new name and returned. + rename_ms (bool, optional): It `True` simply rename a MS and adjust columns appropriately (potentially deleting them) instead of copying the complete MS. If `True` `archive_input_ms` is ignored. Defaults to False. Raises: ValueError: Raised when a ``.ms`` attribute can not be obtained @@ -236,7 +238,7 @@ def task_gaincal_applycal_ms( """ # TODO: Need to do a better type system to include the .ms # TODO: This needs to be expanded to handle multiple MS - ms = wsclean_cmd.ms + ms = ms if isinstance(ms, MS) else ms.ms # type: ignore if not isinstance(ms, MS): raise ValueError( @@ -249,6 +251,7 @@ def task_gaincal_applycal_ms( update_gain_cal_options=update_gain_cal_options, archive_input_ms=archive_input_ms, skip_selfcal=skip_selfcal, + rename_ms=rename_ms, ) diff --git a/flint/prefect/flows/continuum_pipeline.py b/flint/prefect/flows/continuum_pipeline.py index 0d5ada81..77df55fc 100644 --- a/flint/prefect/flows/continuum_pipeline.py +++ b/flint/prefect/flows/continuum_pipeline.py @@ -349,6 +349,7 @@ def process_science_fields( update_gain_cal_options=unmapped(gain_cal_options), archive_input_ms=field_options.zip_ms, skip_selfcal=skip_gaincal_current_round, + rename_ms=field_options.rename_ms, wait_for=[ field_summary ], # To make sure field summary is created with unzipped MSs @@ -672,6 +673,12 @@ def get_parser() -> ArgumentParser: action="store_true", help="Skip checking whether the path containing bandpass solutions exists (e.g. if solutions have already been applied)", ) + parser.add_argument( + "--move-mss", + action="store_true", + default=False, + help="Rename MSs throught rounds of imaging and self-cal instead of creating copies. This will delete data-columns throughout. ", + ) return parser @@ -714,6 +721,7 @@ def cli() -> None: imaging_strategy=args.imaging_strategy, sbid_archive_path=args.sbid_archive_path, sbid_copy_path=args.sbid_copy_path, + rename_ms=args.rename_ms, ) setup_run_process_science_field( diff --git a/flint/selfcal/casa.py b/flint/selfcal/casa.py index 0fd35fd9..13eadb67 100644 --- a/flint/selfcal/casa.py +++ b/flint/selfcal/casa.py @@ -13,10 +13,10 @@ from casacore.tables import table from casatasks import applycal, cvel, gaincal, mstransform -from flint.exceptions import GainCalError +from flint.exceptions import GainCalError, MSError from flint.flagging import nan_zero_extreme_flag_ms from flint.logging import logger -from flint.ms import MS +from flint.ms import MS, rename_ms_and_columns_for_selfcal from flint.naming import get_selfcal_ms_name from flint.utils import remove_files_folders, rsync_copy_directory, zip_folder @@ -51,16 +51,23 @@ def with_options(self, **kwargs) -> GainCalOptions: return GainCalOptions(**_dict) -def copy_and_clean_ms_casagain(ms: MS, round: int = 1, verify: bool = True) -> MS: +def copy_and_clean_ms_casagain( + ms: MS, round: int = 1, verify: bool = True, rename_ms: bool = False +) -> MS: """Create a copy of a measurement set in preparation for selfcalibration using casa's gaincal and applycal. Applycal only works when calibrating DATA and creating a CORRECTED_DATA column. Columns are removed in the copied MS to allow this. + If the MS is large the `move_ms` option will simply renamed the input MS, adjusting + the columns appropriately. Note that this potentially involves deleting the `DATA` + column if present and renaming `CORRECTED_DATA`. + Args: ms (MS): Measurement set that would go through self-calibration. round (int, optional): The self-calibration round. Defaults to 1. verify (bool, optional): Verify that copying the measurementt set (done in preparation for gaincal) was successful. Uses a call to rsync. Defaults to True. + move_ms (bool, optional): Rather than copying the MS, simple renamed the MS and modify columns appropriately. Defaults to False. Returns: MS: Copy of input measurement set with columns removed as required. @@ -74,48 +81,56 @@ def copy_and_clean_ms_casagain(ms: MS, round: int = 1, verify: bool = True) -> M logger.warning(f"{out_ms_path} already exists. Removing it. ") remove_files_folders(out_ms_path) - copytree(ms.path, out_ms_path) - # Because we can trust nothing, verify the - # copy with rsync. On some lustre file systems (mostly seen on stonix) - # components of the measurement sett are not always successfully - # copied with a simple copytree. - if verify: - rsync_copy_directory(ms.path, out_ms_path) - - logger.info("Copying finished. ") - - # The casa gaincal and applycal tasks __really__ expect the input and output - # column names to be DATA and CORRECTED_DATA. So, here we will go through the - # motions of deleting and rnaming columns. Note that the MODEL_DATA column needs - # to exist. The INSTRUMENT_DATA column will also be removed. - logger.info("About to open the table. ") - with table(str(out_ms_path), readonly=False, ack=False) as tab: - logger.info("About tto get the colnames") - colnames = tab.colnames() - logger.info(f"Column names are: {colnames}") - if ms.column == "DATA" and "CORRECTED_DATA" not in colnames: - logger.info( - "Data is the nominated column, and CORRECTED_DATA does not exist. Returning. " - ) - else: - to_delete = [ - "DATA", - ] - for col in to_delete: - if col in colnames: - logger.info(f"Removing {col=} from {str(out_ms_path)}.") - try: - tab.removecols(col) - tab.flush(recursive=True) - except Exception as e: - logger.critical( - f"Failed to remove {col=}! \nCaptured error: {e}" - ) - else: - logger.warning(f"Column {col} not found in {str(out_ms_path)}.") - - logger.info("Renaming CORRECTED_DATA to DATA. ") - tab.renamecol("CORRECTED_DATA", "DATA") + if rename_ms: + if not ms.column: + raise MSError(f"No column has been assigned: {ms}") + + ms = rename_ms_and_columns_for_selfcal( + ms=ms, target=out_ms_path, corrected_data=ms.column, data="DATA" + ) + else: + copytree(ms.path, out_ms_path) + # Because we can trust nothing, verify the + # copy with rsync. On some lustre file systems (mostly seen on stonix) + # components of the measurement sett are not always successfully + # copied with a simple copytree. + if verify: + rsync_copy_directory(ms.path, out_ms_path) + + logger.info("Copying finished. ") + + # The casa gaincal and applycal tasks __really__ expect the input and output + # column names to be DATA and CORRECTED_DATA. So, here we will go through the + # motions of deleting and rnaming columns. Note that the MODEL_DATA column needs + # to exist. The INSTRUMENT_DATA column will also be removed. + logger.info("About to open the table. ") + with table(str(out_ms_path), readonly=False, ack=False) as tab: + logger.info("About tto get the colnames") + colnames = tab.colnames() + logger.info(f"Column names are: {colnames}") + if ms.column == "DATA" and "CORRECTED_DATA" not in colnames: + logger.info( + "Data is the nominated column, and CORRECTED_DATA does not exist. Returning. " + ) + else: + to_delete = [ + "DATA", + ] + for col in to_delete: + if col in colnames: + logger.info(f"Removing {col=} from {str(out_ms_path)}.") + try: + tab.removecols(col) + tab.flush(recursive=True) + except Exception as e: + logger.critical( + f"Failed to remove {col=}! \nCaptured error: {e}" + ) + else: + logger.warning(f"Column {col} not found in {str(out_ms_path)}.") + + logger.info("Renaming CORRECTED_DATA to DATA. ") + tab.renamecol("CORRECTED_DATA", "DATA") # Note that the out_ms_path needs to be set, even if the data column is initially DATA. # Since casa expects DATA, we will force the column to be DATA with the expectation that @@ -207,6 +222,7 @@ def gaincal_applycal_ms( archive_input_ms: bool = False, raise_error_on_fail: bool = True, skip_selfcal: bool = False, + rename_ms: bool = False, ) -> MS: """Perform self-calibration using casa's gaincal and applycal tasks against an input measurement set. @@ -219,6 +235,7 @@ def gaincal_applycal_ms( archive_input_ms (bool, optional): If True, the input measurement set will be compressed into a single file. Defaults to False. raise_error_on_fail (bool, optional): If gaincal does not converge raise en error. if False and gain cal fails return the input ms. Defaults to True. skip_selfcal (bool, optional): Should this self-cal be skipped. If `True`, the a new MS is created but not calibrated the appropriate new name and returned. + rename_ms (bool, optional): It `True` simply rename a MS and adjust columns appropriately (potentially deleting them) instead of copying the complete MS. If `True` `archive_input_ms` is ignored. Defaults to False. Raises: GainCallError: Raised when raise_error_on_fail is True and gaincal does not converge. @@ -236,10 +253,10 @@ def gaincal_applycal_ms( # TODO: If the skip_selfcal is True we should just symlink, maybe? # Pirates like easy things though. - cal_ms = copy_and_clean_ms_casagain(ms=ms, round=round) + cal_ms = copy_and_clean_ms_casagain(ms=ms, round=round, rename_ms=rename_ms) # Archive straight after copying incase we skip the gaincal and return - if archive_input_ms: + if archive_input_ms and not rename_ms: zip_folder(in_path=ms.path) # No need to do work me, hardy diff --git a/flint/utils.py b/flint/utils.py index 2a10b6b1..6454828c 100644 --- a/flint/utils.py +++ b/flint/utils.py @@ -427,12 +427,15 @@ def zip_folder( Returns: Path: the path of the compressed zipped folder """ - + in_path = Path(in_path) out_zip = in_path if out_zip is None else out_zip - logger.info(f"Zipping {in_path}.") - shutil.make_archive(str(out_zip), format=archive_format, base_dir=str(in_path)) - remove_files_folders(in_path) + if in_path.exists(): + logger.info(f"Zipping {in_path}.") + shutil.make_archive(str(out_zip), format=archive_format, base_dir=str(in_path)) + remove_files_folders(in_path) + else: + logger.warning(f"{input_path=} does not exist... Not archiving. ") return out_zip From bca1ce2d727dc14b2c84de5f783a16c0b3c70ed7 Mon Sep 17 00:00:00 2001 From: tgalvin Date: Thu, 20 Jun 2024 14:12:27 +0800 Subject: [PATCH 3/6] corrected cli argument name --- flint/prefect/flows/continuum_pipeline.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flint/prefect/flows/continuum_pipeline.py b/flint/prefect/flows/continuum_pipeline.py index 77df55fc..a4b5869c 100644 --- a/flint/prefect/flows/continuum_pipeline.py +++ b/flint/prefect/flows/continuum_pipeline.py @@ -674,7 +674,7 @@ def get_parser() -> ArgumentParser: help="Skip checking whether the path containing bandpass solutions exists (e.g. if solutions have already been applied)", ) parser.add_argument( - "--move-mss", + "--rename-ms", action="store_true", default=False, help="Rename MSs throught rounds of imaging and self-cal instead of creating copies. This will delete data-columns throughout. ", From 1dcd42d4f7235b27578594751a1ba71744ea077a Mon Sep 17 00:00:00 2001 From: tgalvin Date: Thu, 20 Jun 2024 14:29:03 +0800 Subject: [PATCH 4/6] fixed argument rename --- flint/prefect/flows/continuum_pipeline.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flint/prefect/flows/continuum_pipeline.py b/flint/prefect/flows/continuum_pipeline.py index a4b5869c..c4ed6ac5 100644 --- a/flint/prefect/flows/continuum_pipeline.py +++ b/flint/prefect/flows/continuum_pipeline.py @@ -344,7 +344,7 @@ def process_science_fields( ) cal_mss = task_gaincal_applycal_ms.map( - wsclean_cmd=wsclean_cmds, + ms=wsclean_cmds, round=current_round, update_gain_cal_options=unmapped(gain_cal_options), archive_input_ms=field_options.zip_ms, From 41cc53799f0f1fb36d2edd4b593fe495bd72a331 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 20 Jun 2024 08:03:06 +0000 Subject: [PATCH 5/6] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- flint/ms.py | 2 +- flint/summary.py | 6 +++--- tests/test_ms.py | 1 - 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/flint/ms.py b/flint/ms.py index fd429405..2188fd87 100644 --- a/flint/ms.py +++ b/flint/ms.py @@ -4,10 +4,10 @@ annotations, ) -from curses.ascii import controlnames import shutil from argparse import ArgumentParser from contextlib import contextmanager +from curses.ascii import controlnames from os import PathLike from pathlib import Path from typing import List, NamedTuple, Optional, Tuple, Union diff --git a/flint/summary.py b/flint/summary.py index 0a52bf95..d50c3777 100644 --- a/flint/summary.py +++ b/flint/summary.py @@ -19,6 +19,9 @@ from astropy.table import Table from astropy.time import Time +# Addressing some time interval IERS issue with astropy. +from astropy.utils.iers import conf + from flint.coadd.linmos import LinmosCommand from flint.imager.wsclean import ImageSet, WSCleanCommand from flint.logging import logger @@ -34,9 +37,6 @@ from flint.source_finding.aegean import AegeanOutputs from flint.utils import estimate_skycoord_centre -# Addressing some time interval IERS issue with astropy. -from astropy.utils.iers import conf - conf.auto_max_age = None diff --git a/tests/test_ms.py b/tests/test_ms.py index 3416cb14..53bc5f00 100644 --- a/tests/test_ms.py +++ b/tests/test_ms.py @@ -140,7 +140,6 @@ def test_check_column_in_ms(ms_example): def _get_columns(ms_path): - with table(str(ms_path), readonly=True, ack=False) as tab: return tab.colnames() From 6686ce8a406ce68220cada2f4756fc069bc9245c Mon Sep 17 00:00:00 2001 From: tgalvin Date: Thu, 20 Jun 2024 16:07:08 +0800 Subject: [PATCH 6/6] fixed an unused variable --- flint/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flint/utils.py b/flint/utils.py index 6454828c..1c3c9baa 100644 --- a/flint/utils.py +++ b/flint/utils.py @@ -435,7 +435,7 @@ def zip_folder( shutil.make_archive(str(out_zip), format=archive_format, base_dir=str(in_path)) remove_files_folders(in_path) else: - logger.warning(f"{input_path=} does not exist... Not archiving. ") + logger.warning(f"{in_path=} does not exist... Not archiving. ") return out_zip