Skip to content
Snippets Groups Projects
Commit b96fb67e authored by Frits Sweijen's avatar Frits Sweijen
Browse files

Update order of beam corrections in Split-Directions

parent 9dfced6d
No related branches found
No related tags found
1 merge request!38Update order of beam corrections in Split-Directions
#!/usr/bin/env python3
import argparse
from astropy.coordinates import SkyCoord
from losoto.h5parm import h5parm
def main(h5_in: str, solset: str, direction_name: str):
"""
Obtain the direction of the delay calibrator.
Parameters
----------
h5_in : string
H5parm to use.
solset : string
Solset to use.
direction_name : string
Direction to extract the direction for.
"""
h5 = h5parm(h5_in)
ss = h5.getSolset(solset)
ss_dir = ss.getSou()[direction_name]
delay_direction = SkyCoord(ss_dir[0], ss_dir[1], unit="rad")
ra = delay_direction.ra.to("deg").value
dec = delay_direction.dec.to("deg").value
print("Source_id,RA,DEC")
print(f"DelayCal,{ra},{dec}")
if __name__ == "__main__":
parser = argparse.ArgumentParser(
description="Obtain the direction of the delay calibrator."
)
parser.add_argument(
"--h5parm",
type=str,
help="H5parm solution file containing delay calibration solutions.",
)
parser.add_argument(
"--solset", type=str, help="Solset to extract the solutions from."
)
parser.add_argument(
"--direction_name", type=str, help="Direction to extract the solutions for."
)
args = parser.parse_args()
main(args.h5parm, args.solset, args.direction_name)
......@@ -34,6 +34,12 @@ inputs:
doc: |
Time resolution in seconds for the third averaging.
- id: beamdir_delay_cal
type: string
doc: |
Direction in which the primary beam correction for
the delay calibration has been done.
outputs:
- id: parset
type: File
......@@ -49,8 +55,8 @@ requirements:
entry: |+
steps = [split]
split.replaceparms = [phaseshift.phasecenter, applybeam.direction, msout.name]
split.steps = [phaseshift, averager1, applybeam, averager2, applycal, averager3, msout]
split.replaceparms = [phaseshift.phasecenter, applytargetbeam.direction, msout.name]
split.steps = [phaseshift, averager1, applydelaybeam, applycal, applytargetbeam, averager2, msout]
phaseshift.type = phaseshift
phaseshift.phasecenter = $(inputs.phase_centers)
......@@ -59,23 +65,25 @@ requirements:
averager1.freqresolution = 48.82kHz
averager1.timeresolution = 4.
applybeam.type = applybeam
applybeam.direction = $(inputs.phase_centers)
applybeam.beammode = full
averager2.type = averager
averager2.freqresolution = 390.56kHz
averager2.timeresolution = 32
# Apply solutions and more average_target
# Beam and solutions are fulljones, so they don't commute.
applydelaybeam.type = applybeam
applydelaybeam.direction = $(inputs.beamdir_delay_cal)
applydelaybeam.beammode = full
# Apply delay calibrator solutions now.
applycal.type = applycal
applycal.correction = fulljones
applycal.soltab = [amplitude000, phase000]
averager3.type = averager
averager3.freqresolution = $(inputs.frequency_resolution)
averager3.timeresolution = $(inputs.time_resolution)
# Only now can we properly apply the primary beam of the target.
# DP3 understands the previous applybeam. No explicit undo needed.
applytargetbeam.type = applybeam
applytargetbeam.direction = $(inputs.phase_centers)
applytargetbeam.beammode = full
averager2.type = averager
averager2.freqresolution = $(inputs.frequency_resolution)
averager2.timeresolution = $(inputs.time_resolution)
msout.storagemanager = dysco
msout.name = $(inputs.msout_names)
......
cwlVersion: v1.2
class: CommandLineTool
label: extract_delay_calibrator_coordinates
doc: |
Extracts the direction of the calibrator used during delay calibration
from the H5parm with delay calibration solutions.
baseCommand:
- get_delay_dir.py
stdout: delay_dir.csv
stderr: get_delay_dir_err.txt
inputs:
- id: delay_solutions
label: delay_calibrator_solutions
type: File
inputBinding:
position: 0
prefix: --h5parm
doc: |
Delay calibrator solutions in H5parm format.
- id: solset
label: solset
type: string
inputBinding:
position: 1
prefix: --solset
doc: |
SolutionSet to get the direction from.
default: 'sol000'
- id: direction_name
label: direction_name
type: string
inputBinding:
position: 0
prefix: --direction
doc: |
Name of the direction to extract coordinates for.
default: 'Dir00'
outputs:
- id: delay_cal_dir
label: delay_calibrator_direction
type: File
doc: |
CSV table with coordinates of the delay calibrator.
outputBinding:
glob: delay_dir.csv
......@@ -69,6 +69,8 @@ steps:
source: msin
- id: image_cat
source: image_cat
- id: delay_solutions
source: delay_solset
out:
- id: parset
run: ./subworkflows/split_parset.cwl
......
......@@ -24,6 +24,12 @@ inputs:
The image catalogue in CSV format,
containing the target directions.
- id: delay_solutions
type: File
doc: |
Delay calibrator solutions. This is used
to determine the beam direction.
outputs:
- id: parset
type: File
......@@ -32,7 +38,9 @@ outputs:
steps:
- id: get_coordinates
label: Get target ID and coordinates
label: get_coordinates
doc: |
Get target ID and coordinates
in:
- id: delay_calibrator
source: image_cat
......@@ -45,7 +53,9 @@ steps:
run: ../../steps/prep_delay.cwl
- id: generate_filenames
label: Generate MeasurementSet output names
label: generate_filenames
doc: |
Generate MeasurementSet output names
in:
- id: msin
source: msin
......@@ -55,13 +65,43 @@ steps:
- id: msout_names
run: ../../steps/generate_filenames.cwl
- id: get_delay_cal_dir
label: get_delay_cal_direction
doc: |
Obtains the direction of the primary delay calibrator that was used,
by extracting it from the delay calibration solutions.
in:
- id: delay_solutions
source: delay_solutions
out:
- id: delay_cal_dir
run: ../../steps/get_delay_cal_direction.cwl
- id: get_delay_cal_beam_dir
label: get_delay_cal_beam_direction
doc: |
Process the coordinates for the beam correction in
a format suitable for DP3.
in:
- id: delay_calibrator
source: get_delay_cal_dir/delay_cal_dir
out:
- id: source_id
- id: coordinates
- id: logfile
run: ../../steps/prep_delay.cwl
- id: generate_parset
label: Generate direction parset.
label: generate_parset
doc: |
Generate direction parset.
in:
- id: msout_names
source: generate_filenames/msout_names
- id: phase_centers
source: get_coordinates/coordinates
- id: beamdir_delay_cal
source: get_delay_cal_beam_dir/coordinates
out:
- id: parset
run: ../../steps/generate_parset_split.cwl
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment