Developer Docs

Documentation for all the under-the-hood classes and functions that most users won’t need to interact with.

Base Classes

These classes are the under-the-hood classes that provide much of the infrastructure for pyuvdata’s user classes.

UVParameter is the base class for the attributes on pyuvdata’s user classes, allowing the attributes to carry information like expected type and shape, acceptable values or ranges and tolerances. We also have some type specific parameter objects (e.g. for angles and earth locations) with extra functionality.

UVBase is the base class for pyuvdata’s user classes which has the common infrastructure to turn the UVParameter attributes into properties and check the attribute shapes and values.

class pyuvdata.parameter.UVParameter(name, required=True, value=None, spoof_val=None, form=(), description='', expected_type=<class 'int'>, acceptable_vals=None, acceptable_range=None, tols=(1e-05, 1e-08))[source]

Data and metadata objects for interferometric data sets.

name

The name of the attribute. Used as the associated property name in classes based on UVBase.

Type

str

required

Flag indicating whether this is required metadata for the class with this UVParameter as an attribute. Default is True.

Type

bool

value

The value of the data or metadata.

spoof_val

A fake value that can be assigned to a non-required UVParameter if the metadata is required for a particular file-type. This is not an attribute of required UVParameters.

form

Either ‘str’ or a tuple giving information about the expected shape of the value. Elements of the tuple may be the name of other UVParameters that indicate data shapes.

Form examples:
  • ‘str’: a string value

  • (‘Nblts’, 3): the value should be an array of shape:

    Nblts (another UVParameter name), 3

Type

‘str’ or tuple

description

Description of the data or metadata in the object.

Type

str

expected_type

The type that the data or metadata should be. Default is np.int or str if form is ‘str’

acceptable_vals

List giving allowed values for elements of value.

Type

list, optional

acceptable_range

Tuple giving a range of allowed magnitudes for elements of value.

Type

2-tuple, optional

tols

Tolerances for testing the equality of UVParameters. Either a single absolute value or a tuple of relative and absolute values to be used by np.isclose()

Type

float or 2-tuple of float

apply_spoof()[source]

Set value to spoof_val for non-required UVParameters.

expected_shape(uvbase)[source]

Get the expected shape of the value based on the form.

Parameters

uvbase (object) – Object with this UVParameter as an attribute. Needed because the form can refer to other UVParameters on this object.

Returns

tuple – The expected shape of the value.

check_acceptability()[source]

Check that values are acceptable.

class pyuvdata.parameter.AngleParameter(name, required=True, value=None, spoof_val=None, form=(), description='', expected_type=<class 'int'>, acceptable_vals=None, acceptable_range=None, tols=(1e-05, 1e-08))[source]

Subclass of UVParameter for Angle type parameters.

Adds extra methods for conversion to & from degrees (used by UVBase objects for _degrees properties associated with these parameters).

degrees()[source]

Get value in degrees.

set_degrees(degree_val)[source]

Set value in degrees.

Parameters

degree_val (float) – Value in degrees to use to set the value attribute.

class pyuvdata.parameter.LocationParameter(name, required=True, value=None, spoof_val=None, description='', acceptable_range=6350000.0, 6390000.0, tols=0.001)[source]

Subclass of UVParameter for Earth location type parameters.

Adds extra methods for conversion to & from lat/lon/alt in radians or degrees (used by UVBase objects for _lat_lon_alt and _lat_lon_alt_degrees properties associated with these parameters).

lat_lon_alt()[source]

Get value in (latitude, longitude, altitude) tuple in radians.

set_lat_lon_alt(lat_lon_alt)[source]

Set value from (latitude, longitude, altitude) tuple in radians.

Parameters

lat_lon_alt (3-tuple of float) – Tuple with the latitude (radians), longitude (radians) and altitude (meters) to use to set the value attribute.

lat_lon_alt_degrees()[source]

Get value in (latitude, longitude, altitude) tuple in degrees.

set_lat_lon_alt_degrees(lat_lon_alt_degree)[source]

Set value from (latitude, longitude, altitude) tuple in degrees.

Parameters

lat_lon_alt (3-tuple of float) – Tuple with the latitude (degrees), longitude (degrees) and altitude (meters) to use to set the value attribute.

check_acceptability()[source]

Check that vector magnitudes are in range.

class pyuvdata.uvbase.UVBase[source]

Base class for objects with UVParameter attributes.

