NRAO Home > CASA > CASA Toolkit Reference Manual
ms.getdata - Function

1.3.1 Read values from the measurement set.


Description

This function will read the specified items from the currently selected measurement set and returns them in fields of a record. The main difference between this and direct access of the table, using the table tool, is that this function reads data from the selected measurement set, it provides access to derived quantities like amplitude & flag_sum and it can reorder the data.

The items to read are specified, as with the range function, using a vector of strings. Table~1.6 shows the allowable items. Unrecognized items will result in a warning being sent to the logger. Duplicate items are silently ignored.

The record that is returned contains fields that correspond to each of the specified items. Most fields will contain an array. The array may be one, two or three dimensional depending on whether the corresponding row in the measurement set is a scalar, one or two dimensional. Unless the ifraxis argument is set to T the length of the last axis on these arrays will correspond to the number of rows in the selected measurement set.

If the ifraxis argument is set to True, the row axis is split into an interferometer axis and a time axis. For example a measurement set with 90 rows, in an array with 6 telescopes (so that there are 15 interferometers), may have a data array of shape [4,32,90] if ifraxis is False or [4,32,15,6], if ifraxis is True (assuming there are 4 correlations and 32 channels). If there are missing rows as will happen if not all interferometers where used for all time-slots then a default value will be inserted.

This splitting of the row axis may not happen for items where there is only a single value per row. For some items the returned vector will contain only as many values as there are interferometers and it is implicit that the same value should be used for all time slots. The antenna1, antenna2, feed1, feed2 & ifr_number items fall in this category. For other items the returned vector will have as many values as there are time slots and it is implicit that the same value should be used for all interefometers. The field_id, scan_number, data_desc_id & time items fall into this category.

The axis_info item provides data labelling information. It returns a record with the following fields: corr_axis, freq_axis, ifr_axis & time_axis. The latter two fields are not present if ifr_axis is set to False. The corr_axis field contains a string vector with elements like ’RR’ or ’XY’ that indicates which polarizations where correlated together to produce the data. The length of this vector will always be the same as the length of the first axis of the data array. The freq_axis field contains a record with two fields, chan_freq & resolution. Each of these fields contains vectors which indicate the centre frequency and spectral resolution (FWHM) of each channel. The length of these vectors will be the same as the length of the second axis in the data. The ifr_axis field contains fields: ifr_number, ifr_name, ifr_shortname & baseline. The ifr_number is the same as returned by the ifr_item, the ifr_name & ifr_shortname are string vecors containing descriptions of the interferometer and the baseline is the Euclidian distance, in meters between the two antennas. All of these vectors have a length equal to the number of interferometers in the selected measurement set ie., to the length of the third axis in the data when ifraxis is True. The time_axis field contains the MJD seconds field and optionally the HA, UT & LAST fields. To include the optional fields you need to add the ha, last or ut strings to the list of requested items. All the fields in the time_axis record contain vectors that indicate the time at the midpoint of the observation and are in seconds. The MJD seconds field is since 0 hours on the day having a modified julian day number of zero and the rest are since midnight prior to the start of the observation.

An optional gap size can be specified to visually separate groups of interferometers with the same antenna1 index (handy for identifying antennas in an interferometer vs time display). The default is no gap.

An optional increment can be specified to return data from every row matching the increment only.

When the average flag is set, the data will be averaged over the time axis if the ifraxis is True or the row axis i.e., different interferometers and times may be averaged together. In the latter case, some of the coordinate information, like antenna_id, will no longer make sense.

You need to call selectinit before calling this function. If you haven’t then selectinit will be called for you with default arguments.

Items prefixed with either; corrected, model, residual or obs_residual and the imaging_weight item are not available unless your measurement set has been processed either with the imager or calibrator tools.

Arguments





Inputs

items

Item names

allowed:

stringArray

Default:

ifraxis

Create interferometer axis if True

allowed:

bool

Default:

false

ifraxisgap

Gap size on ifr axis when antenna1 changes

allowed:

int

Default:

0

increment

Row increment for data access

allowed:

int

Default:

1

average

Average the data in time or over rows

allowed:

bool

Default:

false

Returns
record

Example

 
 
ms.open("3C273XC1.MS")  
ms.selectinit(datadescid=0)  
# The following line causes an EXCEPTION  
# d = ms.getdata(["amplitude","axis_info","ha"],ifraxis=True)  
# so we settle for MJDseconds rather than HA in seconds  
d = ms.getdata(["amplitude","axis_info"],ifraxis=True)  
tstart = min(d["axis_info"]["time_axis"]["MJDseconds"])  
tstop  = max(d["axis_info"]["time_axis"]["MJDseconds"])  
maxamp = max(max(d["amplitude"][:,0,0,0]),max(d["amplitude"][0,:,0,0]),  
    max(d["amplitude"][0,0,:,0]),max(d["amplitude"][0,0,0,:]))  
print "MJD start time (seconds) =", tstart  
# MJD start time (seconds) = 4121629400.0  
print "MJD stop time (seconds) =", tstop  
# MJD stop time (seconds) = 4121642670.0  
# MJDseconds Correlation amplitude  
print "Maximum correlation amplitude =", maxamp  
# Maximum correlation amplitude = 33.5794372559  
chan = 0  
corr = 0  
freqGHz = d["axis_info"]["freq_axis"]["chan_freq"][chan]/1.0E9  
baselineStr = d["axis_info"]["ifr_axis"]["ifr_name"][corr]  
corrStr = d["axis_info"]["corr_axis"][corr]  
tcoord = d["axis_info"]["time_axis"]["MJDseconds"]  
acoord = d["amplitude"][0,0,0,:]  
print "Frequency", freqGHz, "GHz", "Baseline", baselineStr, "(", corrStr, ")"  
print "MJDseconds", "Correlation amplitude"  
for i in range(len(tcoord)):  
    print tcoord[i], acoord[i]  
#  
# Frequency [ 8.085] GHz Baseline 1-2 ( RR )  
# MJDseconds Correlation amplitude  
# 4121629400.0 29.2170944214  
# 4121629410.0 29.1688995361  
# 4121629420.0 29.2497825623  
# 4121629430.0 29.2029647827  
# 4121629440.0 29.166015625  
# 4121629450.0 29.2417526245  
# 4121629460.0 29.2867794037  
# 4121638270.0 0.0  
# 4121638280.0 29.4539775848  
# 4121638290.0 29.472661972  
# 4121638300.0 29.4424362183  
# 4121638310.0 29.4234466553  
# 4121638320.0 29.4018745422  
# 4121638330.0 29.3326053619  
# 4121638340.0 29.3575496674  
# 4121642600.0 31.1411132812  
# 4121642610.0 31.0726108551  
# 4121642620.0 31.1242599487  
# 4121642630.0 31.0505466461  
# 4121642640.0 31.0448284149  
# 4121642650.0 30.9974422455  
# 4121642660.0 31.0648326874  
# 4121642670.0 31.0638961792  
 
 
    This example selects all the data from the  
    measurement set where the value in the DATA_DESC_ID column is  
    zero. This corresponds to a particular spectral window and  
    polarization setup. It then gets the correlated amplitude, and the  
    axis information from this selected measurement set. This is  
    returned in the casapy variable d. The remainder of the example  
    prints a table of ’hour angle’ and corresponding ’correlated  
    amplitude’ for the first channel, correlation and baseline.  

__________________________________________________________________


More information about CASA may be found at the CASA web page

Copyright 2016 Associated Universities Inc., Washington, D.C.

This code is available under the terms of the GNU General Public Lincense


Home | Contact Us | Directories | Site Map | Help | Privacy Policy | Search