From abded2d903636a92922048253dc1240814f07cd2 Mon Sep 17 00:00:00 2001 From: jurjen93 Date: Wed, 28 Aug 2024 16:54:17 +0200 Subject: [PATCH] upd --- ms_helpers/concat_with_dummies.py | 12 ++++++++---- subtract/subtract_with_wsclean.py | 8 ++++---- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/ms_helpers/concat_with_dummies.py b/ms_helpers/concat_with_dummies.py index c5bb2ffe..468641a7 100644 --- a/ms_helpers/concat_with_dummies.py +++ b/ms_helpers/concat_with_dummies.py @@ -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): @@ -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 ---') diff --git a/subtract/subtract_with_wsclean.py b/subtract/subtract_with_wsclean.py index 2ca0cbfc..f0defe99 100644 --- a/subtract/subtract_with_wsclean.py +++ b/subtract/subtract_with_wsclean.py @@ -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) @@ -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")