-
Notifications
You must be signed in to change notification settings - Fork 2
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
feat(galt_auto_cont): Add container and task for saving raw Galt autos. #109
base: master
Are you sure you want to change the base?
Changes from 3 commits
3bcf099
c2e52c7
9c80c0c
079d265
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,7 @@ | |
from ch_util import fluxcat | ||
from ch_util import finder | ||
from ch_util import rfi | ||
from ch_util import layout | ||
|
||
from draco.core import task | ||
from draco.util import _fast_tools | ||
|
@@ -2364,3 +2365,65 @@ def _calculate_uv(freq, prod, inputmap): | |
uv = dist[:, np.newaxis, :] / lmbda[np.newaxis, :, np.newaxis] | ||
|
||
return uv | ||
|
||
class ExtractGaltAutoCorrelation(task.SingleTask): | ||
"""Extract the autocorrelations of the Galt telescope from a holography acquisition.""" | ||
|
||
def process(self, data): | ||
"""Extract the Galt autocorrelations and write them to disk. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add blank lines between the summary and parameters section, and between the parameters and returns section. |
||
Parameters | ||
---------- | ||
data: TimeStream | ||
A TimeStream container holding a raw holography acquisition. | ||
Returns | ||
------- | ||
autocorrelation: containers.GaltAutocorrelation | ||
A GaltAutocorrelation container holding the extracted Galt autos | ||
as a function of frequency, polarization product, and time. | ||
""" | ||
# Redistribute over freq | ||
data.redistribute("freq") | ||
|
||
# Locate the holographic indices | ||
layout_graph = layout.graph.from_db(data.time[0]) | ||
|
||
galt_inputs = get_holographic_index( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't see the Alternatively, you could use the Then, you would provide that
I think this is probably preferable, because |
||
get_correlator_inputs(layout_graph, correlator="chime") | ||
) | ||
|
||
# Get the product map and inputs | ||
prodmap = data.prod | ||
ina, inb = prodmap["input_a"], prodmap["input_b"] | ||
|
||
# Locate the Galt autocorrelations and cross-pol correlation | ||
flag_YY = np.where((ina == galt_inputs[0]) & (inb == galt_inputs[0]), 1, 0) | ||
flag_YX = np.where((ina == galt_inputs[0]) & (inb == galt_inputs[1]), 1, 0) | ||
flag_XX = np.where((ina == galt_inputs[1]) & (inb == galt_inputs[1]), 1, 0) | ||
|
||
auto_flag = (flag_YY + flag_YX + flag_XX).astype(bool) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the way this is done, there is no guarantee that the products picked out by I would probably construct the polarisation axis as follows:
|
||
|
||
# Dereference beam and weight datasets | ||
beam = data.vis[:].local_array | ||
weight = data.weight[:].local_array | ||
|
||
# Load only the data corresponding to the Galt inputs | ||
galt_auto = beam[:, auto_flag, :] | ||
galt_weight = weight[:, auto_flag, :] | ||
|
||
# Initialize the auto container | ||
autocorrelation = containers.GaltAutocorrelation( | ||
pol=np.array([b"YY", b"YX", b"XX"]), | ||
attrs_from=data, | ||
freq=data.freq, | ||
time=data.index_map["time"], | ||
comm=data.comm, | ||
distributed=data.distributed, | ||
) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think you want to use More generally, you can pass |
||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm wondering if instead of creating a separate
The benefit of doing it this way is that we reduce the overall number of containers and we can apply other pipeline tasks that have been developed for the CHIME timestreams to the holography autocorrelation data without any modifications to those tasks. |
||
# Redistribute output container over frequency | ||
autocorrelation.redistribute("freq") | ||
|
||
autocorrelation.auto[:].local_array[:] = galt_auto | ||
autocorrelation.weight[:].local_array[:] = galt_weight | ||
|
||
return autocorrelation |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -802,6 +802,39 @@ def source(self): | |||||
return self.index_map["source"] | ||||||
|
||||||
|
||||||
class GaltAutocorrelation(FreqContainer, TODContainer): | ||||||
_axes = ("freq", "pol", "time") | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To support common axes like There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
If you inherit from the base classes, then you no longer need to specify the axes covered by those classes. A new instance will have all the unique axes contained in all subclasses. |
||||||
|
||||||
_dataset_spec = { | ||||||
"auto": { | ||||||
"axes": ["freq", "pol", "time"], | ||||||
"dtype": np.complex64, | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. since this container is explicitly for autos, this probably doesn't need to be complex There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agreed, but in principle we also want the cross-correlation of the two 26m polarisations in addition to 26m XX and YY, and that has a phase, so I set the container to be complex. |
||||||
"initialise": True, | ||||||
"distributed": True, | ||||||
"distributed_axis": "freq", | ||||||
}, | ||||||
"weight": { | ||||||
"axes": ["freq", "pol", "time"], | ||||||
"dtype": np.float64, | ||||||
"initialise": True, | ||||||
"distributed": True, | ||||||
"distributed_axis": "freq", | ||||||
}, | ||||||
} | ||||||
|
||||||
@property | ||||||
def auto(self): | ||||||
return self.datasets["auto"] | ||||||
|
||||||
@property | ||||||
def weight(self): | ||||||
return self.datasets["weight"] | ||||||
|
||||||
@property | ||||||
def fpga_count(self): | ||||||
return self.index_map["time"]["fpga_count"] | ||||||
|
||||||
|
||||||
def make_empty_corrdata( | ||||||
freq=None, | ||||||
input=None, | ||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,7 +40,6 @@ | |
|
||
from draco.core import task, io | ||
|
||
|
||
class LoadCorrDataFiles(task.SingleTask): | ||
"""Load data from files passed into the setup routine. | ||
|
||
|
@@ -473,3 +472,4 @@ def next(self, files): | |
) | ||
|
||
return sorted(list(new_files)) | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think these new lines can be be removed so that this PR does not modify the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think unless there is something wrong with the starting and ending hour angles, this should use
self.log.info
instead ofself.log.warning
.