Skip to content

Commit

Permalink
Calibration Utility Updates (#287)
Browse files Browse the repository at this point in the history
  • Loading branch information
landmanbester authored Jul 5, 2023
1 parent 967c779 commit 2e66bde
Show file tree
Hide file tree
Showing 12 changed files with 28 additions and 3 deletions.
1 change: 1 addition & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ History

X.Y.Z (YYYY-MM-DD)
------------------
* Check that ncorr is never larger than 2 in calibration utils (:pr:`287`)
* Optionally check NRT allocations (:pr:`286`)
* Use `packaging.version.Version` instead of deprecated `distutils.version.LooseVersion` (:pr:`285`)
* Pin numba to less than 0.59 in anticipation of @generated_jit deprecation (:pr:`284`)
Expand Down
4 changes: 4 additions & 0 deletions africanus/calibration/utils/compute_and_corrupt_vis.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@ def compute_and_corrupt_vis(time_bin_indices, time_bin_counts, antenna1,
def _compute_and_corrupt_vis_fn(time_bin_indices, time_bin_counts,
antenna1, antenna2, jones, model,
uvw, freq, lm):
if model.shape[-1] > 2:
raise ValueError('ncorr cant be larger than 2')
if jones.shape[-1] > 2:
raise ValueError('ncorr cant be larger than 2')
# for dask arrays we need to adjust the chunks to
# start counting from zero
time_bin_indices -= time_bin_indices.min()
Expand Down
4 changes: 4 additions & 0 deletions africanus/calibration/utils/correct_vis.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@ def _correct_vis_fn(time_bin_indices, time_bin_counts,
antenna1, antenna2, jones, vis, flag):
# for dask arrays we need to adjust the chunks to
# start counting from zero
if vis.shape[-1] > 2:
raise ValueError('ncorr cant be larger than 2')
if jones.shape[-1] > 2:
raise ValueError('ncorr cant be larger than 2')
time_bin_indices -= time_bin_indices.min()
jones_shape = np.shape(jones)
n_tim = jones_shape[0]
Expand Down
4 changes: 4 additions & 0 deletions africanus/calibration/utils/corrupt_vis.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ def corrupt_vis(time_bin_indices, time_bin_counts, antenna1,

def _corrupt_vis_fn(time_bin_indices, time_bin_counts, antenna1,
antenna2, jones, model):
if model.shape[-1] > 2:
raise ValueError('ncorr cant be larger than 2')
if jones.shape[-1] > 2:
raise ValueError('ncorr cant be larger than 2')
# for dask arrays we need to adjust the chunks to
# start counting from zero
time_bin_indices -= time_bin_indices.min()
Expand Down
6 changes: 6 additions & 0 deletions africanus/calibration/utils/residual_vis.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,12 @@ def residual_vis(time_bin_indices, time_bin_counts, antenna1,
@wraps(residual_vis)
def _residual_vis_fn(time_bin_indices, time_bin_counts, antenna1,
antenna2, jones, vis, flag, model):
if vis.shape[-1] > 2:
raise ValueError('ncorr cant be larger than 2')
if jones.shape[-1] > 2:
raise ValueError('ncorr cant be larger than 2')
if model.shape[-1] > 2:
raise ValueError('ncorr cant be larger than 2')
# for dask arrays we need to adjust the chunks to
# start counting from zero
time_bin_indices -= time_bin_indices.min()
Expand Down
3 changes: 2 additions & 1 deletion africanus/calibration/utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,12 @@ def check_type(jones, vis, vis_type='vis'):
def chunkify_rows(time, utimes_per_chunk):
utimes, time_bin_counts = np.unique(time, return_counts=True)
n_time = len(utimes)
if utimes_per_chunk <= 0:
utimes_per_chunk = n_time
row_chunks = [np.sum(time_bin_counts[i:i+utimes_per_chunk])
for i in range(0, n_time, utimes_per_chunk)]
time_bin_indices = np.zeros(n_time, dtype=np.int32)
time_bin_indices[1::] = np.cumsum(time_bin_counts)[0:-1]
time_bin_indices = time_bin_indices.astype(np.int32)
time_bin_counts = time_bin_counts.astype(np.int32)
return tuple(row_chunks), time_bin_indices, time_bin_counts

Expand Down
1 change: 1 addition & 0 deletions africanus/experimental/rime/fused/terms/brightness.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ def codegen(context, builder, signature, args):

class Brightness(Term):
"""Brightness Matrix Term"""

def __init__(self, configuration, stokes, corrs):
super().__init__(configuration)
self.stokes = stokes
Expand Down
1 change: 1 addition & 0 deletions africanus/experimental/rime/fused/terms/cube_dde.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ def codegen(context, builder, signature, args):

class BeamCubeDDE(Term):
"""Voxel Beam Cube Term"""

def __init__(self, configuration, corrs):
if configuration not in {"left", "right"}:
raise ValueError(f"BeamCubeDDE configuration must be"
Expand Down
1 change: 1 addition & 0 deletions africanus/experimental/rime/fused/terms/feed_rotation.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

class FeedRotation(Term):
"""Feed Rotation Term"""

def __init__(self, configuration, feed_type, corrs):
if configuration not in {"left", "right"}:
raise ValueError(f"FeedRotation configuration must "
Expand Down
1 change: 1 addition & 0 deletions africanus/experimental/rime/fused/terms/gaussian.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

class Gaussian(Term):
"""Gaussian Amplitude Term"""

def dask_schema(self, uvw, chan_freq, gauss_shape):
assert uvw.ndim == 2
assert chan_freq.ndim == 1
Expand Down
1 change: 1 addition & 0 deletions africanus/experimental/rime/fused/terms/phase.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

class Phase(Term):
"""Phase Delay Term"""

def dask_schema(self, lm, uvw, chan_freq, convention="fourier"):
assert lm.ndim == 2
assert uvw.ndim == 2
Expand Down
4 changes: 2 additions & 2 deletions africanus/rime/examples/tests/meqtrees/turbo-sim.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@
# these will show up in the menu automatically

# OMS: time to retire this one
#import Meow.LSM
#lsm = Meow.LSM.MeowLSM(include_options=False);
# import Meow.LSM
# lsm = Meow.LSM.MeowLSM(include_options=False);

models = [gridded_sky, azel_sky, transient_sky, fitsimage_sky] # ,lsm ]

Expand Down

0 comments on commit 2e66bde

Please sign in to comment.