|
|
|
@ -3,10 +3,12 @@
@@ -3,10 +3,12 @@
|
|
|
|
|
Creates the {exp}.comment and {exp}.tasav.txt files for the EVN Pipeline. |
|
|
|
|
Given a default template, customizes it to include the basic data from the given experiment. |
|
|
|
|
|
|
|
|
|
Version: 2.8 |
|
|
|
|
Date: Nov 2019 |
|
|
|
|
Version: 3.0 |
|
|
|
|
Date: May 2021 |
|
|
|
|
Author: Benito Marcote (marcote@jive.eu) |
|
|
|
|
|
|
|
|
|
version 3.0 changes |
|
|
|
|
- Support for passes with primary beam corrections. |
|
|
|
|
version 2.8 changes |
|
|
|
|
- Bug fix happening in some cases for e-EVN (e.g. RSK04). |
|
|
|
|
version 2.7 changes |
|
|
|
@ -36,10 +38,11 @@ import subprocess
@@ -36,10 +38,11 @@ import subprocess
|
|
|
|
|
from datetime import datetime as dt |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
__version__ = 2.7 |
|
|
|
|
__version__ = 3.0 |
|
|
|
|
# The .comment file template is located in the same directory as this script. Or it should be. |
|
|
|
|
template_comment_file = os.path.dirname(os.path.abspath(__file__)) + '/template.comment' |
|
|
|
|
template_tasav_file = os.path.dirname(os.path.abspath(__file__)) + '/template.tasav.txt' |
|
|
|
|
# template-pbcor.tasav.txt is also expected to be at the same location, for primary beam corrected experiments |
|
|
|
|
|
|
|
|
|
help_str = """Creates a .comment file (in $OUT/exp directory) and a .tasav.txt file (in $IN/exp). |
|
|
|
|
|
|
|
|
@ -75,32 +78,37 @@ def get_input_file_info():
@@ -75,32 +78,37 @@ def get_input_file_info():
|
|
|
|
|
- target : list |
|
|
|
|
The targets. Should have the same dimension than the phaseref (unless it is not a phase |
|
|
|
|
referencing experiment). |
|
|
|
|
- do_primarybeam : Bool |
|
|
|
|
If primary beam corrections were applied. |
|
|
|
|
""" |
|
|
|
|
with open('/jop83_0/pipe/in/{}/{}.inp.txt'.format(args.experiment.lower().split('_')[0], |
|
|
|
|
args.experiment.lower()), 'r') as inpfile: |
|
|
|
|
phaseref = None |
|
|
|
|
cutoff = 7 |
|
|
|
|
target = None |
|
|
|
|
do_primary_beam = False |
|
|
|
|
for inpline in inpfile.readlines(): |
|
|
|
|
if 'refant' in inpline and inpline[0].strip() != '#': |
|
|
|
|
if 'refant' in inpline and inpline.strip()[0] != '#': |
|
|
|
|
refant = inpline.split('=')[1].strip().split(',')[0] |
|
|
|
|
if ('fring_snr' in inpline) and inpline[0].strip() != '#': |
|
|
|
|
if ('fring_snr' in inpline) and inpline.strip()[0] != '#': |
|
|
|
|
cutoff = int(inpline.split('=')[1].strip()) |
|
|
|
|
if 'bpass' in inpline and inpline[0].strip() != '#': |
|
|
|
|
if 'bpass' in inpline and inpline.strip()[0] != '#': |
|
|
|
|
bpass = [i.strip() for i in inpline.split('=')[1].strip().split(',')] |
|
|
|
|
if ('phaseref' in inpline) and inpline[0].strip() != '#': |
|
|
|
|
if ('phaseref' in inpline) and inpline.strip()[0] != '#': |
|
|
|
|
phaseref = [i.strip() for i in inpline.split('=')[1].strip().split(',')] |
|
|
|
|
if ('target' in inpline) and inpline[0].strip() != '#': |
|
|
|
|
if ('target' in inpline) and inpline.strip()[0] != '#': |
|
|
|
|
target = [i.strip() for i in inpline.split('=')[1].strip().split(',')] |
|
|
|
|
if ('sources' in inpline) and inpline[0].strip() != '#': |
|
|
|
|
if ('sources' in inpline) and inpline.strip()[0] != '#': |
|
|
|
|
if target is None: |
|
|
|
|
target = [i.strip() for i in inpline.split('=')[1].strip().split(',')] |
|
|
|
|
if ('doprimarybeam=1' in inpline.replace(' ', '')) and (inpline.strip()[0] != '#'): |
|
|
|
|
do_primary_beam = True |
|
|
|
|
|
|
|
|
|
if target is None: |
|
|
|
|
# No phase referencing experiment and no additional sources specified apart of bpass |
|
|
|
|
target = bpass |
|
|
|
|
|
|
|
|
|
return refant, cutoff, bpass, phaseref, target |
|
|
|
|
return refant, cutoff, bpass, phaseref, target, do_primary_beam |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def parse_sources(bpass, phaseref, target): |
|
|
|
@ -330,10 +338,11 @@ def parse_sources_list(sources, max_item_first_raw=3):
@@ -330,10 +338,11 @@ def parse_sources_list(sources, max_item_first_raw=3):
|
|
|
|
|
return s |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
refant, fringe_cutoff, *all_sources, do_pb_cor = get_input_file_info() |
|
|
|
|
|
|
|
|
|
with open(template_comment_file, 'r') as template: |
|
|
|
|
type_experiment = 'line' if args.experiment[-2:] == '_2' else 'cont' |
|
|
|
|
full_text = template.read() |
|
|
|
|
refant, fringe_cutoff, *all_sources = get_input_file_info() |
|
|
|
|
full_text = full_text.format(setup_header=parse_setup(args.experiment.split('_')[0], type_experiment, *get_setup()), |
|
|
|
|
sources_info=parse_sources(*all_sources), |
|
|
|
|
station_info=parse_antennas(get_antennas()), fringe_cutoff=fringe_cutoff, |
|
|
|
@ -349,9 +358,10 @@ with open(template_comment_file, 'r') as template:
@@ -349,9 +358,10 @@ with open(template_comment_file, 'r') as template:
|
|
|
|
|
print('\nFile {0}.comment created successfully in {1}/.'.format(args.experiment.lower(), outputdir)) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
with open(template_tasav_file, 'r') as template: |
|
|
|
|
refant, fringe_cutoff, bp_sources, pcal_sources, target_sources, do_pb_cor = get_input_file_info() |
|
|
|
|
|
|
|
|
|
with open(template_tasav_file.replace('template', 'template-pbcor' if do_pb_cor else 'template'), 'r') as template: |
|
|
|
|
full_text = template.read() |
|
|
|
|
refant, fringe_cutoff, bp_sources, pcal_sources, target_sources = get_input_file_info() |
|
|
|
|
if pcal_sources is None: |
|
|
|
|
full_text = full_text.format(expname=args.experiment.upper().split('_')[0], |
|
|
|
|
fringe_sources=parse_sources_list(bp_sources, 3), |
|
|
|
|