Skip to content

Commit

Permalink
upd
Browse files Browse the repository at this point in the history
  • Loading branch information
jurjen93 committed Aug 28, 2024
1 parent 8ecdcfe commit abded2d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
12 changes: 8 additions & 4 deletions ms_helpers/concat_with_dummies.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@
import argparse
import os
from pprint import pprint
import re


def case_insensitive_replace(text, old, new):
return re.sub(re.escape(old), new, text, flags=re.IGNORECASE)


def get_largest_divider(inp, max=1000):
Expand Down Expand Up @@ -172,17 +177,16 @@ def make_parset(mss, concat_name, data_column, time_avg, freq_avg, time_res, fre

for dir, ms in ms_dict.items():


if concat_name is None:
concatname = ('_'.join([i for i in ms[0].split('_') if 'mhz' not in i.lower()]).
replace('mstargetphase','')+'.concat.ms').replace('..', '.').split('/')[-1]
parsetname = concatname.replace('.concat.ms', '.parset')
parsetname = case_insensitive_replace(concatname, '.concat.ms', '.parset')

else:
concatname = concat_name
parsetname = concatname.replace('.ms', '.parset')
parsetname = case_insensitive_replace(concatname, '.ms', '.parset')

txtname = parsetname.replace('.parset', '.txt')
txtname = case_insensitive_replace(parsetname, '.parset', '.txt')

if fill_freq_gaps(input=ms, make_dummies=True, output_name=txtname, only_basename=only_basename):
print('--- SUCCESS: no frequency gaps found ---')
Expand Down
8 changes: 4 additions & 4 deletions subtract/subtract_with_wsclean.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ def get_data(soltab, axis):
phase_v = get_data('phase000', 'val')
amplitude_v = get_data('amplitude000', 'val')
new_dirs = np.array([outh5.root.sol000.source[:][dir_idx]])
new_dirs['name'][0] = bytes('Dir' + str(0).zfill(2), 'utf-8')
# new_dirs['name'][0] = bytes('Dir' + str(0).zfill(2), 'utf-8')
dirs = np.array([outh5.root.sol000.phase000.dir[:][dir_idx]])

outh5.remove_node("/sol000/phase000", "val", recursive=True)
Expand Down Expand Up @@ -856,12 +856,12 @@ def main():

if args.scratch:
# copy averaged MS back to output folder
for ms in msout: os.system(f'cp -r {ms} {outpath}')
for ms in msout: os.system(f'cp -r {ms} {outpath}/{dirname.replace("Dir","facet_")}-{ms.split("/")[-1]}')
# clean up scratch directory (for big MS)
os.system('rm -rf *.ms')
os.system(f'cp *.log {outpath} && rm -rf *.ms')
os.chdir(outpath)

print(f"DONE: See output --> sub{subpred.scale}*.ms")
print(f'DONE: See output --> {dirname.replace("Dir","facet_")}-*.ms')
else:
print(f"DONE: Output is SUBTRACT_DATA column in input MS")

Expand Down

0 comments on commit abded2d

Please sign in to comment.