Skip to content

Commit

Permalink
remove leakage attempts to use stokes .i.
Browse files Browse the repository at this point in the history
  • Loading branch information
tgalvin committed Dec 25, 2024
1 parent 6ee17b8 commit c03a5ce
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 3 deletions.
11 changes: 8 additions & 3 deletions flint/coadd/linmos.py
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,9 @@ def _get_alpha_linmos_option(pol_axis: Optional[float] = None) -> str:


def _get_holography_linmos_options(
holofile: Optional[Path] = None, pol_axis: Optional[float] = None
holofile: Optional[Path] = None,
pol_axis: Optional[float] = None,
remove_leakage: bool = False,
) -> str:
"""Construct the appropriate set of linmos options that
describe the use of the holography cube file to primary
Expand All @@ -414,6 +416,7 @@ def _get_holography_linmos_options(
Args:
holofile (Optional[Path], optional): Path to the holography cube file to primary beam correct with. Defaults to None.
pol_axis (Optional[float], optional): The rotation of the third axis as described in an ASAKP MS. Defaults to None.
remove_leakage (bool, optional): Add the directive to remove leakage. Defaults to False.
Returns:
str: Set of linmos options to add to a parset file
Expand All @@ -431,7 +434,7 @@ def _get_holography_linmos_options(
parset = (
f"linmos.primarybeam = ASKAP_PB\n"
f"linmos.primarybeam.ASKAP_PB.image = {str(holofile.absolute())}\n"
f"linmos.removeleakage = true\n"
f"linmos.removeleakage = {'true' if remove_leakage else 'false'}\n"
)
parset += _get_alpha_linmos_option(pol_axis=pol_axis)

Expand Down Expand Up @@ -522,7 +525,9 @@ def generate_linmos_parameter_set(
"linmos.imageaccess.axis = 1\n" # WSClean outputs frequency as second dimension (so 1 in zero indexing)
)
# Construct the holography section of the linmos parset
parset += _get_holography_linmos_options(holofile=holofile, pol_axis=pol_axis)
parset += _get_holography_linmos_options(
holofile=holofile, pol_axis=pol_axis, remove_leakage=".i." not in str(images[0])
)

# Now write the file, me hearty
logger.info(f"Writing parset to {str(parset_output_path)}.")
Expand Down
29 changes: 29 additions & 0 deletions flint/prefect/flows/subtract_cube_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
)
from flint.options import (
AddModelSubtractFieldOptions,
BaseOptions,
SubtractFieldOptions,
add_options_to_parser,
create_options_from_parser,
Expand All @@ -42,6 +43,15 @@
from flint.naming import get_sbid_from_path


class CrystalBallOptions(BaseOptions):
"""Options related to running crystal ball"""

attempt_crystalball: bool = False
"""Attempt to predict the model visibilities using ``crystalball``"""
wsclean_pol_mode: List[str] = ["i"]
"""The polarisation of the wsclean model that was generated"""


def _check_and_verify_options(
options: Union[AddModelSubtractFieldOptions, SubtractFieldOptions],
) -> None:
Expand Down Expand Up @@ -174,6 +184,25 @@ def task_addmodel_to_ms(
return ms.with_options(model_column="MODEL_DATA")


def task_crystalball_to_ms(ms: MS, crystalball_options: CrystalBallOptions) -> MS:
from prefect_dask import get_dask_client
from flint.imager.wsclean import get_wsclean_output_source_list_path

logger.info(f"Searching for wsclean source list for {ms.path}")
for idx, pol in enumerate(crystalball_options.wsclean_pol_mode):
wsclean_source_list_path = get_wsclean_output_source_list_path(
name_path=ms.path, pol=pol
)
assert (
wsclean_source_list_path.exists()
), f"{wsclean_source_list_path=} was requested, but does not exist"

with get_dask_client():
logger.info("Running crystalball in prefect dask client")

return ms


@task
def task_combine_all_linmos_images(
linmos_commands: List[LinmosCommand],
Expand Down

0 comments on commit c03a5ce

Please sign in to comment.