Skip to content

Commit

Permalink
interpolate
Browse files Browse the repository at this point in the history
  • Loading branch information
jurjen93 committed Dec 14, 2024
1 parent f2d3547 commit 452a1cc
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions ms_helpers/interpolate_flags.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,8 @@ def interpolate_flags(flagged_ms, ms, make_backup_flags):
interpolated flags
"""

ants = table(flagged_ms + "::ANTENNA", ack=False)
baselines = np.c_[make_ant_pairs(ants.nrows(), 1)]
ants.close()
with table(flagged_ms + "::ANTENNA", ack=False) as ants:
baselines = np.c_[make_ant_pairs(ants.nrows(), 1)]

t1 = table(flagged_ms, ack=False)
t2 = table(ms, ack=False, readonly=False)
Expand All @@ -124,14 +123,12 @@ def interpolate_flags(flagged_ms, ms, make_backup_flags):
np.save(ms+'.flags.npy', t2.getcol("FLAG"))

# Get freq axis first table
t = table(flagged_ms+'::SPECTRAL_WINDOW', ack=False)
freq_flagged_axis = t.getcol("CHAN_FREQ")[0]
t.close()
with table(flagged_ms+'::SPECTRAL_WINDOW', ack=False) as t:
freq_flagged_axis = t.getcol("CHAN_FREQ")[0]

# Get freq axis second table
t = table(ms+'::SPECTRAL_WINDOW', ack=False)
freq_axis = t.getcol("CHAN_FREQ")[0]
t.close()
with table(ms+'::SPECTRAL_WINDOW', ack=False) as t:
freq_axis = t.getcol("CHAN_FREQ")[0]

# Loop over baselines
for n, baseline in enumerate(baselines):
Expand Down Expand Up @@ -202,7 +199,7 @@ def main():
# interpolate flags
for ms in args.msin:
print(f'Interpolate to {ms}')
interpolate_flags(args.msin, ms, args.backup_flags)
interpolate_flags(args.interpolate_from_ms, ms, args.backup_flags)


if __name__ == '__main__':
Expand Down

0 comments on commit 452a1cc

Please sign in to comment.