msmetadata

class msmetadata[source]

Operations to retrieve metadata from a measurment set

The msmd tool provides methods to retrieve metadata from measurement sets.

Attaching to a Measurement Set

The simplest and most common way to attach an msmd tool to a measurement set is to use the msmd.open method which requires that you specify the name of the measurement set table.

NOTE: Any modifications to an MS while an associated msmd tool is open will not be reflected in the msmd tool. You must close and reopen the tool if you want to capture changes made to metadata of an MS if such a change occurs.

Methods Summary

almaspws

Get spectral window IDs based on ALMA-specific criteria. The inputs are or’ed together

antennadiameter

Get the diameter for the specified antenna.

antennaids

Get the zero-based antenna IDs for the specfied antenna names and the specified diameter range for the specified observation ID.

antennanames

Get the name of the antenna for the specfied zero-based antenna ID.

antennaoffset

Get the offset position of the specified antenna relative to the array reference position.

antennaposition

Get the position of the specified antenna.

antennasforscan

Get an array of the unique antennaIDs for the specified scan, observation ID, and array ID.

antennastations

Get the station names of the specified antennas.

bandwidths

Get the bandwidths in Hz for the specified spectral windows.

baseband

Get the baseband for the specified spectral window.

baselines

Get a two dimensional boolean array representing baselines for data recorded in the MS.

chanavgspws

Get an array of spectral window IDs used for channel averages.

chaneffbws

Get an array of channel effective bandwidths for the specified spectral window.

chanfreqs

Get an array of channel frequencies for the specified spectral window.

chanres

Get an array of channel resolutions for the specified spectral window.

chanwidths

Get an array of channel widths for the specified spectral window.

close

This method will close the tool and reclaim system resources it has been using.

corrbit

Get the value of SPECTRAL_WINDOW::SDM_CORR_BIT column for the specified spw.

corrprodsforpol

Get the correlation products associated with the specified polarization ID.

corrtypesforpol

Get the correlation types associated with the specified polarization ID.

datadescids

Get a list of data description IDs associated with the specified spectral window ID and/or polarization ID.

done

This method will close the tool and reclaim system resources it has been using.

effexposuretime

Get the effective exposure time (equivalent to what might be more commonly known as total integration time or total sample time) is calculated by summing over all rows in the main MS table, excluding autocorrelations or rows where FLAG_ROW is False, thusly:

exposuretime

Get the exposure time for the specified scan, spwid, polarization ID, array ID, and observation ID.

fdmspws

Get an array of spectral window IDs used for FDM.

fieldnames

Get an array of field names as they appear in the FIELD table.

fieldsforintent

Get an array of the unique fields for the specified intent.

fieldsforname

Get an array of the unique, zero-based field IDs for the specified field name.

fieldsforscan

Get an array of the unique fields for the specified scan number, observation ID, and array ID.

fieldsforscans

Get an array or dictionary of the unique fields for the specified scan numbers, observation ID, and array ID.

fieldsforsource

Get an array of the unique fields for the specified source.

fieldsforsources

Get a map of source IDs to fields.

fieldsforspw

Get an array of the unique fields for the specified spectral window.

fieldsfortimes

Get an array of the unique, zero-based, fieldIDs for the specified time range (time-tol to time+tol).

intents

Get an array of the unique intents associated with the MS.

intentsforfield

Get an array of the unique intents for the specified field.

intentsforscan

Get an array of the unique intents for the specified scan, observation ID, and array ID.

intentsforspw

Get an array of the unique intents for the specified spectral window ID.

meanfreq

Get the mean frequency for the specified spectral window.

msmetadata

msmetadata method

name

Get the name of the attached MS.

namesforfields

Get the name of the specified field.

namesforspws

Get the name of the specified spw(s).

nantennas

Get the number of antennas associated with the MS.

narrays

Get the number of arrays associated with the MS from the ARRAY table.

nbaselines

Get the number of unique baselines (antenna pairs) represented in the main MS table.

nchan

Get the number of channels associated with the specified spectral window.

ncorrforpol

Get the number of correlations for the specified polarization ID.

nfields

Get the number of fields associated with the MS.

nobservations

Get the number of observations associated with the MS from the OBSERVATIONS table.

nrows

Get the number of visibilities (from the main table) associated with the MS.

nscans

Get the number of scans associated with the MS.

nsources

Get the number of unique values from the SOURCE_ID column in the SOURCE table.

nspw

This method will return the number of spectral windows in the associated MS.

nstates

This method will return the number of states (number of rows in the STATES table) in the associated MS.

observatorynames

Get an array of MS telescope (observatory) names as they are listed in the OBSERVATIONS table.

observatoryposition

Get the position of the specified telescope.

observers

Get an array of observers as they are listed in the OBSERVATIONS table.

open

Attach this tool to the specified MS.

phasecenter

Get a direction measures for the phasecenter of the field id and time specified

pointingdirection

Get the pointing direction for antennas at the specified row number in the main MS table.

polidfordatadesc

Get the polarization ID associated with the specified data description ID.

projects

Get an array of projects as they are listed in the OBSERVATIONS table.

propermotions

Get the values of the DIRECTION column from the SOURCE table.

refdir

Get a direction measure for the reference direction of the field and time specified

reffreq

Get the reference frequency of the specified spectral window.

restfreqs

Get the rest frequencies from the SOURCE table for the specified source and spectral window.

scannumbers

This method will return an array of unique scan numbers in the associated MS for the specified observation ID and array ID.

scansforfield

Get an array of the unique scan numbers associated with the specified field, observation ID, and array ID.

scansforfields

Get a dictionary of which maps field ID to scan numbers for the specified observation ID and array ID.

scansforintent

Get an array of the unique scan numbers associated with the specified intent, observation ID, and arrayID.

scansforspw

Get an array of the unique scan numbers associated with the specified zero-based spectral window ID, observation ID, and array ID.

scansforspws

Get a dictionary of which maps spw ID to scan numbers for the specified observation ID and array ID.

scansforstate

Get an array of the unique scan numbers for the specified state, observation ID, and array ID.

scansfortimes

Get an array of the unique scan numbers for the specified time range (time-tol to time+tol), observation ID, and array ID.

schedule

Get the schedule information for the specified observation ID.

sideband

Get the sideband for the specified spectral window.

sourcedirs

Get the values of the DIRECTION column from the SOURCE table.

sourceidforfield

Get the source ID from the field table for the specified field ID.

sourceidsfromsourcetable

Get the values of the SOURCE_ID column from the SOURCE table.

sourcenames

Get the values of the SOURCE_NAME column from the SOURCE table.

sourcetimes

Get the values of the TIME column from the SOURCE table.

spwfordatadesc

Get the spectral window ID associated with the specified data description ID.

spwsforbaseband

Get the spectral windows associated with the specified baseband or dictionary that maps baseband to spectral windows.

spwsforfield

Get an array of the unique spectral window IDs for the specified field.

spwsforfields

Get a dictionary which maps field IDs to spectral window IDs.

spwsforintent

Get an array of the unique spectral window IDs for the specified intent.

spwsfornames

Get the IDs of the specified spw(s).

spwsforscan

Get an array of the unique spectral window IDs for the specified scan number, observation ID, and array ID.

spwsforscans

Get a dictionary of which maps scan number to spectral windows for the specified observation ID and array ID.

statesforscan

Get an array of the unique state IDs for the specified scan number, observation ID, and array ID.

statesforscans

Get a dictionary which maps scan numbers to state IDs for the specified array and observation IDs.

summary

Get dictionary summarizing the MS.

tdmspws

Get an array of spectral window IDs used for TDM.

timerangeforobs

Get the time range for the specified observation ID.

timesforfield

Get an array of the unique times for the specified field.

timesforintent

Get an array of the unique times for the specified intent.

timesforscan

Get the unique times for the specified scan number, observation ID, and array ID.

timesforscans

Get an array of the unique times for the specified scan numbers, observation ID, and array ID.

timesforspws

Get the unique times corresponding to the specified spectral window(s).

transitions

Get the spectral transitions from the SOURCE table for the specified source and spectral window.

wvrspws

Get an array of spectral window IDs used for WVR.

almaspws(chavg=False, fdm=False, sqld=False, tdm=False, wvr=False, complement=False)[source]

Get spectral window IDs based on ALMA-specific criteria. The inputs are or’ed together to form the returned list. If complement=True, then the complement of the selection is returned.

If the SPECTRAL_WINDOW table has the optional BBC_NO column and if the name of the spectral window matches the regular expression “BB_[0-9]#SQLD”, where [0-9] indicates that a single integer matches, the window is classified as a square law detector spectral window.

The following algorithm is used to identify WVR spwectral windows:

  1. check for water vapor radiometer (WVR) spectral windows using the spectral window name “WVR#NOMINAL” and report these.

  2. If no SPWs match that string, then the names are checked for “WVR” and are reported instead.

If the window is not found to be a WVR window, it is then checked if

The window is classified as a channel average spectral window if it is not a WVR window, if the number of channels is one, and the spectral window name does not contain the string “FULL_RES”

The window is classified as an FDM window if it is neither a WVR window nor a channel average window and if either

  1. its bandwidth is less than 2 GHz, or

  2. the number of channels it contains is greater than or equal to 15 but not equal to 256, 128, 64, 32, 16, 248, 124, 62, or 31.

The window is classified as a TDM spectral window if it is neither a WVR window, a channel average window, nor an FDM window.

Parameters

  • chavg (bool=False) - Get channel average spectral windows?

  • fdm (bool=False) - Get FDM spectral windows?

  • sqld (bool=False) - Get square law (i.e. total power) detector spectral windows?

  • tdm (bool=False) - Get TDM spectral windows?

  • wvr (bool=False) - Get WVR spectral windows?

  • complement (bool=False) - Return the complement of the selected set?

Returns

intVec

Examples

msmd.open("my.ms")
# get all square law detector spectral window IDs
msmd.almaspws(sqld=True)
# get all spectral window IDs other than those associated with square law detectors
msmd.almaspws(sqld=True, complement=True)
antennadiameter(antenna='-1')[source]

Get the diameter for the specified antenna. The antenna can be specified either by its zero-based ID from the ANTENNA table or by its name in that table. The returned dictionary is a valid quantity. If a negative integer is provided for the antenna, then all atenna diameters will be returned in a dictionary that has keys that are the antenna IDs and values that are dictionaries, each being a valid quantity representing the diameter for that antenna ID.

Parameters

  • antenna ({string, int}='-1') - Zero-based antenna in the ANTENNA table, or antenna name. A negative integer will cause all antenna diameters to be returned.

Returns

record

Examples

msmd.open("my.ms")
# Get the diameter of the antenna named "VB2"
diameter = msmd.antennadiameter("VB2")
msmd.done()
antennaids(name='', mindiameter='0m', maxdiameter='1pc', obsid=- 1)[source]

Get the zero-based antenna IDs for the specfied antenna names and the specified diameter range for the specified observation ID. An array of unique IDs in order of the specified names is returned. Note that if a specified name is listed mulitple times in the ANTENNA table, the largest ID is returned, unless the observation ID is specified to be non-negative, in which case, the returned IDs are filtered based on the specified observation ID. If no names and no diameter range is specified, all IDs are returned.

Parameters

  • name ({string, stringVec}='') - Antenna names (string or string array) for which to get the corresponding IDs. Note that * matches any number of characters of all character classes.

  • mindiameter (variant='0m') - Minimum antenna diameter, expressed as a quantity.

  • maxdiameter (variant='1pc') - Maximum antenna diameter, expressed as a quantity.

  • obsid (int=-1) - Observation ID. If negative, all observation IDs are considered.

Returns

intVec

Examples

msmd.open("my.ms")
# get the zero-based antenna IDs for the antenna named "VB2"
antenna_id = msmd.antennaids("VB2")[0]
# get the zero-based antenna IDs for all antennas with diameters between 9m and 11m
antenna_ids = msmd.antennaids(mindiameter="9m", maxdiameter=qa.quantity("11m"))
msmd.done()
antennanames(antennaids=- 1)[source]

Get the name of the antenna for the specfied zero-based antenna ID. If antennaids is not specified, all antenna names are returned.

Parameters

  • antennaids ({int, intVec}=-1) - Zero-based antenna IDs (int or int array) for which to get the antenna names.

Returns

stringVec

Examples

msmd.open("my.ms")
# get the name associated with antenna ID 31
antenna_name = msmd.antennanames(31)[0]
msmd.done()
antennaoffset(which='0')[source]

Get the offset position of the specified antenna relative to the array reference position. Antenna may be specified as a zero-based integer (row number in the ANTENNA table) or a string representing a valid antenna name. The returned record contains the longitude, latitude, and elevation offsets as quantity records. The reported longitude and latitude offsets are measured along the surface of a sphere whose center is coincident with the center of the earth and whose surface contains the observatory reference position.

Parameters

  • which ({string, int}='0') - Zero-based antenna in the ANTENNA table, or antenna name.

Returns

record

Examples

msmd.open("my.ms")
# get the offset of the (zero-based) 3rd antenna in the ANTENNA table
antennna_offset = msmd.antennaoffset(3)
# get the offset of antenna DV02
antennna_offset = msmd.antennaoffset('DV02')
msmd.done()
antennaposition(which='0')[source]

Get the position of the specified antenna. The returned record represents a position measure, and can be used as such by the measures (me) tool.

Parameters

  • which ({int, string}='0') - Zero-based antenna ID in the ANTENNA table or antenna name.

Returns

record

Examples

msmd.open("my.ms")
# get the position of the (zero-based) 3rd antenna in the ANTENNA table
antennna_position = msmd.antennaposition(3)
# get the position of the antenna named DV07
antennna_position = msmd.antennaposition("DV07")
msmd.done()
antennasforscan(scan=- 1, obsid=- 1, arrayid=- 1)[source]

Get an array of the unique antennaIDs for the specified scan, observation ID, and array ID.

Parameters

  • scan (int=-1) - Scan number for which to return the intents.

  • obsid (int=-1) - Observation ID. If less than 0, all observation IDs are used.

  • arrayid (int=-1) - Array ID. If less than 0, all array IDs are used.

Returns

intVec

Examples

msmd.open("my.ms")
# get the antennas associated with scan 4 (all observation IDs, all array IDs)
antennas = msmd.antennasforscan(4)
msmd.done()
antennastations(which='-1', obsid=- 1)[source]

Get the station names of the specified antennas. If a specified antenna name is listed multiple times in the ANTENNA table, obsid is negative, and which is specified as an array of names, then the station associated with the largest ID for that antenna is returned. If obsid is nonnegative, returned stations are filtered based on that. If which is specified as a string (antenna name), then all the stations associated with that antenna are returned.

Parameters

  • which ({int, string, intVec, stringVec}='-1') - Zero-based antenna ID(s) in the ANTENNA table or antenna name(s). Single numeric id less than zero retrieves all station names.

  • obsid (int=-1) - Observation ID. If negative, all observation IDs are considered.

Returns

stringVec

Examples

msmd.open("my.ms")
# get all station names
stations = msmd.antennastations(-1)
# get the stations of the antennas named DV07 and DV01
stations = msmd.antennaposition(["DV07", "DV01"])
msmd.done()
bandwidths(spw=- 1)[source]

Get the bandwidths in Hz for the specified spectral windows. If spw less than zero, return bandwidths for all spectral windows.

Parameters

  • spw ({int, intVec}=-1) - Spectral window IDs, if integer less than zero, return bandwidths for all spectral windows.

Returns

any

Examples

msmd.open("my.ms")
# get bandwdith for spectral window 2.
baseband = msmd.bandwidth(2)
msmd.done()
baseband(spw='')[source]

Get the baseband for the specified spectral window.

Parameters

  • spw (int='') - Spectral window ID.

Returns

int

Examples

msmd.open("my.ms")
# get baseband for spectral window 2.
baseband = msmd.baseband(2)
msmd.done()
baselines()[source]

Get a two dimensional boolean array representing baselines for data recorded in the MS. A value of True means there is at least one row in the MS main table for that baseline, False means no rows for that baseline. Autocorrelation “baseline” information is also present via the values along the diagonal.

chanavgspws()[source]

Get an array of spectral window IDs used for channel averages. These are windows that do have 1 channel.

chaneffbws(spw='', unit='', asvel=False)[source]

Get an array of channel effective bandwidths for the specified spectral window. The parameter asvel indicates if velocity widths (True) or frequency widths (False) should be returned. The unit parameter specifies the units that the returned values should have. If empty (default), “Hz” will be used if asvel=False, or “km/s” will be used if asvel=True.

Parameters

  • spw (int='') - Spectral window ID.

  • unit (string='') - Desired unit of returned quantities. Empty means “Hz” if asvel=False, “km/s” if asvel=True.

  • asvel (bool=False) - Should return values be equivalent velocity widths?

Returns

doubleVec

Examples

msmd.open("my.ms")
# get the channel effective bandwidths for spectral window 2, in m/s
chan_ebw = msmd.chaneffbws(2, "m/s", True)
msmd.done()
chanfreqs(spw='', unit='Hz')[source]

Get an array of channel frequencies for the specified spectral window.

Parameters

  • spw (int='') - Spectral window ID.

  • unit (string='Hz') - Convert frequencies to this unit.

Returns

doubleVec

Examples

msmd.open("my.ms")
# get the channel frequencies for spectral window 2.
chan_freqs = msmd.chanfreqs(2)
msmd.done()
chanres(spw='', unit='', asvel=False)[source]

Get an array of channel resolutions for the specified spectral window. The parameter asvel indicates if velocity widths (True) or frequency widths (False) should be returned. The unit parameter specifies the units that the returned values should have. If empty (default), “Hz” will be used if asvel=False, or “km/s” will be used if asvel=True.

Parameters

  • spw (int='') - Spectral window ID.

  • unit (string='') - Desired unit of returned quantities. Empty means “Hz” if asvel=False, “km/s” if asvel=True.

  • asvel (bool=False) - Should return values be equivalent velocity resolutions?

Returns

doubleVec

Examples

msmd.open("my.ms")
# get the channel resolutions for spectral window 2, in m/s
chan_res = msmd.chanres(2, "m/s", True)
msmd.done()
chanwidths(spw='', unit='Hz')[source]

Get an array of channel widths for the specified spectral window.

Parameters

  • spw (int='') - Spectral window ID.

  • unit (string='Hz') - Convert frequencies to this unit.

Returns

doubleVec

Examples

msmd.open("my.ms")
# get the channel widths for spectral window 2.
chan_freqs = msmd.chanwidths(2)
msmd.done()
close()[source]

This method will close the tool and reclaim system resources it has been using. Returns True if successful.

corrbit(spw='-1')[source]

Get the value of SPECTRAL_WINDOW::SDM_CORR_BIT column for the specified spw. If spw >= 0 is specified, a string value is returned. If spw <0, a list of string values with length equal to the number of spectral windows is returned. If the SPECTRAL_WINDOW::SDM_CORR_BIT column does not exist, either “UNKNOWN” is returned if spw>=0, or a list with nspw entries of “UNKNOWN” is returned if spw<0. A list of integers may also be supplied for the spw parameter. In this case, all integers should be in the range [0, spw-1] or an exception will be thrown. The return value will be a list containing the corresponding CORR_BIT values in the order of the spws specified.

Parameters

  • spw (variant='-1') - Spectral window ID(s). May be an integer or list of integers. If integer, <0 implies all.

Returns

any

Examples

msmd.open("my.ms")
# get value of SPECTRAL_WINDOW::SDM_CORR_BIT column for spw=2.
cb = msmd.corrbit(spw=2)
msmd.done()
corrprodsforpol(pol=- 1)[source]

Get the correlation products associated with the specified polarization ID.

Parameters

  • pol (int=-1) - Polarization ID. Must be nonnegative.

Returns

any

Examples

msmd.open("my.ms")
# get correlation products for polarization ID 3
corrprods = msmd.corrprodsforpol(3)
msmd.done()
corrtypesforpol(pol=- 1)[source]

Get the correlation types associated with the specified polarization ID.

Parameters

  • pol (int=-1) - Polarization ID. Must be nonnegative.

Returns

intVec

Examples

msmd.open("my.ms")
# get correlation types for polarization ID 3
corrtypes = msmd.corrtypesforpol(3)
msmd.done()
datadescids(spw=- 1, pol=- 1)[source]

Get a list of data description IDs associated with the specified spectral window ID and/or polarization ID. Values of less than zero for either means all IDs should be used in the selection.

Parameters

  • spw (int=-1) - Spectral window ID. Less than zero implies any,

  • pol (int=-1) - Polarization ID. Less than zero implies any.

Returns

intVec

Examples

msmd.open("my.ms")
# get all data description IDs associated with spw 2.
msmd.datadescids(spw=2)
# same as before but limit the IDs returned to those associated with
# polarization ID 3
msmd.datadescids(spw=2, pol=3)
msmd.done()
done()[source]

This method will close the tool and reclaim system resources it has been using. Returns True if successful.

effexposuretime()[source]

Get the effective exposure time (equivalent to what might be more commonly known as total integration time or total sample time) is calculated by summing over all rows in the main MS table, excluding autocorrelations or rows where FLAG_ROW is False, thusly:

sum[over i] (exposure[i]*sum[over j](UFBW[i, j])/ncorrelations[i] )/ nmaxbaselines

where exposure[i] is the value of EXPOSURE for the ith row, the inner sum is performed over each correlation for that row, UFBW is the unflagged fractional bandwidth is determined by summing all the widths of the unflagged channels for that correlation and dividing by the total bandwidth of all spectral windows observed at the timestamp of row i, ncorrelations is the number of correlations determined by the number of rows in the FLAG matrix for MS row i, and nmaxbaselines is the maximum number of antenna pairs, nantennas*(nantennas-1)/2, where nantennas is the number of antennas in the ANTENNA table. This method returns a quantity (a dictionary having a numerical value and a string unit).

exposuretime(scan=0, spwid=0, polid=- 1, obsid=0, arrayid=0)[source]

Get the exposure time for the specified scan, spwid, polarization ID, array ID, and observation ID. This is the exposure time of the record with the lowest time stamp of the records associated with these parameters. Returns a quantity dictionary. If polid is not specified (or specified and negative) and there is only one polarization ID in for the specified combination of scan, spwid, obsID, and arrayID, then that polarization ID is used. If there are multiple polarization IDs for the combination of other parameters, a list of these is logged and an empty dictionary is returned.

Parameters

  • scan (int=0) - Scan number.

  • spwid (int=0) - Spectral window ID.

  • polid (int=-1) - Polarization ID.

  • obsid (int=0) - Observation ID.

  • arrayid (int=0) - Array ID.

Returns

record

Examples

msmd.open("my.ms")
# get the exposure time for scan 1, spwid 2, and polid 3
# for obsid=0 and arrayid=0
integration_time = msmd.exposuretime(scan=1, spwid=2, polid=3)
msmd.done()
fdmspws()[source]

Get an array of spectral window IDs used for FDM. These are windows that do not have 64, 128, or 256 channels.

fieldnames()[source]

Get an array of field names as they appear in the FIELD table.

fieldsforintent(intent='', asnames=False)[source]

Get an array of the unique fields for the specified intent. Note that * matches any number of characters of all character classes.

Parameters

  • intent (string='') - Intent (case sensitive) for which to return the fields.

  • asnames (bool=False) - If True, return the field names. If False, return the zero-based field IDs.

Returns

any

Examples

msmd.open("my.ms")
# get the field names for intent "observe target"
field_names = msmd.fieldsforintent("observe target", True, regex=False)
# get the field IDs for intent "observe target"
field_IDs = msmd.fieldsforintent("observe target", False, regex=False)
# get all field IDs for all intents which contain 'WVR'
field_IDs = msmd.fieldsforIntent("*WVR*")
msmd.done()
fieldsforname(name='')[source]

Get an array of the unique, zero-based field IDs for the specified field name. If the field name is the empty string (the default), a list of all unique field IDs in the main table of the MS will be returned.

Parameters

  • name (string='') - Field name (case sensitive) for which to return the fields.

Returns

intVec

Examples

msmd.open("my.ms")
# get the field IDs for field name "Enceladus"
fields = msmd.fieldsforname("Enceladus")
msmd.done()
fieldsforscan(scan=- 1, asnames=False, obsid=- 1, arrayid=- 1)[source]

Get an array of the unique fields for the specified scan number, observation ID, and array ID.

Parameters

  • scan (int=-1) - Scan number for which to return the fields.

  • asnames (bool=False) - If True, return the field names. If False, return the zero-based field IDs.

  • obsid (int=-1) - Observation ID. A negative value means use all observation IDs.

  • arrayid (int=-1) - Array ID. A negative value means use all array IDs.

Returns

any

Examples

msmd.open("my.ms")
# get the field names for scan number 5 (for all array IDs and all observation IDs).
field_names = msmd.fieldsforscan(5, True)
# get the field IDs for scan number 5 (for all array IDs and all observation IDs)
field_IDs = msmd.fieldsforscan(5, False)
msmd.done()
fieldsforscans(scans='', asnames=False, obsid=- 1, arrayid=- 1, asmap=False)[source]

Get an array or dictionary of the unique fields for the specified scan numbers, observation ID, and array ID. If asnames=True, the values returned will be the field names, if False, they will be field IDs. If asmap=True, the structure returned will be a dictionary which maps scan number (as a string) to fields. In this case, both obsid and arrayid must be nonnegative. If asmap=False, a single array of fields is returned that matches the query. In this case, if obsid and/or arrayid are negative, then it indicates that all fields matching any obsid and/or arrayid should be returned. An empty array specified for scans means that all scans for the selected obsid and arrayid should be included.

Parameters

  • scans (intVec='') - Scan numbers for which to return the fields.

  • asnames (bool=False) - If True, return the field names. If False, return the zero-based field IDs.

  • obsid (int=-1) - Observation ID. A negative value means use all observation IDs.

  • arrayid (int=-1) - Array ID. A negative value means use all array IDs.

  • asmap (bool=False) - Return a dictionary mapping scan numbers to fields?

Returns

any

Examples

msmd.open("my.ms")
# get the field names for scan numbers 5 and 10 (all obsids, all arrayids)
field_names = msmd.fieldsforscan([5, 10], True)
# get the field IDs for scan numbers 5 and 10 (all obsids, all arrayids)
field_IDs = msmd.fieldsforscan([5, 10], False)
# get mapping of scans to fields for arrayid=2 and obsid=4
scans_to_fields = msmd.fieldsforscan(obsid=4, arrayid=2, asmap=True)
msmd.done()
fieldsforsource(source=- 1, asnames=False)[source]

Get an array of the unique fields for the specified source.

Parameters

  • source (int=-1) - Zero-based source ID for which to return the fields.

  • asnames (bool=False) - If True, return the field names. If False, return the zero-based field IDs.

Returns

any

Examples

msmd.open("my.ms")
# get the field names for source ID 1
field_names = msmd.fieldsforsource(1, True)
# get the field IDs for source ID 1
field_IDs = msmd.fieldsforsource(1, False)
msmd.done()
fieldsforsources(asnames=False)[source]

Get a map of source IDs to fields. The keys (source IDs) will be strings.

Parameters

  • asnames (bool=False) - If True, return the field names. If False, return the zero-based field IDs.

Returns

record

Examples

msmd.open("my.ms")
# get the source to field name map
sources_to_fields = msmd.fieldsforsources(True)
# access the field names for source 1
field = sources_to_fields["1"]
msmd.done()
fieldsforspw(spw=- 1, asnames=False)[source]

Get an array of the unique fields for the specified spectral window.

Parameters

  • spw (int=-1) - Zero-based spectral window ID for which to return the fields.

  • asnames (bool=False) - If True, return the field names. If False, return the zero-based field IDs.

Returns

any

Examples

msmd.open("my.ms")
# get the field names for spectral window 1
field_names = msmd.fieldsforspw(1, True)
# get the field IDs for spectral window 1
field_IDs = msmd.fieldsforspw(1, False)
msmd.done()
fieldsfortimes(time=- 1, tol=0)[source]

Get an array of the unique, zero-based, fieldIDs for the specified time range (time-tol to time+tol).

Parameters

  • time (double=-1) - Time at center of time range.

  • tol (double=0) - Time on either side of center for specifying range.

Returns

intVec

Examples

msmd.open("my.ms")
# get the field IDs associated with the specified time range
fields = msmd.fieldsfortimes(4.8428293714e+09, 20)
msmd.done()
intents()[source]

Get an array of the unique intents associated with the MS.

intentsforfield(field='-1')[source]

Get an array of the unique intents for the specified field.

Parameters

  • field ({int, string}='-1') - Field ID or name for which to return the intents.

Returns

stringVec

Examples

msmd.open("my.ms")
# get the intents associated with field 4
intents = msmd.intentsforfield(4)
# get intents for field "MOS"
intents2 = msmd.intentsforfield("MOS")
msmd.done()
intentsforscan(scan=- 1, obsid=- 1, arrayid=- 1)[source]

Get an array of the unique intents for the specified scan, observation ID, and array ID.

Parameters

  • scan (int=-1) - Scan number for which to return the intents.

  • obsid (int=-1) - Observation ID. A negative value means use all observation IDs.

  • arrayid (int=-1) - Array ID. A negative value means use all array IDs.

Returns

stringVec

Examples

msmd.open("my.ms")
# get the intents associated with scan 4 (all obsids, all arrayids)
intents = msmd.intentsforscan(4)
msmd.done()
intentsforspw(spw=- 1)[source]

Get an array of the unique intents for the specified spectral window ID.

Parameters

  • spw (int=-1) - Spectral window ID (>=0) for which to return the intents.

Returns

stringVec

Examples

msmd.open("my.ms")
# get the intents associated with spectral window ID 3
intents = msmd.intentsforspw(3)
msmd.done()
meanfreq(spw='', unit='Hz')[source]

Get the mean frequency for the specified spectral window.

Parameters

  • spw (int='') - Spectral window ID.

  • unit (string='Hz') - Convert frequencies to this unit.

Returns

double

Examples

msmd.open("my.ms")
# get the mean frequency for spectral window 2.
mean_freq = msmd.meanfreq(2)
msmd.done()
msmetadata()[source]

msmetadata method

name()[source]

Get the name of the attached MS.

namesforfields(fieldids='')[source]

Get the name of the specified field.

Parameters

  • fieldids ({string, int, intVec}='') - Zero-based field IDs for which to get the names (integer or interger array). Unspecified will return all field names.

Returns

stringVec

Examples

msmd.open("my.ms")
# get the name for field 8 and 2.
field_names = msmd.namesforfields([8, 2])
# get all field names
all_field_nams = namesforfields()
msmd.done()
namesforspws(spwids='')[source]

Get the name of the specified spw(s).

Parameters

  • spwids ({string, int, intVec}='') - Zero-based spw ID(s) for which to get the names (integer or interger array). Unspecified will return all spw names.

Returns

stringVec

Examples

msmd.open("my.ms")
# get the name for spws 8 and 2.
spw_names = msmd.namesforspws([8, 2])
# get all spw names
all_spw_names = msmd.namesforspws()
msmd.done()
nantennas()[source]

Get the number of antennas associated with the MS.

narrays()[source]

Get the number of arrays associated with the MS from the ARRAY table.

nbaselines(ac=False)[source]

Get the number of unique baselines (antenna pairs) represented in the main MS table. This can, in theory, be less than n*(n-1)/2 (n being the number of antennas in the ANTENNA table), if data for certain baselines are not included in the main MS table. Autocorrelation “baselines” are included in this count if ac=True.

Parameters

  • ac (bool=False) - Include auto-correlation “baselines”?

Returns

int

Examples

msmd.open("my.ms")
number_of_baselines = msmd.nbaselines()
number_of_baselines_including_ac = msmd.nbaselines(True)
msmd.done()
nchan(spw='')[source]

Get the number of channels associated with the specified spectral window.

Parameters

  • spw (int='') - Zero-based spw ID for which to get the number of channels.

Returns

int

Examples

msmd.open("my.ms")
nchan = msmd.nchan(3)
msmd.done()
ncorrforpol(polid=- 1)[source]

Get the number of correlations for the specified polarization ID. If the specified polarization ID is negative, an array of numbers of correlations is returned. The indices of that array represent polarization IDs.

Parameters

  • polid (int=-1) - Zero-based polarization ID. A negative number will cause all the numbers of correlations to be returned.

Returns

variant

Examples

msmd.open("my.ms")
# get the number of correlations associated with polarization ID 4
polid = msmd.ncorrforpol(4)
# get the array of numbers of correlations from the POLARIZATION table
polids = msmd.ncorrforpol(-1)
msmd.done()
nfields()[source]

Get the number of fields associated with the MS.

nobservations()[source]

Get the number of observations associated with the MS from the OBSERVATIONS table.

nrows(autoc=True, flagged=True)[source]

Get the number of visibilities (from the main table) associated with the MS.

Parameters

  • autoc (bool=True) - Include autocorrelation data? If False, only cross correlation rows will be summed.

  • flagged (bool=True) - Include flagged data? If False, only unflagged or patially flagged rows will be summed.

Returns

double

Examples

msmd.open("my.ms")
# get the total number of rows
nrows = msmd.nrows()
# got the number of cross correlation rows
ncross = msmd.nrows(auto=False)
# get the number of unflagged rows
ngood = msmd.nrows(flagged=False)
# get the number of unflagged cross correlation rows
ncrossunflagged = msmd.nrows(auto=False, flagged=False)
msmd.done()
nscans()[source]

Get the number of scans associated with the MS.

nsources()[source]

Get the number of unique values from the SOURCE_ID column in the SOURCE table. The number of rows in the SOURCE table may be greater than this value.

nspw(includewvr=True)[source]

This method will return the number of spectral windows in the associated MS.

Parameters

  • includewvr (bool=True) - Include wvr spectral windows? If False, exclude wvr windows from count.

Returns

int

Examples

msmd.open("my.ms")
number_of_spectral_windows = msmd.nspw()
msmd.done()
nstates()[source]

This method will return the number of states (number of rows in the STATES table) in the associated MS.

observatorynames()[source]

Get an array of MS telescope (observatory) names as they are listed in the OBSERVATIONS table.

observatoryposition(which=0)[source]

Get the position of the specified telescope.

Parameters

  • which (int=0) - Zero-based telescope position in the OBSERVATIONS table (see msmd.telescopenames()).

Returns

record

Examples

msmd.open("my.ms")
# get the position of the 0th telescope
telescope_position = msmd.telescopeposition(0)
msmd.done()
observers()[source]

Get an array of observers as they are listed in the OBSERVATIONS table.

open(msfile='', maxcache=50)[source]

Attach this tool to the specified MS. This method runs a few basic MS validation tests, and if any of these fail (which indicates that the MS is invalid), an error occurs and the tool is not attached to the MS. Note that it is ultimately the user’s responsibility to ensure that the MS is valid. Running the methods of this tool on an invalid MS may result in incorrect results or even a crash of CASA. Such invalidities include any MS subtable not having appropriate information (eg, an OBSERVATION subtable not having enough rows to account for all the OBSERVATION_IDs in the main table).

Parameters

  • msfile (string='') - Name of the existing measurement set

  • maxcache (float=50) - Maximum cache size, in megabytes, to use.

Returns

bool

Examples

msmd.open("my.ms")
# do stuff and close it
msmd.done()
phasecenter(fieldid=0, epoch='')[source]

Get a direction measures for the phasecenter of the field id and time specified

Parameters

  • fieldid (int=0) - Zero-based field ID for which to get the phasecenter; default fieldid=0

  • epoch (record='') - Optional time, expressed as a measures epoch dictionary, if field id has a polynomial in time phasecenter or an ephemerides table attached to the ID. Default value means evaluate at the origin TIME in the FIELD table

Returns

record

Examples

msmd.open("my.ms")
# get phasecenter for field ID 1
mydir = msmd.phasecenter(1);
# if the phasecenter is a polynomial or has an ephemerides attached to 
# it a time is needed to get the phase direction
ep=me.epoch('utc', '2015/03/15/15:30:55')
mydir2=msmd.phasecenter(2, ep)
msmd.done()
pointingdirection(rownum=0, interpolate=False, initialrow=0)[source]

Get the pointing direction for antennas at the specified row number in the main MS table. Returns a record containing the time, antenna IDs and corresponding pointing directions.

Parameters

  • rownum (int=0) - Row number in the main MS table.

  • interpolate (bool=False) - Interpolate pointings in case the interval in the main table is shorter than that in the pointing table (often the case in fast-scanning in single dish observaitions)

  • initialrow (int=0) - Initial guess of row index in pointing table to start search.

Returns

record

Examples

msmd.open("my.ms")
# get the pointing directions for row ID 500
dirs = msmd.pointingdirection(500)
msmd.done()
polidfordatadesc(ddid=- 1)[source]

Get the polarization ID associated with the specified data description ID. If the specified data description ID is negative, an array of polarization IDs is returned. The indices of that array represent data description IDs.

Parameters

  • ddid (int=-1) - Zero-based data description ID. A negative number will cause all the polarization IDs to be returned.

Returns

variant

Examples

msmd.open("my.ms")
# get the polarization ID associated with data description ID 3
polid = msmd.polidfordatadesc(3)
# get the array of polarization IDs in the order they appear in the DATA_DESCRIPTION table
polids = msmd.polidfordatadesc(-1)
msmd.done()
projects()[source]

Get an array of projects as they are listed in the OBSERVATIONS table.

propermotions()[source]

Get the values of the DIRECTION column from the SOURCE table. Returns a dictionary in which the keys are the associated zero-based row numbers, represented as strings, in the SOURCE table. The associated values are two element dictionaries, with keys “longitude” and “latitude”, containing the longitudinal and latidinal components of the proper motion, which are valid quantity dictionaries.

refdir(field='0', epoch='')[source]

Get a direction measure for the reference direction of the field and time specified

Parameters

  • field ({string, int}='0') - Zero-based field ID or field name for which to get the reference direction; default field=0

  • epoch (record='') - Optional time, expressed as a measures epoch dictionary, if associated field has a polynomial in time reference direction or an ephemerides table attached it. Default value means evaluate at the origin TIME in the FIELD table

Returns

record

Examples

msmd.open("my.ms")
# get reference direction for field ID 1 
mydir = msmd.refdir(1);
# if the reference direction is a polynomial or has an ephemerides attached to 
# it a time is needed to get the reference direction
ep=me.epoch('utc', '2015/03/15/15:30:55')
mydir2=msmd.phasecenter(2, ep)
msmd.done()
reffreq(spw=- 1)[source]

Get the reference frequency of the specified spectral window. The returned frequency is in the form of a valid measures dictionary.

Parameters

  • spw (int=-1) - Zero-based spectral window ID.

Returns

record

Examples

msmd.open("my.ms")
# get the reference frequency for spw ID 20
reffreq = msmd.reffreq(20)
msmd.done()
restfreqs(sourceid=0, spw=0)[source]

Get the rest frequencies from the SOURCE table for the specified source and spectral window. The return value will be a dictionary of frequency measures if the rest frequencies are defined for the specified inputs, or False if they do not.

Parameters

  • sourceid (int=0) - Zero-based source ID (from the SOURCE::SOURCE_ID column).

  • spw (int=0) - Zero-based spectral window ID.

Returns

any

Examples

msmd.open("my.ms")
# get the rest frequencies for source ID 2 and spw ID 20
reffreq = msmd.restfreqs(2, 20)
msmd.done()
scannumbers(obsid=- 1, arrayid=- 1)[source]

This method will return an array of unique scan numbers in the associated MS for the specified observation ID and array ID.

Parameters

  • obsid (int=-1) - Observation ID. A negative value indicates all observation IDs should be used.

  • arrayid (int=-1) - Array ID. A negative value indicates all array IDs should be used.

Returns

intVec

Examples

msmd.open("my.ms")
# scan numbers for all obsids and all arrayids
scan_numbers = msmd.scannumbers()
msmd.done()
scansforfield(field='', obsid=- 1, arrayid=- 1)[source]

Get an array of the unique scan numbers associated with the specified field, observation ID, and array ID.

Parameters

  • field ({string, int}='') - Field ID or field name (case sensitive) for which to return the scan numbers.

  • obsid (int=-1) - Observation ID. A negative value indicates all observation IDs should be used.

  • arrayid (int=-1) - Array ID. A negative value indicates all array IDs should be used.

Returns

intVec

Examples

msmd.open("my.ms")
# get the scan numbers associated with field "planet Z" (all obsids, all arrayids)
scan_numbers = msmd.scansforfield("planet Z")
# get the scan numbers associated with field ID 5 (all obsids, all arrayids)
scan_numbers = msmd.scansforfield(5)
msmd.done()
scansforfields(obsid=0, arrayid=0)[source]

Get a dictionary of which maps field ID to scan numbers for the specified observation ID and array ID. The keys (field IDs) will be strings. obsid and arrayid must both be non-negative.

Parameters

  • obsid (int=0) - Observation ID. Must be non-negative.

  • arrayid (int=0) - Array ID. Must be non-negative.

Returns

record

Examples

msmd.open("my.ms")
# get the field - scan map for arrayID 1 and obsID 2
field_to_scans = msmd.scansforfields(arrayid=1, obsid=2)
# access the scans associated with field ID 2
field_to_scans2 = field_to_scans["2"]
msmd.done()
scansforintent(intent='', obsid=- 1, arrayid=- 1)[source]

Get an array of the unique scan numbers associated with the specified intent, observation ID, and arrayID. The “*” character matches any number of characters from all character classes.

Parameters

  • intent (string='') - Intent (case-sensitive) for which to return the scan numbers.

  • obsid (int=-1) - Observation ID. A negative value indicates all observation IDs should be used.

  • arrayid (int=-1) - Array ID. A negative value indicates all array IDs should be used.

Returns

intVec

Examples

msmd.open("my.ms")
# get the scan numbers associated with intent "detect planet X" (all obsids, all arrayids)
scan_numbers = msmd.scansforintent("detect planet X", regex=False)
# got all the scan numbers associated with all intents which contain 'WVR' (all obsids, all arrayids)
scan_numbers = msmd.scansforintent("*WVR*")
msmd.done()
scansforspw(spw=- 1, obsid=- 1, arrayid=- 1)[source]

Get an array of the unique scan numbers associated with the specified zero-based spectral window ID, observation ID, and array ID.

Parameters

  • spw (int=-1) - Zero-based spectral window ID for which to return the scan numbers.

  • obsid (int=-1) - Observation ID. A negative value indicates all observation IDs should be used.

  • arrayid (int=-1) - Array ID. A negative value indicates all array IDs should be used.

Returns

intVec

Examples

msmd.open("my.ms")
# get the scan numbers associated with spectral window ID 14, all obsids, all arrayids
scan_numbers = msmd.scansforspw(14)
msmd.done()
scansforspws(obsid=0, arrayid=0)[source]

Get a dictionary of which maps spw ID to scan numbers for the specified observation ID and array ID. The keys (spectral window IDs) will be strings. obsid and arrayid must both be non-negative.

Parameters

  • obsid (int=0) - Observation ID. Must be non-negative.

  • arrayid (int=0) - Array ID. Must be non-negative.

Returns

record

Examples

msmd.open("my.ms")
# get the spw - scan map for arrayID 1 and obsID 2
spw_to_scans = msmd.scansforspws(arrayid=1, obsid=2)
# access the scans associated with spw ID 2
spw_to_scans2 = spw_to_scans["2"]
msmd.done()
scansforstate(state=- 1, obsid=- 1, arrayid=- 1)[source]

Get an array of the unique scan numbers for the specified state, observation ID, and array ID.

Parameters

  • state (int=-1) - ID of state for which to return the scan numbers.

  • obsid (int=-1) - Observation ID. A negative value indicates all observation IDs should be used.

  • arrayid (int=-1) - Array ID. A negative value indicates all array IDs should be used.

Returns

intVec

Examples

msmd.open("my.ms")
# get the scan numbers associated with state 2, all obsids, all arrayids
scans = msmd.scansforstate(2)
msmd.done()
scansfortimes(time=- 1, tol=0, obsid=- 1, arrayid=- 1)[source]

Get an array of the unique scan numbers for the specified time range (time-tol to time+tol), observation ID, and array ID.

Parameters

  • time (double=-1) - Time at center of time range.

  • tol (double=0) - Time difference on either side of center for specifying range.

  • obsid (int=-1) - Observation ID. A negative value indicates all observation IDs should be used.

  • arrayid (int=-1) - Array ID. A negative value indicates all array IDs should be used.

Returns

intVec

Examples

msmd.open("my.ms")
# get the scan numbers associated with the specified time range (all obsids, all array ids)
scans = msmd.scansfortimes(4.84282937e+09, 20)
msmd.done()
schedule(obsid=- 1)[source]

Get the schedule information for the specified observation ID.

Parameters

  • obsid (int=-1) - Observation ID.

Returns

stringVec

Examples

msmd.open("my.ms")
# get the schdule information for observation ID = 2
schedule = msmd.schedule()[2]
msmd.done()
sideband(spw='')[source]

Get the sideband for the specified spectral window.

Parameters

  • spw (int='') - Spectral window ID.

Returns

int

Examples

msmd.open("my.ms")
# get sideband for spectral window 2.
sideband = msmd.sideband(2)
msmd.done()
sourcedirs()[source]

Get the values of the DIRECTION column from the SOURCE table. Returns a dictionary in which the keys are the associated row numbers, represented as strings, in the SOURCE table. Each value in the returned dictionary is a valid direction measure.

sourceidforfield(field=- 1)[source]

Get the source ID from the field table for the specified field ID.

Parameters

  • field (int=-1) - Zero-based field ID for which to return the source ID from the field table.

Returns

int

Examples

msmd.open("my.ms")
# get source ID associated with field ID 2
sourceid = msmd.sourceidforfield(2)
msmd.done()
sourceidsfromsourcetable()[source]

Get the values of the SOURCE_ID column from the SOURCE table. It is unfortunate that the SOURCE table has a column named SOURCE_ID, because implicitly the “ID” of a row in an MS subtable is generally meant to reflect a row number in that table, but that is not the case for the SOURCE table.

sourcenames()[source]

Get the values of the SOURCE_NAME column from the SOURCE table.

sourcetimes()[source]

Get the values of the TIME column from the SOURCE table. Returns a dictionary in which the keys are the associated row numbers, represented as strings, in the SOURCE table. Each value in the returned dictionary is a valid time quantity.

spwfordatadesc(ddid=- 1)[source]

Get the spectral window ID associated with the specified data description ID. If the specified data description ID is negative, an array of spectral window IDs is returned. The indices of that array represent data description IDs.

Parameters

  • ddid (int=-1) - Zero-based data description ID. A negative number will cause all the spectral window IDs to be returned.

Returns

variant

Examples

msmd.open("my.ms")
# get the spectral window ID associated with data description ID 3
spw = msmd.spwfordatadesc(3)
# get the array of spectral window IDs in the order they appear in the DATA_DESCRIPTION table
spws = msmd.spwfordatadesc(-1)
msmd.done()
spwsforbaseband(baseband=- 1, sqldmode='include')[source]

Get the spectral windows associated with the specified baseband or dictionary that maps baseband to spectral windows.

Parameters

  • baseband (int=-1) - Baseband number. If <0, return a dictionary mapping basebands to spws.

  • sqldmode (string='include') - If “include”, include SQLD windows, if “exclude”, exclude SQLD windows, if “only”, include only SQLD windows. Case insenstive, inimum match honored.

Returns

variant

Examples

msmd.open("my.ms")
# get the spectral window IDs associated with all the basebands in this dataset
basebandtospwdict = msmd.spwsforbasebands()
# get an array of spws associated with baseband 2.
spwsforbb2 = msmd.spwsforbasebands(2)
msmd.done()
spwsforfield(field='')[source]

Get an array of the unique spectral window IDs for the specified field.

Parameters

  • field ({string, int}='') - Field (case sensitive string or zero-based integer ID) for which to return the spectral window IDs.

Returns

intVec

Examples

msmd.open("my.ms")
# get the spectral window IDs associated with field "Fomalhaut"
spws = msmd.spwsforfield("Fomalhaut")
# get spectral window IDs associated with field ID 2
spws = msmd.spwsforfield(2)
msmd.done()
spwsforfields()[source]

Get a dictionary which maps field IDs to spectral window IDs. The field IDs are keys in the returned dictionary. To access a particular element, one must ensure the key is a string.

spwsforintent(intent='')[source]

Get an array of the unique spectral window IDs for the specified intent. The “*” character matches any number of characters from all character classes.

Parameters

  • intent (string='') - Intent (case sensitive) for which to return the spectral window IDs.

Returns

intVec

Examples

msmd.open("my.ms")
# get the spectral window IDs associated with "MY COOL INTENT"
spws = msmd.spwsforintent("MY COOL INTENT")
# got all the spw IDs associated with all intents which contain 'WVR'
scan_numbers = msmd.spwsforintent("*WVR*")
msmd.done()
msmd.done()
spwsfornames(spwids='')[source]

Get the IDs of the specified spw(s). Returns a dictionary where the keys are the requested spectral window names that are present in the data set and the values are arrays of the spectral window IDs corresponding to the name. If a specified name is not present, a warning message is logged and that name is not included in the returned dictionary. Specifying no names results in a dictionary containing the name to spw ID mapping for the entire data set.

Parameters

  • spwids ({string, stringVec}='') - Names of the spws for which IDs are needed (string or string array). Unspecified will return all spw names.

Returns

record

Examples

msmd.open("my.ms")
# get the IDs for spws named "CO" and "HCN"
spw_ids = msmd.spwsfornames(["CO", "HCN"])
# get the complete spw name to ID map
spw_names_to_ids = msmd.spwsfornames()
msmd.done()
spwsforscan(scan=- 1, obsid=- 1, arrayid=- 1)[source]

