Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ss/daily filter #88

Merged
merged 4 commits into from
Sep 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions ch_util/cal_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1998,7 +1998,7 @@ def guess_fwhm(freq, pol="X", dec=None, sigma=False, voltage=False, seconds=Fals

# Divide by declination to convert to degrees hour angle
if dec is not None:
sig /= np.cos(dec)
sig = sig / np.cos(dec)

# If requested, convert to seconds
if seconds:
Expand Down Expand Up @@ -2369,7 +2369,7 @@ def interpolate_gain(freq, gain, weight, flag=None, length_scale=30.0):
train = np.flatnonzero(flag[:, ii])
test = np.flatnonzero(~flag[:, ii])

if train.size > 0:
if (train.size > 0) and (test.size > 0):
xtest = x[test, :]

xtrain = x[train, :]
Expand Down
28 changes: 18 additions & 10 deletions ch_util/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -2029,26 +2029,34 @@ def pack_product_array(exp_arr, axis=1):

def fast_pack_product_array(arr):
"""
Equivalent to ch_util.tools.pack_product_array(arr, axis=0),
Equivalent to ch_util.tools.pack_product_array(arr, axis=-1),
but 10^5 times faster for full CHIME!

Currently assumes that arr is a 2D array of shape (nfeeds, nfeeds),
and returns a 1D array of length (nfeed*(nfeed+1))/2. This case
is all we need for phase calibration, but pack_product_array() is
more general.
Parameters
----------
arr : np.ndarray[..., nfeed, nfeed]
Array of full correlation matrices.

Returns
-------
ret : np.ndarray[..., nprod]
Array containing products packed in upper triangle format
with nprod = nfeed*(nfeed+1))/2.
"""

assert arr.ndim == 2
assert arr.shape[0] == arr.shape[1]
assert arr.ndim >= 2
ssiegelx marked this conversation as resolved.
Show resolved Hide resolved
assert arr.shape[-1] == arr.shape[-2]

nfeed = arr.shape[0]
nfeed = arr.shape[-1]
nprod = (nfeed * (nfeed + 1)) // 2

ret = np.zeros(nprod, dtype=np.float64)
shp = arr.shape[:-2] + (nprod,)

ret = np.zeros(shp, dtype=arr.dtype)
iout = 0

for i in range(nfeed):
ret[iout : (iout + nfeed - i)] = arr[i, i:]
ret[..., iout : (iout + nfeed - i)] = arr[..., i, i:]
iout += nfeed - i

return ret
Expand Down