This class is intended to be subclassed and its init method should be called in the subclass init after all associated UVParameter attributes are defined. The init method of this base class creates properties (named using UVParameter.name) from all the UVParameter attributes on the subclass. AngleParameter and LocationParameter attributes also have extra convenience properties defined:

AngleParameter:

UVParameter.name+’_degrees’

LocationParameter:

UVParameter.name+’_lat_lon_alt’ UVParameter.name+’_lat_lon_alt_degrees’

prop_fget(param_name)[source]

Getter method for UVParameter properties.

prop_fset(param_name)[source]

Setter method for UVParameter properties.

degree_prop_fget(param_name)[source]

Degree getter method for AngleParameter properties.

degree_prop_fset(param_name)[source]

Degree setter method for AngleParameter properties.

lat_lon_alt_prop_fget(param_name)[source]

Lat/lon/alt getter method for LocationParameter properties.

lat_lon_alt_prop_fset(param_name)[source]

Lat/lon/alt setter method for LocationParameter properties.

lat_lon_alt_degrees_prop_fget(param_name)[source]

Lat/lon/alt degree getter method for LocationParameter properties.

lat_lon_alt_degrees_prop_fset(param_name)[source]

Lat/lon/alt degree setter method for LocationParameter properties.

required()[source]

Iterate over all required UVParameter attributes.

extra()[source]

Iterate over all non-required UVParameter attributes.

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

Check that required parameters exist and have the correct shapes.

Optionally, check that the values are acceptable.

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

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

  • ignore_requirements (bool) – Do not error if a required parameter isn’t set. This allows the user to run the shape/acceptability checks on parameters in a partially-defined UVData object.

copy()[source]

Make and return a copy of the object.

File Type Specific Classes

These classes inherit from pyuvdata’s user classes and hold the file type specific code. The read and write methods on the user classes convert between the user classes and the file-specific classes automatically as needed, so users generally do not need to interact with these classes, but developers may need to.

class pyuvdata.uvdata.fhd.FHD[source]

Defines a FHD-specific subclass of UVData for reading FHD save files.

This class should not be interacted with directly, instead use the read_fhd method on the UVData class.

read_fhd(filelist, use_model=False, background_lsts=True, read_data=True, 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. An obs file is also required if read_data is False.

  • 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).

  • background_lsts (bool) – When set to True, the lst_array is calculated in a background thread.

  • read_data (bool) – Read in the visibility, nsample and flag data. If set to False, only the metadata will be read in. Setting read_data to False results in a metadata only object. If read_data is False, an obs file must be included in the filelist. Note that if read_data is False, Npols is derived from the obs file and reflects the number of polarizations used in the FHD run. If read_data is True, Npols is given by the number of visibility data files provided in filelist.

  • 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 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.

class pyuvdata.uvdata.miriad.Miriad[source]

Defines a Miriad-specific subclass of UVData for reading and writing Miriad files.

This class should not be interacted with directly, instead use the read and write_miriad methods on the UVData class.

read_miriad(filepath, 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, background_lsts=True)[source]

Read in data from a miriad file.

Parameters
  • filepath (str) – The miriad root directory to read from.

  • 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 uvws, times, visibility and flag data. If set to False, only the metadata that can be read quickly (without reading the data) will be read in. For Miriad, some of the normally required metadata are not fast to read in (e.g. uvws, times) so will not be read in if this keyword is False. Therefore, 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.

  • background_lsts (bool) – When set to True, the lst_array is calculated in a background thread.

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.

class pyuvdata.uvdata.ms.MS[source]

Defines a class for reading and writing casa measurement sets.

This class should not be interacted with directly, instead use the read_ms method on the UVData class.

ms_required_extra

Names of optional UVParameters that are required for MS

Type

list of str

write_ms()[source]

Write ms: Not yet supported.

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

Read in a casa measurement set.

Parameters
  • filepath (str) – The measurement set root directory to read from.

  • 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).

  • background_lsts (bool) – When set to True, the lst_array is calculated in a background thread.

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.

class pyuvdata.uvdata.mwa_corr_fits.MWACorrFITS[source]

UVData subclass for reading MWA correlator fits files.

This class should not be interacted with directly; instead use the read_mwa_corr_fits method on the UVData class.

correct_cable_length(cable_lens)[source]

Apply a cable length correction to the data array.

Parameters
  • cable_lens (list of strings)

  • A list of strings containing the cable lengths for each antenna.