Get an array of the unique spectral window IDs for the specified scan number, observation ID, and array ID.

Parameters

  • scan (int=-1) - Scan number for which to return the spectral window IDs.

  • obsid (int=-1) - Observation ID. A negative value means that all observation IDs should be used.

  • arrayid (int=-1) - Array ID. A negative value means that all array IDs should be used.

Returns

intVec

Examples

msmd.open("my.ms")
# get the spectral window IDs associated with scan number 20, all obsids, all arrayids.
spws = msmd.spwsforscan(20)
msmd.done()
spwsforscans(obsid=0, arrayid=0)[source]

Get a dictionary of which maps scan number to spectral windows for the specified observation ID and array ID. The keys (scan numbers) will be strings. obsid and arrayid must both be non-negative.

Parameters

  • obsid (int=0) - Observation ID. Must be non-negative.

  • arrayid (int=0) - Array ID. Must be non-negative.

Returns

record

Examples

msmd.open("my.ms")
# get the scan - spw map for arrayID 1 and obsID 2
scan_to_spws = msmd.spwsforscans(arrayid=1, obsid=2)
# access the spws associated with scan 2
spws_for_scan2 = scan_to_spws["2"]
msmd.done()
statesforscan(scan=- 1, obsid=- 1, arrayid=- 1)[source]

Get an array of the unique state IDs for the specified scan number, observation ID, and array ID.

Parameters

  • scan (int=-1) - Scan number for which to return the state IDs.

  • obsid (int=-1) - Observation ID. A negative value means that all observation IDs should be used.

  • arrayid (int=-1) - Array ID. A negative value means that all array IDs should be used.

Returns

intVec

Examples

msmd.open("my.ms")
# get the state IDs associated with scan number 251, all obsids, all arrayids
states = msmd.statesforscan(251)
msmd.done()
statesforscans(obsid=0, arrayid=0)[source]

Get a dictionary which maps scan numbers to state IDs for the specified array and observation IDs. The returned dictionary will have scan numbers, as strings, as keys.

Parameters

  • obsid (int=0) - Observation ID, must be nonnegative.

  • arrayid (int=0) - Array ID, must be nonnegative.

Returns

record

Examples

msmd.open("my.ms")
# get the map of scan numbers to state IDs for arrayID=1, obsID=2
scans_to_states = msmd.statesforscans(obsID=2, arrayID=1)
states_for_scan_5 = scans_to_states[str(5)]
msmd.done()
summary()[source]

Get dictionary summarizing the MS.

tdmspws()[source]

Get an array of spectral window IDs used for TDM. These are windows that have 64, 128, or 256 channels.

timerangeforobs(obsid=- 1)[source]

Get the time range for the specified observation ID. The return value is a dictionary containing keys “begin” and “end”. Each of the associated value are dictionaries representing epochs which are valid measure records. The values are taken directly from the OBSERVATION subtable; no half-intervals are added or subtracted.

Parameters

  • obsid (int=-1) - Zero-based observation ID for which to get the time range.

Returns

record

Examples

msmd.open("my.ms")
# get the time range associated with observation ID 3
timerange = msmd.timerangeforobs(3)
msmd.done()
timesforfield(field=- 1)[source]

Get an array of the unique times for the specified field.

Parameters

  • field (int=-1) - Zero-based field ID for which to return the times.

Returns

doubleVec

Examples

msmd.open("my.ms")
# get the times associated with field 3
times = msmd.timesforfields(3)
msmd.done()
timesforintent(intent='')[source]

Get an array of the unique times for the specified intent.

Parameters

  • intent (string='') - Intent for which to return the times.

Returns

doubleVec

Examples

msmd.open("my.ms")
# get the times associated with intent "myintent"
times = msmd.timesforintent("myintent")
msmd.done()
timesforscan(scan=- 1, obsid=- 1, arrayid=- 1, perspw=False)[source]

Get the unique times for the specified scan number, observation ID, and array ID. If perspw=True, the returned data structure is a dictionary that has keys representing zero-based spectral window IDs and values representing the unique values of the TIME column corrsponding to the specified scan and that corresponding spectral window ID. If False, an array of unique values from the TIME column for the specified scan is returned; there is no separation into spectral window IDs.

Parameters

  • scan (int=-1) - Scan number for which to return the times.

  • obsid (int=-1) - Observation ID. A negative value indicates all observation IDs should be used.

  • arrayid (int=-1) - Array ID. A negative value indicates all array IDs should be used.

  • perspw (bool=False) - Return output dictionary with keys representing spectral window IDs (True), or an array of all times (False).

Returns

any

Examples

msmd.open("my.ms")
# get the times associated with scan number 10, all obsids, all arrayids.
times = msmd.timesforscan(10)
msmd.done()
timesforscans(scans=- 1, obsid=- 1, arrayid=- 1)[source]

Get an array of the unique times for the specified scan numbers, observation ID, and array ID.

Parameters

  • scans ({int, intVec}=-1) - Scan number(s) for which to return the times.

  • obsid (int=-1) - Observation ID. A negative value indicates all observation IDs should be used.

  • arrayid (int=-1) - Array ID. A negative value indicates all array IDs should be used.

Returns

doubleVec

Examples

msmd.open("my.ms")
# get the times associated with scan numbers 10 and 20, all obsids, all arrayids
times = msmd.timesforscans([10,20])
msmd.done()
timesforspws(spw=- 1)[source]

Get the unique times corresponding to the specified spectral window(s). The input indicates the spws for which times are to be retrieved, and can be a single integer or an array of integers. If a single, non-negative integer, an array of unique times associated with that spectral window are returned. Otherwise, a dictionary of times associated with the specified spectral windows are returned, with the spws (as strings) as the keys and the times as the values. A negative integer will cause a dictionary of all spws and their associated times to be returned.

Parameters

  • spw ({int, intVec}=-1) - Zero-based spectral window ID(s). A negative integer will cause the all the times for all spws to be returned.

Returns

any

Examples

msmd.open("my.ms")
# get the times associated with spws 10 and 20
times = msmd.timesforspws([10,20])
# print the times for spw 10
print times["10"]
msmd.done()
transitions(sourceid=0, spw=0)[source]

Get the spectral transitions from the SOURCE table for the specified source and spectral window. The return value will be an array of transitions if the transitions are defined for the specified inputs, or False if they do not.

Parameters

  • sourceid (int=0) - Zero-based source ID (from the SOURCE::SOURCE_ID column).

  • spw (int=0) - Zero-based spectral window ID.

Returns

any

Examples

msmd.open("my.ms")
# get the transitions for source ID 2 and spw ID 20
reffreq = msmd.transitions(2, 20)
msmd.done()
wvrspws(complement=False)[source]

Get an array of spectral window IDs used for WVR. These are windows that have 4 channels. If complement is True, return the complement set instead (all non-wvr spw IDs). WVR windows are identified using the algorithm 1. check for water vapor radiometer (WVR) spectral windows using the spectral window name “WVR#NOMINAL” and report these. 2. If no SPWs match that string, then the names are checked for “WVR” and are reported instead.

Parameters

  • complement (bool=False) - If True, return all non-wvr spws.

Returns

intVec

Examples

msmd.open("my.ms")
# get the spectral window IDs used for WVR.
wvr_spws = msmd.wvrspws()
msmd.done()