Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to restore FIELD direction in fix_ms_dir #12

Merged
merged 4 commits into from
Feb 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ ASKAP utilities for updating MeasurementSets for external imagers.

ASKAP MSs are produced in a way that breaks compatibility with most other imagers (e.g. CASA, WSclean). Here we provide two modules (with CLI hooks) that perform the fixes that need to be applied in order to produce astronomically correct imagers with non-YandaSoft imagers:

1. `fix_ms_dir` : ASKAP MeasurementSets are phased towards the centre of field, but not the centre of its given beam. This utility reads the appropriate offsets to the beam centre from the `BEAM_OFFSET` and updates the `FIELD` table, as well as the phase and delay reference columns.
1. `fix_ms_dir` : ASKAP MeasurementSets are phased towards the centre of field, but not the centre of its given beam. This utility reads the appropriate offsets to the beam centre from the `BEAM_OFFSET` and updates the `FIELD` table, as well as the phase and delay reference columns. An option is also available to restore the `FIELD` table directions to the original directions if `fix_ms_dir` has already been run.

2. `fix_ms_corrs` : ASKAP MeasurementSets, as calibrated by the obervatory, provide correlations in the instrument frame. ASKAP has a unique 'roll' axis which means, in principle, the instrument frame can be at any arbitrary rotation on the sky. This utility applies the appropriate rotation matrix to the visibilities such the 'X' is aligned North-South and 'Y' is aligned East-West (IAU convention). Further, ASKAPsoft defines Stokes I as $I=XX+YY$, whereas most other telescopes use $I=\frac{1}{2}(XX+YY)$ (note this also applies to all other Stokes paramters). This factor is also corrected for here at the same time as the rotation. If you have calibrated with non-ASKAPsoft tools, you may need to use the `--no-fix-stokes-factor` option, which will disable the factor of two correction and just do a rotation.

Expand Down Expand Up @@ -81,10 +81,11 @@ usage: fix_ms_dir [-h] [ms]
ASKAP utility - update the pointing centre of a beam in an MS. - Allows imaging by CASA or wsclean.

positional arguments:
ms Measurement set to update (default: None)
ms Measurement set to update (default: None)

optional arguments:
-h, --help show this help message and exit
options:
-h, --help show this help message and exit
-r, --restore Switch to restore direction to the original ASKAPsoft pipeline direction. (default: False)
```

## Contribution
Expand Down
32 changes: 30 additions & 2 deletions fixms/fix_ms_dir.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,26 @@ def decs_rad(dec_string):
return r


def restore_ms_dir(ms):
"""Restore the direction to the ASKAPsoft standard."""

if tableexists("%s/FIELD_OLD" % (ms)):
logger.info("Restoring FIELD directions in %s" % (ms))
tp = table("{}/FIELD".format(ms), readonly=False, ack=False)
fp = table("%s/FIELD_OLD" % (ms), readonly=True, ack=False)
field_dir = fp.getcol("PHASE_DIR")
tp.putcol("PHASE_DIR", field_dir)
tp.putcol("DELAY_DIR", field_dir)
tp.putcol("REFERENCE_DIR", field_dir)
tp.flush()
tp.close()
else:
logger.warning(
"No `FIELD_OLD` table in %s - cannot restore direction if direction has not changed."
% (ms)
)


def fix_ms_dir(ms):
logger.info("Fixing FEED directions in %s" % (ms))
# Check that the observation wasn't in pol_fixed mode
Expand Down Expand Up @@ -368,11 +388,19 @@ def cli():
parser.add_argument(
"ms", help="Measurement set to update", type=str, default=None, nargs="?"
)
parser.add_argument(
"-r",
"--restore",
action="store_true",
help="Switch to restore direction to the original ASKAPsoft pipeline direction",
)
# Parse the command line
args = parser.parse_args()

# Call the main function
fix_ms_dir(args.ms)
if args.restore:
restore_ms_dir(args.ms)
else:
fix_ms_dir(args.ms)


if __name__ == "__main__":
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "fixms"
version = "0.1.5"
version = "0.2.0"
description = ""
authors = ["Alec Thomson (S&A, Kensington WA) <[email protected]>"]
readme = "README.md"
Expand Down
Loading