flag_init(num_fine_chan, edge_width=80000.0, start_flag=2.0, end_flag=2.0, flag_dc_offset=True)[source]

Apply routine flagging to the MWA Correlator FITS file data.

Includes options to flag the coarse channel edges, beginning and end of obs, as well as the center fine channel of each coarse channel.

Parameters
  • edge_width (float) – The width to flag on the edge of each coarse channel, in hz. Set to 0 for no edge flagging.

  • start_flag (float) – The number of seconds to flag at the beginning of the observation. Set to 0 for no flagging.

  • end_flag (floats) – The number of seconds to flag at the end of the observation. Set to 0 for no flagging.

  • flag_dc_offset (bool) – Set to True to flag the center fine channel of each coarse channel.

Raises

ValueError – If edge_width is not an integer multiple of the channel_width of the data (0 also acceptable). If start_flag is not an integer multiple of the integration time (0 also acceptable). If end_flag is not an integer multiple of the integration time (0 also acceptable).

read_mwa_corr_fits(filelist, use_cotter_flags=False, correct_cable_len=False, phase_to_pointing_center=False, flag_init=True, edge_width=80000.0, start_flag=2.0, end_flag=2.0, flag_dc_offset=True, background_lsts=True, read_data=True, data_array_dtype=<class 'numpy.complex64'>, nsample_array_dtype=<class 'numpy.float32'>, 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. Can also be a list of lists to read multiple data sets.

  • 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.

  • flag_init (bool) – Set to True in order to do routine flagging of coarse channel edges, start or end integrations, or the center fine channel of each coarse channel. See associated keywords.

  • edge_width (float) – Only used if flag_init is True. The width to flag on the edge of each coarse channel, in hz. Errors if not equal to integer multiple of channel_width. Set to 0 for no edge flagging.

  • start_flag (float) – Only used if flag_init is True. The number of seconds to flag at the beginning of the observation. Set to 0 for no flagging. Errors if not equal to an integer multiple of the integration time.

  • end_flag (floats) – Only used if flag_init is True. The number of seconds to flag at the end of the observation. Set to 0 for no flagging. Errors if not equal to an integer multiple of the integration time.

  • flag_dc_offset (bool) – Only used if flag_init is True. Set to True to flag the center fine channel of each coarse channel.

  • background_lsts (bool) – When set to True, the lst_array is calculated in a background thread.

  • read_data (bool) – Read in the visibility, nsample and flag data. If set to False, only the metadata will be read in. Setting read_data to False results in a metadata only object.

  • 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).

  • nsample_array_dtype (numpy dtype) – Datatype to store the output nsample_array as. Must be either np.float64 (double-precision), np.float32 (single-precision), or np.float16 (half-precision). Half-precision is only recommended for cases where no sampling or averaging of baselines will occur, because round-off errors can be quite large (~1e-3).

  • 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.

class pyuvdata.uvdata.uvfits.UVFITS[source]

Defines a uvfits-specific subclass of UVData for reading and writing uvfits.

This class should not be interacted with directly, instead use the read_uvfits and write_uvfits methods on the UVData class.

uvfits_required_extra

Names of optional UVParameters that are required for uvfits.

Type

list of str

read_uvfits(filename, 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, read_data=True, run_check=True, check_extra=True, run_check_acceptability=True, keep_all_metadata=True, background_lsts=True)[source]

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

Supports reading only selected portions of the data.

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

  • 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.

  • 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 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, nsample and flag data. If set to False, only the metadata will be read in. Setting read_data to False results in a metadata only object.

  • 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.

  • background_lsts (bool) – When set to True, the lst_array is calculated in a background thread.

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 before writing the file.

  • 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 before writing the file.

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.

class pyuvdata.uvdata.uvh5.UVH5[source]

A class for UVH5 file objects.

This class defines an HDF5-specific subclass of UVData for reading and writing UVH5 files. This class should not be interacted with directly, instead use the read_uvh5 and write_uvh5 methods on the UVData class.

read_uvh5(filename, 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, read_data=True, run_check=True, check_extra=True, run_check_acceptability=True, data_array_dtype=<class 'numpy.complex128'>, keep_all_metadata=True, multidim_index=False, background_lsts=True)[source]

