Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
jurjen93 committed Aug 25, 2023
1 parent 1e899ac commit 60a337c
Show file tree
Hide file tree
Showing 9 changed files with 40 additions and 81 deletions.
14 changes: 0 additions & 14 deletions dp3_helpers/circ2lin.sh

This file was deleted.

14 changes: 0 additions & 14 deletions dp3_helpers/lin2circ.sh

This file was deleted.

2 changes: 1 addition & 1 deletion h5_helpers/add_antenna_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

def add_antenna_from_ms(ms, h5, solset=None):
"""
Add antenna table to h5 from corresponding MS
Insert antenna table from MS in given h5
WARNING: this overwrites the antenna table from the h5
:param ms: Measurement set
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion h5_helpers/h5_filter.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
This script is meant to filter directions outside of a specific circle.
This script is meant to filter directions outside of a given circle.
This can be useful for excluding directions at the boundaries of a field because the solutions are less good there.
"""

Expand Down
71 changes: 36 additions & 35 deletions h5_helpers/pol_phase_rot.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@

class PhaseRotate:
"""
Make template based on given h5parm file
Make template h5 with default values (phase=0 and amplitude=1) and convert to phase rotate matrix for
polarization alignment between different observations.
"""
def __init__(self, name_in, name_out, freqs = None):
os.system(' '.join(['cp', name_in, name_out]))
Expand Down Expand Up @@ -104,40 +105,6 @@ def make_template(self, shape = None, polrot = None):

return self

def rotate(self, intercept, rotation_measure):
"""
Rotate angle by the following matrix:
/e^(i*rho) 0 \
| |
\ 0 1/
:param intercept: intercept
:param rotation_measure: rotation measure in rad/m^2
"""
print('\n2) ADD PHASE ROTATION')

phaserot = intercept+rotation_measure*(speed_of_light/self.freqs)**2

mapping = list(zip(list(self.freqs), list(phaserot)))
print('########################\nFrequency to rotation in radian (circular base):\n------------------------')
for element in mapping:
print(str(int(element[0]))+'Hz --> '+str(round(element[1], 3))+'rad')

# print('Rotate with rotation angle: '+str(intercept) + ' radian')
for solset in self.h5.root._v_groups.keys():
ss = self.h5.root._f_get_child(solset)
for soltab in ss._v_groups.keys():
if 'phase' in soltab:
phaseval = ss._f_get_child(soltab).val[:]
# same phaserot for all antennas
for ant_idx in range(phaseval.shape[2]):
phaseval[0, :, ant_idx, 0, 0] += phaserot
self.update_array(ss._f_get_child(soltab), phaseval, 'val')
print("########################")

self.circ2lin()

return self

def circ2lin(self):
"""
Expand Down Expand Up @@ -192,6 +159,40 @@ def circ2lin(self):

return G_new

def rotate(self, intercept, rotation_measure):
"""
Rotate angle by the following matrix:
/e^(i*rho) 0 \
| |
\ 0 1/
:param intercept: intercept
:param rotation_measure: rotation measure in rad/m^2
"""
print('\n2) ADD PHASE ROTATION')

phaserot = intercept+rotation_measure*(speed_of_light/self.freqs)**2

mapping = list(zip(list(self.freqs), list(phaserot)))
print('########################\nFrequency to rotation in radian (circular base):\n------------------------')
for element in mapping:
print(str(int(element[0]))+'Hz --> '+str(round(element[1], 3))+'rad')

# print('Rotate with rotation angle: '+str(intercept) + ' radian')
for solset in self.h5.root._v_groups.keys():
ss = self.h5.root._f_get_child(solset)
for soltab in ss._v_groups.keys():
if 'phase' in soltab:
phaseval = ss._f_get_child(soltab).val[:]
# same phaserot for all antennas
for ant_idx in range(phaseval.shape[2]):
phaseval[0, :, ant_idx, 0, 0] += phaserot
self.update_array(ss._f_get_child(soltab), phaseval, 'val')
print("########################")

self.circ2lin()

return self

if __name__ == '__main__':

Expand Down
1 change: 0 additions & 1 deletion h5_helpers/smooth_bandpass.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""
Script for smoothing bandpass with median filter.
Useful for fitting on strange patterns in bandpass.
Be careful with usage and always check the results in the plots given at the end.
Expand Down
15 changes: 0 additions & 15 deletions h5_helpers/testcirc2lin.py

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"""Functions to parse history from MS"""

import os
import re

Expand Down

0 comments on commit 60a337c

Please sign in to comment.