UVData Class

UVData is the main user class. It provides import and export functionality to all supported file formats (UVFITS, Miriad, FHD) and can be interacted with directly.

class pyuvdata.UVData[source]

A class for defining a radio interferometer dataset.

Currently supported file types: uvfits, miriad, fhd. Provides phasing functions.

UVParameter objects

For full list see UVData Parameters (http://pyuvdata.readthedocs.io/en/latest/uvdata_parameters.html). Some are always required, some are required for certain phase_types and others are always optional.

property data_like_parameters

An iterator of defined parameters which are data-like (not metadata-like)

property metadata_only

Property that determines whether this is a metadata only object.

An object is metadata only if data_array, nsample_array and flag_array are all None.

check(check_extra=True, run_check_acceptability=True)[source]

Add some extra checks on top of checks on UVBase class.

Check that required parameters exist. Check that parameters have appropriate shapes and optionally that the values are acceptable.

Parameters
  • check_extra (bool) – If true, check all parameters, otherwise only check required parameters.

  • run_check_acceptability (bool) – Option to check if values in parameters are acceptable.

Returns

bool – True if check passes

Raises

ValueError – if parameter shapes or types are wrong or do not have acceptable values (if run_check_acceptability is True)

copy(metadata_only=False)[source]

Make and return a copy of the UVData object.

Parameters

metadata_only (bool) – If True, only copy the metadata of the object.

Returns

uv (UVData) – Copy of self.

set_drift()[source]

Set phase_type to ‘drift’ and adjust required parameters.

set_phased()[source]

Set phase_type to ‘phased’ and adjust required parameters.

set_unknown_phase_type()[source]

Set phase_type to ‘unknown’ and adjust required parameters.

known_telescopes()[source]

Get a list of telescopes known to pyuvdata.

This is just a shortcut to uvdata.telescopes.known_telescopes()

Returns

list of str – List of names of known telescopes

set_telescope_params(overwrite=False)[source]

Set telescope related parameters.

If the telescope_name is in the known_telescopes, set any missing telescope-associated parameters (e.g. telescope location) to the value for the known telescope.

Parameters

overwrite (bool) – Option to overwrite existing telescope-associated parameters with the values from the known telescope.

Raises

ValueError – if the telescope_name is not in known telescopes

baseline_to_antnums(baseline)[source]

Get the antenna numbers corresponding to a given baseline number.

Parameters

baseline (int or array_like of int) – baseline number

Returns

  • int or array_like of int – first antenna number(s)

  • int or array_like of int – second antenna number(s)

antnums_to_baseline(ant1, ant2, attempt256=False)[source]

Get the baseline number corresponding to two given antenna numbers.

Parameters
  • ant1 (int or array_like of int) – first antenna number

  • ant2 (int or array_like of int) – second antenna number

  • attempt256 (bool) – Option to try to use the older 256 standard used in many uvfits files (will use 2048 standard if there are more than 256 antennas).

Returns

int or array of int – baseline number corresponding to the two antenna numbers.

set_lsts_from_time_array()[source]

Set the lst_array based from the time_array.

unphase_to_drift(phase_frame=None, use_ant_pos=False)[source]

Convert from a phased dataset to a drift dataset.

See the phasing memo under docs/references for more documentation.

Parameters
  • phase_frame (str) – The astropy frame to phase from. Either ‘icrs’ or ‘gcrs’. ‘gcrs’ accounts for precession & nutation, ‘icrs’ also includes abberation. Defaults to using the ‘phase_center_frame’ attribute or ‘icrs’ if that attribute is None.

  • use_ant_pos (bool) – If True, calculate the uvws directly from the antenna positions rather than from the existing uvws.

Raises

ValueError – If the phase_type is not ‘phased’

phase(ra, dec, epoch='J2000', phase_frame='icrs', use_ant_pos=False, allow_rephase=True, orig_phase_frame=None)[source]

Phase a drift scan dataset to a single ra/dec at a particular epoch.

See the phasing memo under docs/references for more documentation.

Tested against MWA_Tools/CONV2UVFITS/convutils. Will not phase already phased data.

Parameters
  • ra (float) – The ra to phase to in radians.

  • dec (float) – The dec to phase to in radians.

  • epoch (astropy.time.Time object or str) – The epoch to use for phasing. Either an astropy Time object or the string “J2000” (which is the default). Note that the epoch is only used to evaluate the ra & dec values, if the epoch is not J2000, the ra & dec values are interpreted as FK5 ra/dec values and translated to J2000, the data are then phased to the J2000 ra/dec values.

  • phase_frame (str) – The astropy frame to phase to. Either ‘icrs’ or ‘gcrs’. ‘gcrs’ accounts for precession & nutation, ‘icrs’ accounts for precession, nutation & abberation.

  • use_ant_pos (bool) – If True, calculate the uvws directly from the antenna positions rather than from the existing uvws.

  • allow_rephase (bool) – If True, allow unphasing and rephasing if this object is already phased.

  • orig_phase_frame (str) – The original phase frame of this object (to use in unphasing). Only used if the object is already phased, allow_rephase is True and the phase_center_ra/dec of the object does not match ra and dec. Defaults to using the ‘phase_center_frame’ attribute or ‘icrs’ if that attribute is None.

Raises

ValueError – If the phase_type is not ‘drift’

phase_to_time(time, phase_frame='icrs', use_ant_pos=False, allow_rephase=True, orig_phase_frame=None)[source]

Phase a drift scan dataset to the ra/dec of zenith at a particular time.

See the phasing memo under docs/references for more documentation.

Parameters
  • time (astropy.time.Time object or float) – The time to phase to, an astropy Time object or a float Julian Date

  • phase_frame (str) – The astropy frame to phase to. Either ‘icrs’ or ‘gcrs’. ‘gcrs’ accounts for precession & nutation, ‘icrs’ accounts for precession, nutation & abberation.

  • use_ant_pos (bool) – If True, calculate the uvws directly from the antenna positions rather than from the existing uvws.

  • allow_rephase (bool) – If True, allow unphasing and rephasing if this object is already phased.

  • orig_phase_frame (str) – The original phase frame of this object (to use in unphasing). Only used if the object is already phased, allow_rephase is True and the phase_center_ra/dec of the object does not match ra and dec. Defaults to using the ‘phase_center_frame’ attribute or ‘icrs’ if that attribute is None.

Raises
  • ValueError – If the phase_type is not ‘drift’

  • TypeError – If time is not an astropy.time.Time object or Julian Date as a float

set_uvws_from_antenna_positions(allow_phasing=False, orig_phase_frame=None, output_phase_frame='icrs')[source]

Calculate UVWs based on antenna_positions

Parameters
  • allow_phasing (bool) – Option for phased data. If data is phased and allow_phasing is set, data will be unphased, UVWs will be calculated, and then data will be rephased.

  • orig_phase_frame (str) – The astropy frame to phase from. Either ‘icrs’ or ‘gcrs’. Defaults to using the ‘phase_center_frame’ attribute or ‘icrs’ if that attribute is None. Only used if allow_phasing is True.

  • output_phase_frame (str) – The astropy frame to phase to. Either ‘icrs’ or ‘gcrs’. Only used if allow_phasing is True.

Raises

ValueError – If data is phased and allow_phasing is False.

Warns

UserWarning – If the phase_type is ‘phased’

conjugate_bls(convention='ant1<ant2', use_enu=True, uvw_tol=0.0)[source]

Conjugate baselines according to one of the supported conventions.

This will fail if only one of the cross pols is present (because conjugation requires changing the polarization number for cross pols).

Parameters
  • convention (str or array_like of int) – A convention for the directions of the baselines, options are: ‘ant1<ant2’, ‘ant2<ant1’, ‘u<0’, ‘u>0’, ‘v<0’, ‘v>0’ or an index array of blt indices to conjugate.

  • use_enu (bool) – Use true antenna positions to determine uv location (as opposed to uvw array). Only applies if convention is ‘u<0’, ‘u>0’, ‘v<0’, ‘v>0’. Set to False to use uvw array values.

  • uvw_tol (float) – Defines a tolerance on uvw coordinates for setting the u>0, u<0, v>0, or v<0 conventions. Defaults to 0m.

Raises

ValueError – If convention is not an allowed value or if not all conjugate pols exist.

reorder_pols(order='AIPS', run_check=True, check_extra=True, run_check_acceptability=True)[source]

Rearrange polarizations in the event they are not uvfits compatible.

Parameters
  • order (str) – Either a string specifying a cannonical ordering (‘AIPS’ or ‘CASA’) or an index array of length Npols that specifies how to shuffle the data (this is not the desired final pol order). CASA ordering has cross-pols in between (e.g. XX,XY,YX,YY) AIPS ordering has auto-pols followed by cross-pols (e.g. XX,YY,XY,YX) Default (‘AIPS’) will sort by absolute value of pol values.

  • run_check (bool) – Option to check for the existence and proper shapes of parameters after reordering.

  • check_extra (bool) – Option to check optional parameters as well as required ones.

  • run_check_acceptability (bool) – Option to check acceptable range of the values of parameters after reordering.

Raises

ValueError – If the order is not one of the allowed values.

reorder_blts(order='time', minor_order=None, conj_convention=None, uvw_tol=0.0, conj_convention_use_enu=True, run_check=True, check_extra=True, run_check_acceptability=True)[source]

Arrange blt axis according to desired order. Optionally conjugate some baselines.

Parameters
  • order (str or array_like of int) – A string describing the desired order along the blt axis. Options are: time, baseline, ant1, ant2, bda or an index array of length Nblts that specifies the new order.

  • minor_order (str) – Optionally specify a secondary ordering. Default depends on how order is set: if order is ‘time’, this defaults to baseline, if order is ant1, or ant2 this defaults to the other antenna, if order is baseline the only allowed value is time. Ignored if order is bda If this is the same as order, it is reset to the default.

  • conj_convention (str or array_like of int) – Optionally conjugate baselines to make the baselines have the desired orientation. See conjugate_bls for allowed values and details.

  • uvw_tol (float) – If conjugating baselines, sets a tolerance for determining the signs of u,v, and w, and whether or not they are zero. See conjugate_bls for details.

  • conj_convention_use_enu (bool) – If conj_convention is set, this is passed to conjugate_bls, see that method for details.

  • run_check (bool) – Option to check for the existence and proper shapes of parameters after reordering.

  • check_extra (bool) – Option to check optional parameters as well as required ones.

  • run_check_acceptability (bool) – Option to check acceptable range of the values of parameters after reordering.

Raises

ValueError – If parameter values are inappropriate

sum_vis(other, run_check=True, check_extra=True, run_check_acceptability=True, inplace=False, difference=False)[source]

Sums visibilities between two UVData objects.

Parameters
  • other (UVData object) – Another UVData object which will be added to self.

  • run_check (bool) – Option to check for the existence and proper shapes of parameters after combining objects.

  • check_extra (bool) – Option to check optional parameters as well as required ones.

  • run_check_acceptability (bool) – Option to check acceptable range of the values of parameters after combining objects.

  • inplace (bool) – If True, overwrite self as we go, otherwise create a third object as the sum of the two.

  • difference (bool) – If True, differences the visibilities of the two UVData objects rather than summing them.

Returns

UVData Object – If inplace parameter is False.

Raises

ValueError – If other is not a UVData object, or if self and other are not compatible.

fast_concat(other, axis, phase_center_radec=None, unphase_to_drift=False, phase_frame='icrs', orig_phase_frame=None, use_ant_pos=False, run_check=True, check_extra=True, run_check_acceptability=True, inplace=False)[source]

Concatenate two UVData objects along specified axis with almost no checking of metadata.

Warning! This method assumes all the metadata along other axes is sorted the same way. The __add__ method is much safer, it checks all the metadata, but it is slower. Some quick checks are run, but this method doesn’t make any guarantees that the resulting object is correct.

Parameters
  • other (UVData object) – Another UVData object which will be added to self.

  • axis (str) – Axis to concatenate files along. This enables fast concatenation along the specified axis without the normal checking that all other metadata agrees. Allowed values are: ‘blt’, ‘freq’, ‘polarization’.

  • phase_center_radec (array_like of float) – The phase center to phase the files to before adding the objects in radians (in the ICRS frame). Note that if this keyword is not set and the two UVData objects are phased to different phase centers or if one is phased and one is drift, this method will error because the objects are not compatible.

  • unphase_to_drift (bool) – If True, unphase the objects to drift before combining them.

  • phase_frame (str) – The astropy frame to phase to. Either ‘icrs’ or ‘gcrs’. ‘gcrs’ accounts for precession & nutation, ‘icrs’ accounts for precession, nutation & abberation. Only used if phase_center_radec is set.

  • orig_phase_frame (str) – The original phase frame of the data (if it is already phased). Used for unphasing, only if unphase_to_drift or phase_center_radec are set. Defaults to using the ‘phase_center_frame’ attribute or ‘icrs’ if that attribute is None.

  • use_ant_pos (bool) – If True, calculate the phased or unphased uvws directly from the antenna positions rather than from the existing uvws. Only used if unphase_to_drift or phase_center_radec are set.

  • run_check (bool) – Option to check for the existence and proper shapes of parameters after combining objects.

  • check_extra (bool) – Option to check optional parameters as well as required ones.

  • run_check_acceptability (bool) – Option to check acceptable range of the values of parameters after combining objects.

  • inplace (bool) – If True, overwrite self as we go, otherwise create a third object as the sum of the two.

Raises

ValueError – If other is not a UVData object, axis is not an allowed value or if self and other are not compatible.

select(antenna_nums=None, antenna_names=None, ant_str=None, bls=None, frequencies=None, freq_chans=None, times=None, time_range=None, polarizations=None, blt_inds=None, run_check=True, check_extra=True, run_check_acceptability=True, inplace=True, metadata_only=None, keep_all_metadata=True)[source]

Downselect data to keep on the object along various axes.

Axes that can be selected along include antenna names or numbers, antenna pairs, frequencies, times and polarizations. Specific baseline-time indices can also be selected, but this is not commonly used. The history attribute on the object will be updated to identify the operations performed.

Parameters
  • antenna_nums (array_like of int, optional) – The antennas numbers to keep in the object (antenna positions and names for the removed antennas will be retained unless keep_all_metadata is False). This cannot be provided if antenna_names is also provided.

  • antenna_names (array_like of str, optional) – The antennas names to keep in the object (antenna positions and names for the removed antennas will be retained unless keep_all_metadata is False). This cannot be provided if antenna_nums is also provided.

  • bls (list of tuple, optional) – A list of antenna number tuples (e.g. [(0, 1), (3, 2)]) or a list of baseline 3-tuples (e.g. [(0, 1, ‘xx’), (2, 3, ‘yy’)]) specifying baselines to keep in the object. For length-2 tuples, the ordering of the numbers within the tuple does not matter. For length-3 tuples, the polarization string is in the order of the two antennas. If length-3 tuples are provided, polarizations must be None.

  • ant_str (str, optional) – A string containing information about what antenna numbers and polarizations to keep in the object. Can be ‘auto’, ‘cross’, ‘all’, or combinations of antenna numbers and polarizations (e.g. ‘1’, ‘1_2’, ‘1x_2y’). See tutorial for more examples of valid strings and the behavior of different forms for ant_str. If ‘1x_2y,2y_3y’ is passed, both polarizations ‘xy’ and ‘yy’ will be kept for both baselines (1, 2) and (2, 3) to return a valid pyuvdata object. An ant_str cannot be passed in addition to any of antenna_nums, antenna_names, bls args or the polarizations parameters, if it is a ValueError will be raised.

  • frequencies (array_like of float, optional) – The frequencies to keep in the object, each value passed here should exist in the freq_array.

  • freq_chans (array_like of int, optional) – The frequency channel numbers to keep in the object.

  • times (array_like of float, optional) – The times to keep in the object, each value passed here should exist in the time_array. Cannot be used with time_range.

  • time_range (array_like of float, optional) – The time range in Julian Date to keep in the object, must be length 2. Some of the times in the object should fall between the first and last elements. Cannot be used with times.

  • polarizations (array_like of int, optional) – The polarizations numbers to keep in the object, each value passed here should exist in the polarization_array.

  • blt_inds (array_like of int, optional) – The baseline-time indices to keep in the object. This is not commonly used.

  • run_check (bool) – Option to check for the existence and proper shapes of parameters after downselecting data on this object (the default is True, meaning the check will be run).

  • check_extra (bool) – Option to check optional parameters as well as required ones (the default is True, meaning the optional parameters will be checked).

  • run_check_acceptability (bool) – Option to check acceptable range of the values of parameters after downselecting data on this object (the default is True, meaning the acceptable range check will be done).

  • inplace (bool) – Option to perform the select directly on self or return a new UVData object with just the selected data (the default is True, meaning the select will be done on self).

  • metadata_only (bool) – Option to only do the select on the metadata. Not allowed if the data_array, flag_array or nsample_array is not None. Note this option has been replaced by an automatic detection of whether the data like arrays are present. The keyword will be deprecated in version 1.6.

  • keep_all_metadata (bool) – Option to keep all the metadata associated with antennas, even those that do do not have data associated with them after the select option.

Returns

UVData object or None – None is returned if inplace is True, otherwise a new UVData object with just the selected data is returned

Raises

ValueError – If any of the parameters are set to inappropriate values.

read_uvfits(filename, axis=None, antenna_nums=None, antenna_names=None, ant_str=None, bls=None, frequencies=None, freq_chans=None, times=None, time_range=None, polarizations=None, blt_inds=None, keep_all_metadata=True, read_data=True, read_metadata=True, run_check=True, check_extra=True, run_check_acceptability=True)[source]

Read in header, metadata and data from a single uvfits file.

Parameters
  • filename (str) – The uvfits file to read from. Support for a list of files will be deprecated in version 2.0 in favor of a call to the generic read method.

  • axis (str) – Axis to concatenate files along. This enables fast concatenation along the specified axis without the normal checking that all other metadata agrees. This method does not guarantee correct resulting objects. Please see the docstring for fast_concat for details. Allowed values are: ‘blt’, ‘freq’, ‘polarization’. Only used if multiple files are passed.

  • antenna_nums (array_like of int, optional) – The antennas numbers to include when reading data into the object (antenna positions and names for the removed antennas will be retained unless keep_all_metadata is False). This cannot be provided if antenna_names is also provided. Ignored if read_data is False.

  • antenna_names (array_like of str, optional) – The antennas names to include when reading data into the object (antenna positions and names for the removed antennas will be retained unless keep_all_metadata is False). This cannot be provided if antenna_nums is also provided. Ignored if read_data is False.

  • bls (list of tuple, optional) – A list of antenna number tuples (e.g. [(0, 1), (3, 2)]) or a list of baseline 3-tuples (e.g. [(0, 1, ‘xx’), (2, 3, ‘yy’)]) specifying baselines to include when reading data into the object. For length-2 tuples, the ordering of the numbers within the tuple does not matter. For length-3 tuples, the polarization string is in the order of the two antennas. If length-3 tuples are provided, polarizations must be None. Ignored if read_data is False.

  • ant_str (str, optional) – A string containing information about what antenna numbers and polarizations to include when reading data into the object. Can be ‘auto’, ‘cross’, ‘all’, or combinations of antenna numbers and polarizations (e.g. ‘1’, ‘1_2’, ‘1x_2y’). See tutorial for more examples of valid strings and the behavior of different forms for ant_str. If ‘1x_2y,2y_3y’ is passed, both polarizations ‘xy’ and ‘yy’ will be kept for both baselines (1, 2) and (2, 3) to return a valid pyuvdata object. An ant_str cannot be passed in addition to any of antenna_nums, antenna_names, bls args or the polarizations parameters, if it is a ValueError will be raised. Ignored if read_data is False.

  • frequencies (array_like of float, optional) – The frequencies to include when reading data into the object, each value passed here should exist in the freq_array. Ignored if read_data is False.

  • freq_chans (array_like of int, optional) – The frequency channel numbers to include when reading data into the object. Ignored if read_data is False.

  • times (array_like of float, optional) – The times to include when reading data into the object, each value passed here should exist in the time_array in the file. Cannot be used with time_range.

  • time_range (array_like of float, optional) – The time range in Julian Date to include when reading data into the object, must be length 2. Some of the times in the file should fall between the first and last elements. Cannot be used with times.

  • polarizations (array_like of int, optional) – The polarizations numbers to include when reading data into the object, each value passed here should exist in the polarization_array. Ignored if read_data is False.

  • blt_inds (array_like of int, optional) – The baseline-time indices to include when reading data into the object. This is not commonly used. Ignored if read_data is False.

  • keep_all_metadata (bool) – Option to keep all the metadata associated with antennas, even those that do not have data associated with them after the select option.

  • read_data (bool) – Read in the visibility and flag data. If set to false, only the basic header info and metadata read in. Setting read_data to False results in a metdata only object.

  • read_metadata (bool) – Deprecated, will be removed in version 2.0, after which metadata will always be read along with header data. Read in metadata (times, baselines, uvws) as well as basic header info. Only used if read_data is False (metadata will be read if data is read). If both read_data and read_metadata are false, only basic header info is read in, which will result in an incompletely defined object – check will not pass.

  • run_check (bool) – Option to check for the existence and proper shapes of parameters after after reading in the file (the default is True, meaning the check will be run). Ignored if read_data is False.

  • check_extra (bool) – Option to check optional parameters as well as required ones (the default is True, meaning the optional parameters will be checked). Ignored if read_data is False.

  • run_check_acceptability (bool) – Option to check acceptable range of the values of parameters after reading in the file (the default is True, meaning the acceptable range check will be done). Ignored if read_data is False.

Raises
  • IOError – If filename doesn’t exist.

  • ValueError – If incompatible select keywords are set (e.g. ant_str with other antenna selectors, times and time_range) or select keywords exclude all data or if keywords are set to the wrong type. If the data are multi source or have multiple spectral windows. If the metadata are not internally consistent or missing.

write_uvfits(filename, spoof_nonessential=False, write_lst=True, force_phase=False, run_check=True, check_extra=True, run_check_acceptability=True)[source]

Write the data to a uvfits file.

Parameters
  • filename (str) – The uvfits file to write to.

  • spoof_nonessential (bool) – Option to spoof the values of optional UVParameters that are not set but are required for uvfits files.

  • write_lst (bool) – Option to write the LSTs to the metadata (random group parameters).

  • force_phase (: bool) – Option to automatically phase drift scan data to zenith of the first timestamp.

  • run_check (bool) – Option to check for the existence and proper shapes of parameters after before writing the file (the default is True, meaning the check will be run).

  • check_extra (bool) – Option to check optional parameters as well as required ones (the default is True, meaning the optional parameters will be checked).

  • run_check_acceptability (bool) – Option to check acceptable range of the values of parameters before writing the file (the default is True, meaning the acceptable range check will be done).

Raises
  • ValueError – The phase_type of the object is “drift” and the force_phase keyword is not set. The phase_type of the object is “unknown”. If the frequencies are not evenly spaced or are separated by more than their channel width. The polarization values are not evenly spaced. Any of [‘antenna_positions’, ‘gst0’, ‘rdate’, ‘earth_omega’, ‘dut1’, ‘timesys’] are not set on the object and spoof_nonessential is False. If the timesys parameter is not set to “UTC”.

  • TypeError – If any entry in extra_keywords is not a single string or number.

read_ms(filepath, axis=None, data_column='DATA', pol_order='AIPS', run_check=True, check_extra=True, run_check_acceptability=True)[source]

Read in data from a measurement set

Parameters
  • filepath (str) – The measurement set root directory to read from. Support for a list/array of file directories will be deprecated in version 2.0 in favor of a call to the generic read method.

  • axis (str) – Axis to concatenate files along. This enables fast concatenation along the specified axis without the normal checking that all other metadata agrees. This method does not guarantee correct resulting objects. Please see the docstring for fast_concat for details. Allowed values are: ‘blt’, ‘freq’, ‘polarization’. Only used if multiple files are passed.

  • data_column (str) – name of CASA data column to read into data_array. Options are: ‘DATA’, ‘MODEL’, or ‘CORRECTED_DATA’

  • pol_order (str) – Option to specify polarizations order convention, options are ‘CASA’ or ‘AIPS’.

  • run_check (bool) – Option to check for the existence and proper shapes of parameters after after reading in the file (the default is True, meaning the check will be run).

  • check_extra (bool) – Option to check optional parameters as well as required ones (the default is True, meaning the optional parameters will be checked).

  • run_check_acceptability (bool) – Option to check acceptable range of the values of parameters after reading in the file (the default is True, meaning the acceptable range check will be done).

Raises
  • IOError – If root file directory doesn’t exist.

  • ValueError – If the data_column is not set to an allowed value. If the data are have multiple subarrays or are multi source or have multiple spectral windows. If the data have multiple data description ID values.

read_fhd(filelist, use_model=False, axis=None, run_check=True, check_extra=True, run_check_acceptability=True)[source]

Read in data from a list of FHD files.

Parameters
  • filelist (array_like of str) – The list/array of FHD save files to read from. Must include at least one polarization file, a params file and a flag file. Support for a list of lists of files for multiple data sets will be deprecated in version 2.0 in favor of a call to the generic read method.

  • use_model (bool) – Option to read in the model visibilities rather than the dirty visibilities (the default is False, meaning the dirty visibilities will be read).

  • axis (str) – Axis to concatenate files along. This enables fast concatenation along the specified axis without the normal checking that all other metadata agrees. This method does not guarantee correct resulting objects. Please see the docstring for fast_concat for details. Allowed values are: ‘blt’, ‘freq’, ‘polarization’. Only used if multiple data sets are passed.

  • run_check (bool) – Option to check for the existence and proper shapes of parameters after after reading in the file (the default is True, meaning the check will be run).

  • check_extra (bool) – Option to check optional parameters as well as required ones (the default is True, meaning the optional parameters will be checked).

  • run_check_acceptability (bool) – Option to check acceptable range of the values of parameters after reading in the file (the default is True, meaning the acceptable range check will be done).

Raises

ValueError – If required files are missing or multiple files for any polarization are included in filelist. If there is no recognized key for visibility weights in the flags_file.

read_miriad(filepath, axis=None, antenna_nums=None, ant_str=None, bls=None, polarizations=None, time_range=None, read_data=True, phase_type=None, correct_lat_lon=True, run_check=True, check_extra=True, run_check_acceptability=True)[source]

Read in data from a miriad file.

Parameters
  • filepath (str) – The miriad root directory to read from. Support for a list/array of file directories will be deprecated in version 2.0 in favor of a call to the generic read method.

  • axis (str) – Axis to concatenate files along. This enables fast concatenation along the specified axis without the normal checking that all other metadata agrees. This method does not guarantee correct resulting objects. Please see the docstring for fast_concat for details. Allowed values are: ‘blt’, ‘freq’, ‘polarization’. Only used if multiple files are passed.

  • antenna_nums (array_like of int, optional) – The antennas numbers to read into the object.

  • bls (list of tuple, optional) – A list of antenna number tuples (e.g. [(0, 1), (3, 2)]) or a list of baseline 3-tuples (e.g. [(0, 1, ‘xx’), (2, 3, ‘yy’)]) specifying baselines to include when reading data into the object. For length-2 tuples, the ordering of the numbers within the tuple does not matter. For length-3 tuples, the polarization string is in the order of the two antennas. If length-3 tuples are provided, polarizations must be None.

  • ant_str (str, optional) – A string containing information about what antenna numbers and polarizations to include when reading data into the object. Can be ‘auto’, ‘cross’, ‘all’, or combinations of antenna numbers and polarizations (e.g. ‘1’, ‘1_2’, ‘1x_2y’). See tutorial for more examples of valid strings and the behavior of different forms for ant_str. If ‘1x_2y,2y_3y’ is passed, both polarizations ‘xy’ and ‘yy’ will be kept for both baselines (1, 2) and (2, 3) to return a valid pyuvdata object. An ant_str cannot be passed in addition to any of antenna_nums, bls or polarizations parameters, if it is a ValueError will be raised.

  • polarizations (array_like of int or str, optional) – List of polarization integers or strings to read-in. e.g. [‘xx’, ‘yy’, …]

  • time_range (list of float, optional) – len-2 list containing min and max range of times in Julian Date to include when reading data into the object. e.g. [2458115.20, 2458115.40]

  • read_data (bool) – Read in the visibility and flag data. If set to false, only the metadata will be read in. Setting read_data to False results in an incompletely defined object (check will not pass).

  • phase_type (str, optional) – Option to specify the phasing status of the data. Options are ‘drift’, ‘phased’ or None. ‘drift’ means the data are zenith drift data, ‘phased’ means the data are phased to a single RA/Dec. Default is None meaning it will be guessed at based on the file contents.

  • correct_lat_lon (bool) – Option to update the latitude and longitude from the known_telescopes list if the altitude is missing.

  • run_check (bool) – Option to check for the existence and proper shapes of parameters after after reading in the file (the default is True, meaning the check will be run). Ignored if read_data is False.

  • check_extra (bool) – Option to check optional parameters as well as required ones (the default is True, meaning the optional parameters will be checked). Ignored if read_data is False.

  • run_check_acceptability (bool) – Option to check acceptable range of the values of parameters after reading in the file (the default is True, meaning the acceptable range check will be done). Ignored if read_data is False.

Raises
  • IOError – If root file directory doesn’t exist.

  • ValueError – If incompatible select keywords are set (e.g. ant_str with other antenna selectors, times and time_range) or select keywords exclude all data or if keywords are set to the wrong type. If the data are multi source or have multiple spectral windows. If the metadata are not internally consistent.

write_miriad(filepath, run_check=True, check_extra=True, run_check_acceptability=True, clobber=False, no_antnums=False)[source]

Write the data to a miriad file.

Parameters
  • filename (str) – The miriad root directory to write to.

  • run_check (bool) – Option to check for the existence and proper shapes of parameters after before writing the file (the default is True, meaning the check will be run).

  • check_extra (bool) – Option to check optional parameters as well as required ones (the default is True, meaning the optional parameters will be checked).

  • run_check_acceptability (bool) – Option to check acceptable range of the values of parameters before writing the file (the default is True, meaning the acceptable range check will be done).

  • clobber (bool) – Option to overwrite the filename if the file already exists.

  • no_antnums (bool) – Option to not write the antnums variable to the file. Should only be used for testing purposes.

Raises
  • ValueError – If the frequencies are not evenly spaced or are separated by more than their channel width. The phase_type of the object is “unknown”.

  • TypeError – If any entry in extra_keywords is not a single string or number.

read_mwa_corr_fits(filelist, axis=None, use_cotter_flags=False, correct_cable_len=False, phase_to_pointing_center=False, phase_data=None, phase_center=None, run_check=True, check_extra=True, run_check_acceptability=True)[source]

Read in MWA correlator gpu box files.

Parameters
  • filelist (list of str) – The list of MWA correlator files to read from. Must include at least one fits file and only one metafits file per data set. Support for a list of lists of files for multiple data sets will be deprecated in version 2.0 in favor of a call to the generic read method.

  • axis (str) – Axis to concatenate files along. This enables fast concatenation along the specified axis without the normal checking that all other metadata agrees. This method does not guarantee correct resulting objects. Please see the docstring for fast_concat for details. Allowed values are: ‘blt’, ‘freq’, ‘polarization’. Only used if multiple files are passed.

  • use_cotter_flags (bool) – Option to use cotter output mwaf flag files. Otherwise flagging will only be applied to missing data and bad antennas.

  • correct_cable_len (bool) – Option to apply a cable delay correction.

  • phase_to_pointing_center (bool) – Option to phase to the observation pointing center.

  • phase_data (bool) – Deprecated, use phase_to_pointing_center. Option to phase data, default is no phasing.

  • phase_center (tuple, optional) – Deprecated, use the read method to phase to arbitrary locations. A tuple containing the ra and dec coordinates in radians of a specific location to phase data to.

  • run_check (bool) – Option to check for the existence and proper shapes of parameters after after reading in the file (the default is True, meaning the check will be run).

  • check_extra (bool) – Option to check optional parameters as well as required ones (the default is True, meaning the optional parameters will be checked).

  • run_check_acceptability (bool) – Option to check acceptable range of the values of parameters after reading in the file (the default is True, meaning the acceptable range check will be done).

Raises

ValueError – If required files are missing or multiple files metafits files are included in filelist. If files from different observations are included in filelist. If files in fileslist have different fine channel widths If file types other than fits, metafits, and mwaf files are included in filelist.

read_uvh5(filename, axis=None, antenna_nums=None, antenna_names=None, ant_str=None, bls=None, frequencies=None, freq_chans=None, times=None, time_range=None, polarizations=None, blt_inds=None, keep_all_metadata=True, read_data=True, data_array_dtype=<class 'numpy.complex128'>, run_check=True, check_extra=True, run_check_acceptability=True)[source]

Read a UVH5 file.

Parameters
  • filename (str) – The UVH5 file to read from. Support for a list/array of files will be deprecated in version 2.0 in favor of a call to the generic read method.

  • axis (str) – Axis to concatenate files along. This enables fast concatenation along the specified axis without the normal checking that all other metadata agrees. This method does not guarantee correct resulting objects. Please see the docstring for fast_concat for details. Allowed values are: ‘blt’, ‘freq’, ‘polarization’. Only used if multiple files are passed.

  • antenna_nums (array_like of int, optional) – The antennas numbers to include when reading data into the object (antenna positions and names for the removed antennas will be retained unless keep_all_metadata is False). This cannot be provided if antenna_names is also provided. Ignored if read_data is False.

  • antenna_names (array_like of str, optional) – The antennas names to include when reading data into the object (antenna positions and names for the removed antennas will be retained unless keep_all_metadata is False). This cannot be provided if antenna_nums is also provided. Ignored if read_data is False.

  • bls (list of tuple, optional) – A list of antenna number tuples (e.g. [(0, 1), (3, 2)]) or a list of baseline 3-tuples (e.g. [(0, 1, ‘xx’), (2, 3, ‘yy’)]) specifying baselines to include when reading data into the object. For length-2 tuples, the ordering of the numbers within the tuple does not matter. For length-3 tuples, the polarization string is in the order of the two antennas. If length-3 tuples are provided, polarizations must be None. Ignored if read_data is False.

  • ant_str (str, optional) – A string containing information about what antenna numbers and polarizations to include when reading data into the object. Can be ‘auto’, ‘cross’, ‘all’, or combinations of antenna numbers and polarizations (e.g. ‘1’, ‘1_2’, ‘1x_2y’). See tutorial for more examples of valid strings and the behavior of different forms for ant_str. If ‘1x_2y,2y_3y’ is passed, both polarizations ‘xy’ and ‘yy’ will be kept for both baselines (1, 2) and (2, 3) to return a valid pyuvdata object. An ant_str cannot be passed in addition to any of antenna_nums, antenna_names, bls args or the polarizations parameters, if it is a ValueError will be raised. Ignored if read_data is False.

  • frequencies (array_like of float, optional) – The frequencies to include when reading data into the object, each value passed here should exist in the freq_array. Ignored if read_data is False.

  • freq_chans (array_like of int, optional) – The frequency channel numbers to include when reading data into the object. Ignored if read_data is False.

  • times (array_like of float, optional) – The times to include when reading data into the object, each value passed here should exist in the time_array in the file. Cannot be used with time_range.

  • time_range (array_like of float, optional) – The time range in Julian Date to include when reading data into the object, must be length 2. Some of the times in the file should fall between the first and last elements. Cannot be used with times.

  • polarizations (array_like of int, optional) – The polarizations numbers to include when reading data into the object, each value passed here should exist in the polarization_array. Ignored if read_data is False.

  • blt_inds (array_like of int, optional) – The baseline-time indices to include when reading data into the object. This is not commonly used. Ignored if read_data is False.

  • keep_all_metadata (bool) – Option to keep all the metadata associated with antennas, even those that do not have data associated with them after the select option.

  • read_data (bool) – Read in the visibility and flag data. If set to false, only the basic header info and metadata will be read in. Setting read_data to False results in an incompletely defined object (check will not pass).

  • data_array_dtype (numpy dtype) – Datatype to store the output data_array as. Must be either np.complex64 (single-precision real and imaginary) or np.complex128 (double- precision real and imaginary). Only used if the datatype of the visibility data on-disk is not ‘c8’ or ‘c16’.

  • run_check (bool) – Option to check for the existence and proper shapes of parameters after after reading in the file (the default is True, meaning the check will be run). Ignored if read_data is False.

  • check_extra (bool) – Option to check optional parameters as well as required ones (the default is True, meaning the optional parameters will be checked). Ignored if read_data is False.

  • run_check_acceptability (bool) – Option to check acceptable range of the values of parameters after reading in the file (the default is True, meaning the acceptable range check will be done). Ignored if read_data is False.

Raises
  • IOError – If filename doesn’t exist.

  • ValueError – If the data_array_dtype is not a complex dtype. If incompatible select keywords are set (e.g. ant_str with other antenna selectors, times and time_range) or select keywords exclude all data or if keywords are set to the wrong type.

write_uvh5(filename, run_check=True, check_extra=True, run_check_acceptability=True, clobber=False, data_compression=None, flags_compression='lzf', nsample_compression='lzf', data_write_dtype=None)[source]

Write a completely in-memory UVData object to a UVH5 file.

Parameters
  • filename (str) – The UVH5 file to write to.

  • clobber (bool) – Option to overwrite the file if it already exists.

  • data_compression (str) – HDF5 filter to apply when writing the data_array. Default is None meaning no filter or compression.

  • flags_compression (str) – HDF5 filter to apply when writing the flags_array. Default is “lzf” for the LZF filter.

  • nsample_compression (str) – HDF5 filter to apply when writing the nsample_array. Default is “lzf” for the LZF filter.

  • data_write_dtype (numpy dtype) – datatype of output visibility data. If ‘None’, then the same datatype as data_array will be used. Otherwise, a numpy dtype object must be specified with an ‘r’ field and an ‘i’ field for real and imaginary parts, respectively. See uvh5.py for an example of defining such a datatype.

  • run_check (bool) – Option to check for the existence and proper shapes of parameters after before writing the file (the default is True, meaning the check will be run).

  • check_extra (bool) – Option to check optional parameters as well as required ones (the default is True, meaning the optional parameters will be checked).

  • run_check_acceptability (bool) – Option to check acceptable range of the values of parameters before writing the file (the default is True, meaning the acceptable range check will be done).

initialize_uvh5_file(filename, clobber=False, data_compression=None, flags_compression='lzf', nsample_compression='lzf', data_write_dtype=None)[source]

Initialize a UVH5 file on disk with the header metadata and empty data arrays.

Parameters
  • filename (str) – The UVH5 file to write to.

  • clobber (bool) – Option to overwrite the file if it already exists.

  • data_compression (str) – HDF5 filter to apply when writing the data_array. Default is None meaning no filter or compression.

  • flags_compression (str) – HDF5 filter to apply when writing the flags_array. Default is “lzf” for the LZF filter.

  • nsample_compression (str) – HDF5 filter to apply when writing the nsample_array. Default is “lzf” for the LZF filter.

  • data_write_dtype (numpy dtype) – datatype of output visibility data. If ‘None’, then the same datatype as data_array will be used. Otherwise, a numpy dtype object must be specified with an ‘r’ field and an ‘i’ field for real and imaginary parts, respectively. See uvh5.py for an example of defining such a datatype.

Notes

When partially writing out data, this function should be called first to initialize the file on disk. The data is then actually written by calling the write_uvh5_part method, with the same filename as the one specified in this function. See the tutorial for a worked example.

write_uvh5_part(filename, data_array, flags_array, nsample_array, check_header=True, antenna_nums=None, antenna_names=None, ant_str=None, bls=None, frequencies=None, freq_chans=None, times=None, polarizations=None, blt_inds=None, run_check_acceptability=True, add_to_history=None)[source]

Write data to a UVH5 file that has already been initialized.

Parameters
  • filename (str) – The UVH5 file to write to. It must already exist, and is assumed to have been initialized with initialize_uvh5_file.

  • data_array (ndarray) – The data to write to disk. A check is done to ensure that the dimensions of the data passed in conform to the ones specified by the “selection” arguments.

  • flags_array (ndarray) – The flags array to write to disk. A check is done to ensure that the dimensions of the data passed in conform to the ones specified by the “selection” arguments.

  • nsample_array (ndarray) – The nsample array to write to disk. A check is done to ensure that the dimensions of the data passed in conform to the ones specified by the “selection” arguments.

  • check_header (bool) – Option to check that the metadata present in the header on disk matches that in the object.

  • antenna_nums (array_like of int, optional) – The antennas numbers to include when writing data into the file (antenna positions and names for the removed antennas will be retained). This cannot be provided if antenna_names is also provided.

  • antenna_names (array_like of str, optional) – The antennas names to include when writing data into the file (antenna positions and names for the removed antennas will be retained). This cannot be provided if antenna_nums is also provided.

  • bls (list of tuple, optional) – A list of antenna number tuples (e.g. [(0, 1), (3, 2)]) or a list of baseline 3-tuples (e.g. [(0, 1, ‘xx’), (2, 3, ‘yy’)]) specifying baselines to include when writing data into the file. For length-2 tuples, the ordering of the numbers within the tuple does not matter. For length-3 tuples, the polarization string is in the order of the two antennas. If length-3 tuples are provided, polarizations must be None.

  • ant_str (str, optional) – A string containing information about what antenna numbers and polarizations to include writing data into the file. Can be ‘auto’, ‘cross’, ‘all’, or combinations of antenna numbers and polarizations (e.g. ‘1’, ‘1_2’, ‘1x_2y’). See tutorial for more examples of valid strings and the behavior of different forms for ant_str. If ‘1x_2y,2y_3y’ is passed, both polarizations ‘xy’ and ‘yy’ will be kept for both baselines (1, 2) and (2, 3) to return a valid pyuvdata object. An ant_str cannot be passed in addition to any of antenna_nums, antenna_names, bls args or the polarizations parameters, if it is a ValueError will be raised.

  • frequencies (array_like of float, optional) – The frequencies to include when writing data into the file, each value passed here should exist in the freq_array.

  • freq_chans (array_like of int, optional) – The frequency channel numbers to include writing data into the file.

  • times (array_like of float, optional) – The times to include when writing data into the file, each value passed here should exist in the time_array.

  • polarizations (array_like of int, optional) – The polarizations numbers to include when writing data into the file, each value passed here should exist in the polarization_array.

  • blt_inds (array_like of int, optional) – The baseline-time indices to include when writing data into the file. This is not commonly used.

  • run_check_acceptability (bool) – Option to check acceptable range of the values of parameters before writing the file (the default is True, meaning the acceptable range check will be done).

  • add_to_history (str) – String to append to history before write out. Default is no appending.

read(filename, axis=None, file_type=None, allow_rephase=True, phase_center_radec=None, unphase_to_drift=False, phase_frame='icrs', orig_phase_frame=None, phase_use_ant_pos=False, antenna_nums=None, antenna_names=None, ant_str=None, bls=None, frequencies=None, freq_chans=None, times=None, polarizations=None, blt_inds=None, time_range=None, keep_all_metadata=True, read_metadata=True, read_data=True, phase_type=None, correct_lat_lon=True, use_model=False, data_column='DATA', pol_order='AIPS', data_array_dtype=<class 'numpy.complex128'>, use_cotter_flags=False, correct_cable_len=False, phase_to_pointing_center=False, run_check=True, check_extra=True, run_check_acceptability=True)[source]

Read a generic file into a UVData object.

Parameters
  • filename (str or array_like of str) – The file(s) or list(s) (or array(s)) of files to read from.

  • file_type (str) – One of [‘uvfits’, ‘miriad’, ‘fhd’, ‘ms’, ‘uvh5’] or None. If None, the code attempts to guess what the file type is. For miriad and ms types, this is based on the standard directory structure. For FHD, uvfits and uvh5 files it’s based on file extensions (FHD: .sav, .txt; uvfits: .uvfits; uvh5: .uvh5). Note that if a list of datasets is passed, the file type is determined from the first dataset.

  • axis (str) – Axis to concatenate files along. This enables fast concatenation along the specified axis without the normal checking that all other metadata agrees. This method does not guarantee correct resulting objects. Please see the docstring for fast_concat for details. Allowed values are: ‘blt’, ‘freq’, ‘polarization’. Only used if multiple files are passed.

  • allow_rephase (bool) – Allow rephasing of phased file data so that data from files with different phasing can be combined.

  • phase_center_radec (array_like of float) – The phase center to phase the files to before adding the objects in radians (in the ICRS frame). If set to None and multiple files are read with different phase centers, the phase center of the first file will be used.

  • unphase_to_drift (bool) – Unphase the data from the files before combining them.

  • phase_frame (str) – The astropy frame to phase to. Either ‘icrs’ or ‘gcrs’. ‘gcrs’ accounts for precession & nutation, ‘icrs’ accounts for precession, nutation & abberation. Only used if phase_center_radec is set.

  • orig_phase_frame (str) – The original phase frame of the data (if it is already phased). Used for unphasing, only if unphase_to_drift or phase_center_radec are set. Defaults to using the ‘phase_center_frame’ attribute or ‘icrs’ if that attribute is None.

  • phase_use_ant_pos (bool) – If True, calculate the phased or unphased uvws directly from the antenna positions rather than from the existing uvws. Only used if unphase_to_drift or phase_center_radec are set.

  • antenna_nums (array_like of int, optional) – The antennas numbers to include when reading data into the object (antenna positions and names for the removed antennas will be retained unless keep_all_metadata is False). This cannot be provided if antenna_names is also provided.

  • antenna_names (array_like of str, optional) – The antennas names to include when reading data into the object (antenna positions and names for the removed antennas will be retained unless keep_all_metadata is False). This cannot be provided if antenna_nums is also provided.

  • bls (list of tuple, optional) – A list of antenna number tuples (e.g. [(0, 1), (3, 2)]) or a list of baseline 3-tuples (e.g. [(0, 1, ‘xx’), (2, 3, ‘yy’)]) specifying baselines to include when reading data into the object. For length-2 tuples, the ordering of the numbers within the tuple does not matter. For length-3 tuples, the polarization string is in the order of the two antennas. If length-3 tuples are provided, polarizations must be None.

  • ant_str (str, optional) – A string containing information about what antenna numbers and polarizations to include when reading data into the object. Can be ‘auto’, ‘cross’, ‘all’, or combinations of antenna numbers and polarizations (e.g. ‘1’, ‘1_2’, ‘1x_2y’). See tutorial for more examples of valid strings and the behavior of different forms for ant_str. If ‘1x_2y,2y_3y’ is passed, both polarizations ‘xy’ and ‘yy’ will be kept for both baselines (1, 2) and (2, 3) to return a valid pyuvdata object. An ant_str cannot be passed in addition to any of antenna_nums, antenna_names, bls args or the polarizations parameters, if it is a ValueError will be raised.

  • frequencies (array_like of float, optional) – The frequencies to include when reading data into the object, each value passed here should exist in the freq_array.

  • freq_chans (array_like of int, optional) – The frequency channel numbers to include when reading data into the object. Ignored if read_data is False.

  • times (array_like of float, optional) – The times to include when reading data into the object, each value passed here should exist in the time_array in the file. Cannot be used with time_range.

  • time_range (array_like of float, optional) – The time range in Julian Date to include when reading data into the object, must be length 2. Some of the times in the file should fall between the first and last elements. Cannot be used with times.

  • polarizations (array_like of int, optional) – The polarizations numbers to include when reading data into the object, each value passed here should exist in the polarization_array.

  • blt_inds (array_like of int, optional) – The baseline-time indices to include when reading data into the object. This is not commonly used.

  • keep_all_metadata (bool) – Option to keep all the metadata associated with antennas, even those that do not have data associated with them after the select option.

  • read_metadata (bool) – Deprecated, will be removed in version 2.0, after which metadata will always be read along with header data. Option to read in metadata (times, baselines, uvws) as well as basic header info. Only used if file_type is ‘uvfits’ and read_data is False (metadata will be read if data is read). If file_type is ‘uvfits’ and both read_data and read_metadata are false, only basic header info is read in.

  • read_data (bool) – Read in the data. Only used if file_type is ‘uvfits’, ‘miriad’ or ‘uvh5’. If set to False, only the metadata will be read in. Setting read_data to False results in a metdata only object.

  • phase_type (str, optional) – Option to specify the phasing status of the data. Only used if file_type is ‘miriad’. Options are ‘drift’, ‘phased’ or None. ‘drift’ means the data are zenith drift data, ‘phased’ means the data are phased to a single RA/Dec. Default is None meaning it will be guessed at based on the file contents.

  • correct_lat_lon (bool) – Option to update the latitude and longitude from the known_telescopes list if the altitude is missing. Only used if file_type is ‘miriad’.

  • use_model (bool) – Option to read in the model visibilities rather than the dirty visibilities (the default is False, meaning the dirty visibilities will be read). Only used if file_type is ‘fhd’.

  • data_column (str) – name of CASA data column to read into data_array. Options are: ‘DATA’, ‘MODEL’, or ‘CORRECTED_DATA’. Only used if file_type is ‘ms’.

  • pol_order (str) – Option to specify polarizations order convention, options are ‘CASA’ or ‘AIPS’. Only used if file_type is ‘ms’.

  • data_array_dtype (numpy dtype) – Datatype to store the output data_array as. Must be either np.complex64 (single-precision real and imaginary) or np.complex128 (double- precision real and imaginary). Only used if the datatype of the visibility data on-disk is not ‘c8’ or ‘c16’. Only used if file_type is ‘uvh5’.

  • use_cotter_flags (bool) – Flag to apply cotter flags. Only used if file_type is ‘mwa_corr_fits’.

  • correct_cable_len (bool) – Flag to apply cable length correction. Only used if file_type is ‘mwa_corr_fits’.

  • phase_to_pointing_center (bool) – Flag to phase to the pointing center. Only used if file_type is ‘mwa_corr_fits’. Cannot be set if phase_center_radec is not None.

  • run_check (bool) – Option to check for the existence and proper shapes of parameters after after reading in the file (the default is True, meaning the check will be run). Ignored if read_data is False.

  • check_extra (bool) – Option to check optional parameters as well as required ones (the default is True, meaning the optional parameters will be checked). Ignored if read_data is False.

  • run_check_acceptability (bool) – Option to check acceptable range of the values of parameters after reading in the file (the default is True, meaning the acceptable range check will be done). Ignored if read_data is False.

Raises

ValueError – If the file_type is not set and cannot be determined from the file name. If incompatible select keywords are set (e.g. ant_str with other antenna selectors, times and time_range) or select keywords exclude all data or if keywords are set to the wrong type. If the data are multi source or have multiple spectral windows. If phase_center_radec is not None and is not length 2.

get_ants()[source]

Get the unique antennas that have data associated with them.

Returns

ndarray of int – Array of unique antennas with data associated with them.

get_ENU_antpos(center=False, pick_data_ants=False)[source]

Returns antenna positions in ENU (topocentric) coordinates in units of meters.

Parameters
  • center (bool) – If True, subtract median of array position from antpos

  • pick_data_ants (bool) – If True, return only antennas found in data

Returns

  • antpos (ndarray) – Antenna positions in ENU (topocentric) coordinates in units of meters, shape=(Nants, 3)

  • ants (ndarray) – Antenna numbers matching ordering of antpos, shape=(Nants,)

get_baseline_nums()[source]

Get the unique baselines that have data associated with them.

Returns

ndarray of int – Array of unique baselines with data associated with them.

get_antpairs()[source]

Get the unique antpair tuples that have data associated with them.

Returns

list of tuples of int – list of unique antpair tuples (ant1, ant2) with data associated with them.

get_pols()[source]

Get the polarizations in the data.

Returns

list of str – list of polarizations (as strings) in the data.

get_antpairpols()[source]

Get the unique antpair + pol tuples that have data associated with them.

Returns

list of tuples of int – list of unique antpair + pol tuples (ant1, ant2, pol) with data associated with them.

get_feedpols()[source]

Get the unique antenna feed polarizations in the data.

Returns

list of str – list of antenna feed polarizations (e.g. [‘X’, ‘Y’]) in the data.

Raises

ValueError – If any pseudo-Stokes visibilities are present

antpair2ind(ant1, ant2=None, ordered=True)[source]

Get indices along the baseline-time axis for a given antenna pair.

This will search for either the key as specified, or the key and its conjugate.

Parameters
  • ant1, ant2 (int) – Either an antenna-pair key, or key expanded as arguments, e.g. antpair2ind( (10, 20) ) or antpair2ind(10, 20)

  • ordered (bool) – If True, search for antpair as provided, else search for it and it’s conjugate.

Returns

inds (ndarray of int-64) – indices of the antpair along the baseline-time axis.

get_data(key1, key2=None, key3=None, squeeze='default', force_copy=False)[source]

Get the data corresonding to a baseline and/or polarization.

Parameters
  • key1, key2, key3 (int or tuple of ints) – Identifier of which data to get, can be passed as 1, 2, or 3 arguments or as a single tuple of length 1, 2, or 3. These are collectively called the key.

    If key is length 1:
    if (key < 5) or (type(key) is str):

    interpreted as a polarization number/name, get all data for that pol.

    else:

    interpreted as a baseline number, get all data for that baseline.

    if key is length 2: interpreted as an antenna pair, get all data

    for that baseline.

    if key is length 3: interpreted as antenna pair and pol (ant1, ant2, pol),

    get all data for that baseline, pol. pol may be a string or int.

  • squeeze (str) – string specifying how to squeeze the returned array. Options are: ‘default’: squeeze pol and spw dimensions if possible; ‘none’: no squeezing of resulting numpy array; ‘full’: squeeze all length 1 dimensions.

  • force_copy (bool) – Option to explicitly make a copy of the data.

Returns

ndarray – copy (or if possible, a read-only view) of relevant section of data. If data exists conjugate to requested antenna pair, it will be conjugated before returning.

get_flags(key1, key2=None, key3=None, squeeze='default', force_copy=False)[source]

Get the flags corresonding to a baseline and/or polarization.

Parameters
  • key1, key2, key3 (int or tuple of ints) – Identifier of which data to get, can be passed as 1, 2, or 3 arguments or as a single tuple of length 1, 2, or 3. These are collectively called the key.

    If key is length 1:
    if (key < 5) or (type(key) is str):

    interpreted as a polarization number/name, get all flags for that pol.

    else:

    interpreted as a baseline number, get all flags for that baseline.

    if key is length 2: interpreted as an antenna pair, get all flags

    for that baseline.

    if key is length 3: interpreted as antenna pair and pol (ant1, ant2, pol),

    get all flags for that baseline, pol. pol may be a string or int.

  • squeeze (str) – string specifying how to squeeze the returned array. Options are: ‘default’: squeeze pol and spw dimensions if possible; ‘none’: no squeezing of resulting numpy array; ‘full’: squeeze all length 1 dimensions.

  • force_copy (bool) – Option to explicitly make a copy of the data.

Returns

ndarray – copy (or if possible, a read-only view) of relevant section of flags.

get_nsamples(key1, key2=None, key3=None, squeeze='default', force_copy=False)[source]

Get the nsamples corresonding to a baseline and/or polarization.

Parameters
  • key1, key2, key3 (int or tuple of ints) – Identifier of which data to get, can be passed as 1, 2, or 3 arguments or as a single tuple of length 1, 2, or 3. These are collectively called the key.

    If key is length 1:
    if (key < 5) or (type(key) is str):

    interpreted as a polarization number/name, get all nsamples for that pol.

    else:

    interpreted as a baseline number, get all nsamples for that baseline.

    if key is length 2: interpreted as an antenna pair, get all nsamples

    for that baseline.

    if key is length 3: interpreted as antenna pair and pol (ant1, ant2, pol),

    get all nsamples for that baseline, pol. pol may be a string or int.

  • squeeze (str) – string specifying how to squeeze the returned array. Options are: ‘default’: squeeze pol and spw dimensions if possible; ‘none’: no squeezing of resulting numpy array; ‘full’: squeeze all length 1 dimensions.

  • force_copy (bool) – Option to explicitly make a copy of the data.

Returns

ndarray – copy (or if possible, a read-only view) of relevant section of nsample_array.

get_times(key1, key2=None, key3=None)[source]

Get the times for a given antpair or baseline number.

Meant to be used in conjunction with get_data function.

Parameters

key1, key2, key3 (int or tuple of ints) – Identifier of which data to get, can be passed as 1, 2, or 3 arguments or as a single tuple of length 1, 2, or 3. These are collectively called the key.

If key is length 1:
if (key < 5) or (type(key) is str):

interpreted as a polarization number/name, get all times.

else:

interpreted as a baseline number, get all times for that baseline.

if key is length 2: interpreted as an antenna pair, get all times

for that baseline.

if key is length 3: interpreted as antenna pair and pol (ant1, ant2, pol),

get all times for that baseline.

Returns

ndarray – times from the time_array for the given antpair or baseline.

antpairpol_iter(squeeze='default')[source]

Iterator to get the data for each antpair, polarization combination.

Parameters

squeeze (str) – string specifying how to squeeze the returned array. Options are: ‘default’: squeeze pol and spw dimensions if possible; ‘none’: no squeezing of resulting numpy array; ‘full’: squeeze all length 1 dimensions.

Yields
  • key (tuple) – antenna1, antenna2, and polarization string

  • data (ndarray of complex) – data for the ant pair and polarization specified in key

parse_ants(ant_str, print_toggle=False)[source]

Get antpair and polarization from parsing an aipy-style ant string.

Used to support the the select function. Generates two lists of antenna pair tuples and polarization indices based on parsing of the string ant_str. If no valid polarizations (pseudo-Stokes params, or combinations of [lr] or [xy]) or antenna numbers are found in ant_str, ant_pairs_nums and polarizations are returned as None.

Parameters
  • ant_str (str) – String containing antenna information to parse. Can be ‘all’, ‘auto’, ‘cross’, or combinations of antenna numbers and polarization indicators ‘l’ and ‘r’ or ‘x’ and ‘y’. Minus signs can also be used in front of an antenna number or baseline to exclude it from being output in ant_pairs_nums. If ant_str has a minus sign as the first character, ‘all,’ will be appended to the beginning of the string. See the tutorial for examples of valid strings and their behavior.

  • print_toggle (bool) – Boolean for printing parsed baselines for a visual user check.

Returns

  • ant_pairs_nums (list of tuples of int or None) – List of tuples containing the parsed pairs of antenna numbers, or None if ant_str is ‘all’ or a pseudo-Stokes polarizations.

  • polarizations (list of int or None) – List of desired polarizations or None if ant_str does not contain a polarization specification.

get_redundancies(tol=1.0, use_antpos=False, include_conjugates=False, include_autos=True, conjugate_bls=False)[source]

Get redundant baselines to a given tolerance. This can be used to identify redundant baselines present in the data, or find all possible redundant baselines given the antenna positions.

Parameters
  • tol (float) – Redundancy tolerance in meters (default 1m).

  • use_antpos (bool) – Use antenna positions to find all possible redundant groups for this telescope (default False). The returned baselines are in the ‘u>0’ convention.

  • include_conjugates (bool) – Option to include baselines that are redundant under conjugation. Only used if use_antpos is False.

  • include_autos (bool) – Option to include autocorrelations in the full redundancy list. Only used if use_antpos is True.

  • conjugate_bls (bool) – If using antenna positions, this will conjugate baselines on this object to correspond with those in the returned groups.

Returns

  • baseline_groups (list of lists of int) – List of lists of redundant baseline numbers

  • vec_bin_centers (list of ndarray of float) – List of vectors describing redundant group uvw centers

  • lengths (list of float) – List of redundant group baseline lengths in meters

  • conjugates (list of int, or None, optional) – List of indices for baselines that must be conjugated to fit into their redundant groups. Will return None if use_antpos is True and include_conjugates is True Only returned if include_conjugates is True

Notes

If use_antpos is set, then this function will find all redundant baseline groups for this telescope, under the u>0 antenna ordering convention. If use_antpos is not set, this function will look for redundant groups in the data.

get_antenna_redundancies(*args, **kwargs)[source]

Deprecated – Please use get_redundancies instead.

get_baseline_redundancies(*args, **kwargs)[source]

Deprecated – Please use get_redundancies instead.

compress_by_redundancy(tol=1.0, inplace=True, metadata_only=None, keep_all_metadata=True)[source]

Downselect to only have one baseline per redundant group on the object.

Uses utility functions to find redundant baselines to the given tolerance, then select on those.

Parameters
  • tol (float) – Redundancy tolerance in meters, default is 1.0 corresponding to 1 meter.

  • inplace (bool) – Option to do selection on current object.

  • metadata_only (bool) – Option to only do the select on the metadata. Not allowed if the data_array, flag_array or nsample_array is not None. Note this option has been replaced by an automatic detection of whether the data like arrays are present. The keyword will be deprecated in version 1.6.

  • keep_all_metadata (bool) – Option to keep all the metadata associated with antennas, even those that do not remain after the select option.

Returns

UVData object or None – if inplace is False, return the compressed UVData object

inflate_by_redundancy(tol=1.0, blt_order='time', blt_minor_order=None)[source]

Expand data to full size, copying data among redundant baselines.

Note that this method conjugates baselines to the ‘u>0’ convention in order to inflate the redundancies.

Parameters
  • tol (float) – Redundancy tolerance in meters, default is 1.0 corresponding to 1 meter.

  • blt_order (str) – string specifying primary order along the blt axis (see reorder_blts)

  • blt_minor_order (str) – string specifying minor order along the blt axis (see reorder_blts)

upsample_in_time(max_int_time, blt_order='time', minor_order='baseline', summing_correlator_mode=False, allow_drift=False)[source]

Resample to a shorter integration time.

This method will resample a UVData object such that all data samples have an integration time less than or equal to the max_int_time. The new samples are copied from the original samples (not interpolated).

Parameters
  • max_int_time (float) – Maximum integration time to upsample to in seconds.

  • blt_order (str) – Major baseline ordering for output object. Default is “time”. See the documentation on the reorder_blts method for more info.

  • minor_order (str) – Minor baseline ordering for output object. Default is “baseline”.

  • summing_correlator_mode (bool) – Option to split the flux from the original samples into the new samples rather than duplicating the original samples in all the new samples (undoing an integration rather than an average) to emulate undoing the behavior in some correlators (e.g. HERA).

  • allow_drift (bool) – Option to allow resampling of drift mode data. If this is False, drift mode data will be phased before resampling and then unphased after resampling. Phasing and unphasing can introduce small errors, but resampling in drift mode may result in unexpected behavior.

Returns

None

downsample_in_time(min_int_time, blt_order='time', minor_order='baseline', keep_ragged=True, summing_correlator_mode=False, allow_drift=False)[source]

Resample to a longer integration time.

This method will resample a UVData object such that nearly all data samples have an integration time greater than or equal to the min_int_time. Note that if the integrations for a baseline do not divide evenly into the specified min_int_time, the final integrations for that baseline in the output may have integration times less than min_int_time. This behavior can be controlled with the keep_ragged argument. The new samples are averages of the original samples (not interpolations).

Parameters
  • min_int_time (float) – Minimum integration time to downsample the UVData integration_time to in seconds.

  • blt_order (str) – Major baseline ordering for output object. Default is “time”. See the documentation on the reorder_blts method for more details.

  • minor_order (str) – Minor baseline ordering for output object. Default is “baseline”.

  • keep_ragged (bool) – When averaging baselines that do not evenly divide into min_int_time, keep_ragged controls whether to keep the (summed) integrations corresponding to the remaining samples (keep_ragged=True), or discard them (keep_ragged=False).

  • summing_correlator_mode (bool) – Option to integrate the flux from the original samples rather than average the flux to emulate the behavior in some correlators (e.g. HERA).

  • allow_drift (bool) – Option to allow resampling of drift mode data. If this is False, drift mode data will be phased before resampling and then unphased after resampling. Phasing and unphasing can introduce small errors, but resampling in drift mode may result in unexpected behavior.

Returns

None

resample_in_time(target_time, only_downsample=False, only_upsample=False, blt_order='time', minor_order='baseline', keep_ragged=True, summing_correlator_mode=False, allow_drift=False)[source]

Intelligently upsample or downsample a UVData object to the target time.

Parameters
  • target_time (float) – The target integration time to resample to, in seconds.

  • only_downsample (bool) – Option to only call bda_downsample.

  • only_upsample (bool) – Option to only call bda_upsample.

  • blt_order (str) – Major baseline ordering for output object. Default is “time”. See the documentation on the reorder_blts method for more details.

  • minor_order (str) – Minor baseline ordering for output object. Default is “baseline”.

  • keep_ragged (bool) – When averaging baselines that do not evenly divide into min_int_time, keep_ragged controls whether to keep the (summed) integrations corresponding to the remaining samples (keep_ragged=True), or discard them (keep_ragged=False). Note this option only applies to the bda_downsample method.

  • summing_correlator_mode (bool) – Option to integrate or split the flux from the original samples rather than average or duplicate the flux from the original samples to emulate the behavior in some correlators (e.g. HERA).

  • allow_drift (bool) – Option to allow resampling of drift mode data. If this is False, drift mode data will be phased before resampling and then unphased after resampling. Phasing and unphasing can introduce small errors, but resampling in drift mode may result in unexpected behavior.

Returns

None

remove_eq_coeffs()[source]

Remove equalization coefficients from the data.

Some telescopes, e.g. HERA, apply per-antenna, per-frequency gain coefficients as part of the signal chain. These are stored in the eq_coeffs attribute of the object. This method will remove them, so that the data are in “unnormalized” raw units.

Parameters

None

Returns

None

Raises

ValueError – Raised if eq_coeffs or eq_coeffs_convention are not defined on the object, or if eq_coeffs_convention is not one of “multiply” or “divide”.