Read in data from a UVH5 file.

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

  • 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. 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 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, nsample and flag data. If set to False, only the metadata will be read in. Setting read_data to False results in a metadata only object.

  • 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.

  • multidim_index (bool) – If True, attempt to index the HDF5 dataset simultaneously along all data axes. Otherwise index one axis at-a-time. This only works if data selection is sliceable along all but one axis. If indices are not well-matched to data chunks, this can be slow.

  • background_lsts (bool) – When set to True, the lst_array is calculated in a background thread.

Returns

None

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, chunks=True, data_compression=None, flags_compression='lzf', nsample_compression='lzf', data_write_dtype=None, add_to_history=None)[source]

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

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

  • run_check (bool) – Option to check for the existence and proper shapes of parameters before writing the file.

  • 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 before writing the file.

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

  • chunks (tuple or bool) – h5py.create_dataset chunks keyword. Tuple for chunk shape, True for auto-chunking, None for no chunking. Default is True.

  • data_compression (str) – HDF5 filter to apply when writing the data_array. Default is None (no filter/compression). Dataset must be chunked.

  • flags_compression (str) – HDF5 filter to apply when writing the flags_array. Default is the LZF filter. Dataset must be chunked.

  • nsample_compression (str) – HDF5 filter to apply when writing the nsample_array. Default is the LZF filter. Dataset must be chunked.

  • data_write_dtype (numpy dtype) – The datatype of output visibility data. If ‘None’, then the same datatype as data_array will be used. The user may specify ‘c8’ for single-precision floats or ‘c16’ for double-presicion. 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.

Returns

None

Raises

IOError – If the file located at filename already exists and clobber=False, an IOError is raised.

Notes

The HDF5 library allows for the application of “filters” when writing data, which can provide moderate to significant levels of compression for the datasets in question. Testing has shown that for some typical cases of UVData objects (empty/sparse flag_array objects, and/or uniform nsample_arrays), the built-in LZF filter provides significant compression for minimal computational overhead.

Note that for typical HERA data files written after mid-2020, the bitshuffle filter was applied to the data_array. Because of the lack of portability, it is not included as an option here; in the future, it may be added. Note that as long as bitshuffle is installed on the system in a way that h5py can find it, no action needs to be taken to _read_ a data_array encoded with bitshuffle (or an error will be raised).

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

Initialize a UVH5 file on disk to be written to in parts.

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

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

  • chunks (tuple or bool) – h5py.create_dataset chunks keyword. Tuple for chunk shape, True for auto-chunking, None for no chunking. Default is True.

  • data_compression (str) – HDF5 filter to apply when writing the data_array. Default is None (no filter/compression). Dataset must be chunked.

  • flags_compression (str) – HDF5 filter to apply when writing the flags_array. Default is the LZF filter. Dataset must be chunked.

  • nsample_compression (str) – HDF5 filter to apply when writing the nsample_array. Default is the LZF filter. Dataset must be chunked.

  • data_write_dtype (str or numpy dtype) – The datatype of output visibility data. If ‘None’, then double- precision floats will be used. The user may specify ‘c8’ for single-precision floats or ‘c16’ for double-presicion. 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.

Returns

None

Raises

IOError – If the file located at filename already exists and clobber=False, an IOError is raised.

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.

The HDF5 library allows for the application of “filters” when writing data, which can provide moderate to significant levels of compression for the datasets in question. Testing has shown that for some typical cases of UVData objects (empty/sparse flag_array objects, and/or uniform nsample_arrays), the built-in LZF filter provides significant compression for minimal computational overhead.

Note that for typical HERA data files written after mid-2018, the bitshuffle filter was applied to the data_array. Because of the lack of portability, it is not included as an option here; in the future, it may be added. Note that as long as bitshuffle is installed on the system in a way that h5py can find it, no action needs to be taken to _read_ a data_array encoded with bitshuffle (or an error will be raised).

write_uvh5_part(filename, data_array, flag_array, nsample_array, check_header=True, 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_acceptability=True, add_to_history=None)[source]

