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

SPR1-2367: Remove IMAGING_WEIGHT column from MS #356

Merged
merged 2 commits into from
Jul 20, 2022
Merged
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
50 changes: 25 additions & 25 deletions katdal/ms_extra.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ def open_table(name, readonly=False, verbose=False, **kwargs):
return tables.table(name, readonly=readonly, ack=verbose, **kwargs)


# TODO: change interface to `create_ms(filename, nchan, npol, model_data=False)`
def create_ms(filename, table_desc=None, dm_info=None):
"""Create an empty MS with the default expected sub-tables and columns."""
with tables.default_ms(filename, table_desc, dm_info) as main_table:
Expand Down Expand Up @@ -100,24 +101,35 @@ def define_hypercolumn(desc):
}


# TODO: make this private and remove `nbl` parameter
def kat_ms_desc_and_dminfo(nbl, nchan, ncorr, model_data=False):
"""
Creates Table Description and Data Manager Information objects that
describe a MeasurementSet suitable for holding MeerKAT data.
"""Describe the structure of a MeerKAT MeasurementSet.

Creates additional DATA, IMAGING_WEIGHT and possibly
MODEL_DATA and CORRECTED_DATA columns.
This creates Table Description and Data Manager Information objects
that describe a MeasurementSet suitable for holding MeerKAT data,
adding various large columns (DATA, WEIGHT_SPECTRUM, SIGMA_SPECTRUM,
and possibly MODEL_DATA and CORRECTED_DATA). The output can be used
as input to :func:`casacore.tables.default_ms` to create a new empty MS.

Columns are given fixed shapes defined by the arguments to this function.

:param nbl: Number of baselines.
:param nchan: Number of channels.
:param ncorr: Number of correlation products.
:param model_data: Boolean indicated whether MODEL_DATA and CORRECTED_DATA
should be added to the Measurement Set.
:return: Returns a tuple containing a table description describing
the extra columns and hypercolumns, as well as a Data Manager
description.
Parameters
----------
nbl : int
Number of baselines (not used)
nchan : int
Number of frequency channels
ncorr : int
Number of polarisation correlation products (e.g. HH, VV, HV, VH)
model_data : bool, optional
True if MODEL_DATA and CORRECTED_DATA columns should be added to MS

Returns
-------
desc : dict mapping str to dict
Table description describing the extra columns and hypercolumns
dminfo : dict mapping str to dict
Data Manager Information description
"""
# Columns that will be modified. We want to keep things like their
# keywords, dims and shapes.
Expand Down Expand Up @@ -228,16 +240,6 @@ def dmspec(coldesc, tile_mem_limit=None):
dmgroup_spec[dm_group] = dmspec(desc["desc"])
additional_columns.append(desc)

dm_group = 'ImagingWeight'
shape = [nchan]
desc = tables.tablecreatearraycoldesc(
"IMAGING_WEIGHT", 0,
comment="Weight set by imaging task (e.g. uniform weighting)",
options=4, valuetype='float', shape=shape, ndim=len(shape),
datamanagergroup=dm_group, datamanagertype='TiledColumnStMan')
dmgroup_spec[dm_group] = dmspec(desc["desc"])
additional_columns.append(desc)

# Add MODEL_DATA and CORRECTED_DATA if requested
if model_data:
dm_group = 'ModelData'
Expand Down Expand Up @@ -388,8 +390,6 @@ def populate_main_dict(uvw_coordinates, vis_data, flag_data, weight_data, timest
# https://casadocs.readthedocs.io/en/stable/notebooks/data_weights.html
# for further details
main_dict['SIGMA_SPECTRUM'] = weight_data ** -0.5
# Weight set by imaging task (e.g. uniform weighting) (float, 1-dim)
# main_dict['IMAGING_WEIGHT'] = np.ones((num_vis_samples, 1), dtype=np.float32)
# The sampling interval (double)
main_dict['INTERVAL'] = integrate_length * np.ones(num_vis_samples)
# The model data column (complex, 3-dim)
Expand Down