Write out a part of a UVH5 file that has been previously initialized.

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

  • data_array (array of float) – 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.

  • flag_array (array of bool) – 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 (array of float) – The nsample array to write to disk. A check is done to ensure that the dimensions fo 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.

  • run_check_acceptability (bool) – If check_header, additional option to check acceptable range of the values of parameters after reading in the file.

  • antenna_nums (array_like of int, optional) – The antennas numbers to include when writing data into the object (antenna positions and names for the excluded 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 object (antenna positions and names for the excluded antennas will be retained). This cannot be provided if antenna_nums is also provided.

  • bls (list of tuples, 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 write to 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, the polarizations argument below must be None.

  • ant_str (str, optional) – A string containing information about what antenna numbers and polarizations to include when writing 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 written for both baselines (1, 2) and (2, 3) to reflect a valid pyuvdata object. An ant_str cannot be passed in addition to any of the above antenna args or the polarizations arg.

  • frequencies (array_like of float, optional) – The frequencies to include when writing data to the file.

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

  • times (array_like of float, optional) – The times in Julian Day to include when writing data to the file.

  • time_range (array_like of float, optional) – The time range in Julian Date to include when writing data to the file, 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 to include when writing data to the file.

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

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

Returns

None

Raises

AssertionError – An AsserionError is raised if: (1) the location specified by filename does not exist; (2) the data_array, flag_array, and nsample_array do not all have the same shape; (3) the shape of the data arrays do not correspond to the sizes specified by the properties to write out.

Notes

When partially writing out data, this function should be called after calling initialize_uvh5_file. The same filename is passed in, with an optional check to ensure that the object’s metadata in-memory matches the header on-disk. See the tutorial for a worked example.

class pyuvdata.uvcal.calfits.CALFITS[source]

Defines a calfits-specific class for reading and writing calfits files.

This class should not be interacted with directly, instead use the read_calfits and write_calfits methods on the UVCal class.

write_calfits(filename, run_check=True, check_extra=True, run_check_acceptability=True, clobber=False)[source]

Write the data to a calfits file.

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

  • run_check (bool) – Option to check for the existence and proper shapes of parameters before writing the file.

  • 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 before writing the file.

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

read_calfits(filename, run_check=True, check_extra=True, run_check_acceptability=True)[source]

Read data from a calfits file.

Parameters
  • filename (str) – The calfits file to read from.

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

  • 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 reading in the file.

class pyuvdata.uvcal.fhd_cal.FHDCal[source]

Defines a FHD-specific subclass of UVCal for reading FHD calibration save files.

This class should not be interacted with directly, instead use the read_fhd_cal method on the UVCal class.

read_fhd_cal(cal_file, obs_file, settings_file=None, raw=True, extra_history=None, run_check=True, check_extra=True, run_check_acceptability=True)[source]

Read data from an FHD cal.sav file.

Parameters
  • cal_file (str) – The cal.sav file to read from.

  • obs_file (str) – The obs.sav file to read from.

  • settings_file (str, optional) – The settings_file to read from. Optional, but very useful for provenance.

  • raw (bool) – Option to use the raw (per antenna, per frequency) solution or to use the fitted (polynomial over phase/amplitude) solution. Default is True (meaning use the raw solutions).

  • extra_history (str or list of str, optional) – String(s) to add to the object’s history parameter.

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

  • 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 reading in the file.

class pyuvdata.uvbeam.beamfits.BeamFITS[source]

Defines a fits-specific subclass of UVBeam for reading and writing beamfits files.

This class should not be interacted with directly, instead use the read_beamfits and write_beamfits methods on the UVBeam class.

The beamfits format supports regularly gridded or healpix beam files. The format defined here for healpix beams is not compatible with true healpix formats because it needs to support multiple dimensions (e.g. polarization, frequency, efield vectors).

read_beamfits(filename, run_check=True, check_extra=True, run_check_acceptability=True)[source]

Read the data from a beamfits file.

Parameters
  • filename (str) – The beamfits file to read from.

  • run_check (bool) – Option to check for the existence and proper shapes of required parameters after reading in the file.

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

  • run_check_acceptabilit (bool) – Option to check acceptable range of the values of required parameters after reading in the file.

write_beamfits(filename, run_check=True, check_extra=True, run_check_acceptability=True, clobber=False)[source]

Write the data to a beamfits file.

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

  • run_check (bool) – Option to check for the existence and proper shapes of required parameters before writing the file.

  • 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 required parameters before writing the file.

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

class pyuvdata.uvbeam.cst_beam.CSTBeam[source]

Defines a CST-specific subclass of UVBeam for reading CST text files.

This class should not be interacted with directly, instead use the read_cst_beam method on the UVBeam class.

name2freq(fname)[source]

Extract frequency from the filename.

Assumes the file name contains a substring with the frequency channel in MHz that the data represents. e.g. “HERA_Sim_120.87MHz.txt” should yield 120.87e6

Parameters

fname (str) – Filename to parse.

Returns

float – Frequency extracted from filename in Hz.

read_cst_beam(filename, beam_type='power', feed_pol='x', rotate_pol=True, frequency=None, telescope_name=None, feed_name=None, feed_version=None, model_name=None, model_version=None, history='', x_orientation=None, reference_impedance=None, extra_keywords=None, run_check=True, check_extra=True, run_check_acceptability=True)[source]

Read in data from a cst file.

Parameters
  • filename (str) – The cst file to read from.

  • beam_type (str) – What beam_type to read in (‘power’ or ‘efield’).

  • feed_pol (str) – The feed or polarization or list of feeds or polarizations the files correspond to. Defaults to ‘x’ (meaning x for efield or xx for power beams).

  • rotate_pol (bool) – If True, assume the structure in the simulation is symmetric under 90 degree rotations about the z-axis (so that the y polarization can be constructed by rotating the x polarization or vice versa). Default: True if feed_pol is a single value or a list with all the same values in it, False if it is a list with varying values.

  • frequency (float or list of float) – The frequency or list of frequencies corresponding to the filename(s). This is assumed to be in the same order as the files. If not passed, the code attempts to parse it from the filenames.

  • telescope_name (str) – The name of the telescope corresponding to the filename(s).

  • feed_name (str) – The name of the feed corresponding to the filename(s).

  • feed_version (str) – The version of the feed corresponding to the filename(s).

  • model_name (str) – The name of the model corresponding to the filename(s).

  • model_version (str) – The version of the model corresponding to the filename(s).

  • history (str) – A string detailing the history of the filename(s).

  • x_orientation (str, optional) – Orientation of the physical dipole corresponding to what is labelled as the x polarization. Options are “east” (indicating east/west orientation) and “north” (indicating north/south orientation)

  • reference_impedance (float, optional) – The reference impedance of the model(s).

  • extra_keywords (dict, optional) – A dictionary containing any extra_keywords.

  • run_check (bool) – Option to check for the existence and proper shapes of required parameters after reading in the file.

  • 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 required parameters after reading in the file.

class pyuvdata.uvbeam.mwa_beam.MWABeam[source]

Defines an MWA-specific subclass of UVBeam for representing MWA beams.

This class should not be interacted with directly, instead use the read_mwa_beam method on the UVBeam class.

This is based on https://github.com/MWATelescope/mwa_pb/ but we don’t import that module because it’s not python 3 compatible

read_mwa_beam(h5filepath, delays=None, amplitudes=None, pixels_per_deg=5, freq_range=None, run_check=True, check_extra=True, run_check_acceptability=True)[source]

Read in the full embedded element MWA beam.

Parameters
  • h5filepath (str) – path to input h5 file containing the MWA full embedded element spherical harmonic modes. Download via wget http://cerberus.mwa128t.org/mwa_full_embedded_element_pattern.h5

  • delays (array of ints) – Array of MWA beamformer delay steps. Should be shape (n_pols, n_dipoles).

  • amplitudes (array of floats) – Array of dipole amplitudes, these are absolute values (i.e. relatable to physical units). Should be shape (n_pols, n_dipoles).

  • pixels_per_deg (float) – Number of theta/phi pixels per degree. Sets the resolution of the beam.

  • freq_range (array_like of float) – Range of frequencies to include in Hz, defaults to all available frequencies. Must be length 2.

  • run_check (bool) – Option to check for the existence and proper shapes of required parameters after reading in the file.

  • 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 required parameters after reading in the file.

Returns

None

Raises

ValueError – If the amplitudes or delays are the wrong shape or there are delays greater than 32 or delays are not integer types. If the frequency range doesn’t include any available frequencies.

Functions

pyuvdata.uvdata.fhd.get_fhd_history(settings_file, return_user=False)[source]

Small function to get the important history from an FHD settings text file.

Includes information about the command line call, the user, machine name and date

Parameters
  • settings_file (str) – FHD settings file name

  • return_user (bool) – optionally return the username who ran FHD

Returns

  • history (str) – string of history extracted from the settings file

  • user (str) – Only returned if return_user is True

pyuvdata.uvbeam.mwa_beam.P1sin(nmax, theta)[source]

Create the Legendre function flavors for FF expansion using spherical waves.

Note this is not vectorized so is a bit slow, but it handles the special case of theta = 0 and pi. We primarily use the vectorized version (P1sin_array), but call this to handle the special cases.

See: Calculating Far-Field Radiation Based on FEKO Spherical Wave Coefficients, draft 10 June 2015. Available at pyuvdata/docs/references/Far_field_spherical_FEKO_draft2.pdf This memo gives a full description of the equations implemented here, including descriptions of the approximations and numerical approaches used. In line comments below are helpful reminders, but see the memo for the full detail. Also see Sokolowski, M. et al, “Calibration and Stokes Imaging with Full Embedded Element Primary Beam Model for the Murchison Widefield Array”, PASA, 2017 (10.1017/pasa.2017.54) for details specific to the MWA.

Parameters
  • nmax (int) – Maximum n from FEKO Q1mn and Q2mn, n must be >=1

  • theta (float) – The argument of the cosine or sine function used in the associated Legendre functions, in radians.

Returns

  • P_sin (array of float) – P_{n}^{abs(m)}(cos(theta))/sin(theta) with FEKO order M,N. Shape (nmax ** 2 + 2 * nmax).

  • P1 (array of float) – P_{n}^{abs(m)+1}(cos(theta)) with FEKO order M,N. Shape (nmax ** 2 + 2 * nmax).

pyuvdata.uvbeam.mwa_beam.P1sin_array(nmax, theta)[source]

Calculate P^abs(m)_n(cos(theta))/sin(theta) and P^(abs(m)+1)_n(cos(theta)).

Similar to the “P1sin” function, but calculates for all theta in one go. At the end of the function, patches are made using the original P1sin function to solve the 0/0 issue.

Parameters
  • nmax (int) – Maximum n from FEKO Q1mn and Q2mn, n must be >=1

  • theta (array of float) – The argument of the cosine or sine functions used in the associated Legendre functions, in radians.

Returns

  • P_sin (array of float) – P_{n}^{abs(m)}(cos(theta))/sin(theta) with FEKO order M,N. Shape (nmax ** 2 + 2 * nmax, theta.size).

  • P1 (array of float) – P_{n}^{abs(m)+1}(cos(theta)) with FEKO order M,N. Shape (nmax ** 2 + 2 * nmax, theta.size).

pyuvdata.uvflag.uvflag.and_rows_cols(waterfall)[source]

Perform logical and over rows and cols of a waterfall.

For a 2D flag waterfall, flag pixels only if fully flagged along time and/or frequency

Parameters

waterfall (2D boolean array of shape (Ntimes, Nfreqs))

Returns

wf (2D array) – A 2D array (size same as input) where only times/integrations that were fully flagged are flagged.

pyuvdata.uvflag.uvflag.lst_from_uv(uv)[source]

Calculate the lst_array for a UVData or UVCal object.

Parameters

uv (a UVData or UVCal object.) – Object from which lsts are calculated

Returns

lst_array (array of float) – lst_array corresponding to time_array and at telescope location. Units are radian.

pyuvdata.uvflag.uvflag.flags2waterfall(uv, flag_array=None, keep_pol=False)[source]

Convert a flag array to a 2D waterfall of dimensions (Ntimes, Nfreqs).

Averages over baselines and polarizations (in the case of visibility data), or antennas and jones parameters (in case of calibrationd data).

Parameters
  • uv (A UVData or UVCal object) – Object defines the times and frequencies, and supplies the flag_array to convert (if flag_array not specified)

  • flag_array (Optional,) – flag array to convert instead of uv.flag_array. Must have same dimensions as uv.flag_array.

  • keep_pol (bool) – Option to keep the polarization axis intact.

Returns

waterfall (2D array or 3D array) – Waterfall of averaged flags, for example fraction of baselines which are flagged for every time and frequency (in case of UVData input) Size is (Ntimes, Nfreqs) or (Ntimes, Nfreqs, Npols).

aipy extracts

Module for low-level interface to MIRIAD files.

This module extracts some Python code from AIPY used in our MIRIAD I/O routines. It was copied from AIPY commit 6cb5a70876f33dccdd68d4063b076f8d42d9edae, then reformatted. The only items used by pyuvdata are uv_selector and UV.

pyuvdata.uvdata.aipy_extracts.uv_selector(uv, ants=- 1, pol_str=- 1)[source]

Call select on a Miriad object with string arguments for antennas and polarizations.

Parameters
  • uv (UV object) – Miriad data set object

  • ants (str) – string to select antennas or baselines, e.g. ‘all’, ‘auto’, ‘cross’, ‘0,1,2’, or ‘0_1,0_2’

  • pol_str (str) – polarizations to select, e.g. ‘xx’, ‘yy’, ‘xy’, ‘yx’

Returns

None

class pyuvdata.uvdata.aipy_extracts.UV(filename, status='old', corrmode='r')[source]

Top-level interface to a Miriad UV data set.

variables()[source]

Get the list of available variables.

Returns

list of str – list of available variables

items()[source]

Get the list of available header items.

Returns

list of str – list of available header items

select(name, n1, n2, include=True)[source]

Choose which data are returned by read().

Parameters
  • name (str) – This can be: ‘decimate’, ‘time’, ‘antennae’, ‘visibility’, ‘uvrange’, ‘pointing’, ‘amplitude’, ‘window’, ‘or’, ‘dra’, ‘ddec’, ‘uvnrange’, ‘increment’, ‘ra’, ‘dec’, ‘and’, ‘clear’, ‘on’, ‘polarization’, ‘shadow’, ‘auto’, ‘dazim’, ‘delev’

  • n1, n2 (int) – Generally this is the range of values to select. For ‘antennae’, this is the two antennae pair to select (indexed from 0); a -1 indicates ‘all antennae’. For ‘decimate’, n1 is every Nth integration to use, and n2 is which integration within a block of N to use. For ‘shadow’, a zero indicates use ‘antdiam’ variable. For ‘on’, ‘window’, ‘polarization’, ‘increment’, ‘shadow’ only p1 is used. For ‘and’, ‘or’, ‘clear’, ‘auto’ p1 and p2 are ignored.

  • include (bool) – If true, the data is selected. If false, the data is discarded. Ignored for ‘and’, ‘or’, ‘clear’.

read(raw=False)[source]

Return the next data record.

Calling this function causes variables to change to reflect the record which this function returns.

Parameters

raw (bool) – if True data and flags are returned seperately

Returns

  • preamble (tuple) – (uvw, t, (i,j)), where uvw is an array of u,v,w, t is the Julian date, and (i,j) is an antenna pair

  • data (ndarray or masked array) – ndarray if raw is True, otherwise a masked array

  • flags (ndarray) – only returned if raw is True

all_data(raw=False)[source]

Provide an iterator over preamble, data.

Allows constructs like: for preamble, data in uv.all_data(): ....

Parameters

raw (bool) – If True data and flags are returned seperately.

Returns

  • preamble (tuple) – (uvw, t, (i,j)), where uvw is an array of u,v,w, t is the Julian date, and (i,j) is an antenna pair

  • data (ndarray or masked array of complex) – ndarray if raw is True, otherwise a masked array

  • flags (ndarray) – only returned if raw is True

write(preamble, data, flags=None)[source]

Write the next data record.

Parameters
  • preamble (tuple) – (uvw, t, (i,j)), where uvw is an array of u,v,w, t is the Julian date, and (i,j) is an antenna pair

  • data (masked array of complex) – spectra for this record

init_from_uv(uv, override={}, exclude=[])[source]

Initialize header items and variables from another UV.

Those in override will be overwritten by override[k], and tracking will be turned off (meaning they will not be updated in pipe()). Those in exclude are omitted completely.

Parameters
  • uv (UV object) – Miriad data set object to initialize from

  • override (dict) – variables with values to overwrite

  • exclude (list) – list of variable to exclude

pipe(uv, mfunc=<function _uv_pipe_default_action>, append2hist='', raw=False)[source]

Pipe in data from another UV.

Uses the function mfunc(uv, preamble, data), which should return (preamble, data). If mfunc is not provided, the dataset will just be cloned, and if the returned data is None, it will be omitted.

Parameters
  • uv (UV object) – Miriad data set object to pipe from

  • mfunc (function) – function that defines how the data are piped. mfunc(uv, preamble, data) should return (preamble, data). Default is _uv_pipe_default_action which just clones the dataset.

  • append2hist (str) – string to append to history

  • raw (bool) – if True data and flags are piped seperately

add_var(name, var_type)[source]

Add a variable of the specified type to a UV file.

Parameters
  • name (str) – name of header item to add

  • var_type (str) – string indicating the variable type (e.g. ‘a’, ‘i’, ‘d’)