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

A string giving the name of the attribute. Used as the associated property name in classes based on UVBase.

required

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

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.

Examples

‘str’: a string value

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

description

A string description of the data or metadata in the object.

expected_type

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

acceptable_vals

Optional. List giving allowed values for elements of value.

acceptable_range

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

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()

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 with this UVParameter as an attribute. Needed because the form can refer to other UVParameters on this object.

Returns

The expected shape of the value.

check_acceptability()[source]

Check that values are acceptable.

class pyuvdata.parameter.AntPositionParameter(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 antenna positions.

Overrides apply_spoof method to generate an array of the correct shape based on the number of antennas on the object with this UVParameter as an attribute.

apply_spoof(uvbase, antnum_name)[source]

Set value to zeroed array of shape: number of antennas, 3.

Parameters
  • uvbase – object with this UVParameter as an attribute. Needed to get the number of antennas.

  • antnum_name – A string giving the name of the UVParameter containing the number of antennas.

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 – 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 – tuple giving the latitude (radians), longitude (radians) and altitude 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 – tuple giving the latitude (degrees), longitude (degrees) and altitude to use to set the value attribute.

check_acceptability()[source]

Check that values are acceptable. Special case for location, where we want to check the vector magnitude

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]

Iterator for all required UVParameter attributes.

extra()[source]

Iterator for all non-required UVParameter attributes.

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

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

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

  • run_check_acceptability – Option to check if values in required parameters are acceptable. Default is True.

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.uvfits.UVFITS[source]

Defines a uvfits-specific subclass of UVData for reading and writing uvfits files. 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.

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

Read in header, metadata and data from a uvfits file. Supports reading only selected portions of the data.

Parameters
  • filename – The uvfits file to read from.

  • antenna_nums – The antennas numbers to include when reading 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. Ignored if read_data is False.

  • antenna_names – The antennas names to include when reading 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. Ignored if read_data is False.

  • bls – 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, the polarizations argument below must be None. Ignored if read_data is False.

  • ant_str – 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 the above antenna args or the polarizations arg. Ignored if read_data is False.

  • frequencies – The frequencies to include when reading data into the object. Ignored if read_data is False.

  • freq_chans – The frequency channel numbers to include when reading data into the object. Ignored if read_data is False.

  • times – The times to include when reading data into the object. Ignored if read_data is False.

  • polarizations – The polarizations to include when reading data into the object. Ignored if read_data is False.

  • blt_inds – The baseline-time indices to include when reading data into the object. This is not commonly used. Ignored if read_data is False.

  • read_data – Read in the visibility and flag data. If set to false, only the basic header info and metadata (if read_metadata is True) will be read in. Results in an incompletely defined object (check will not pass). Default True.

  • read_metadata – 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. Default True.

  • run_check – Option to check for the existence and proper shapes of parameters after reading in the file. Default is True. Ignored if read_data is False.

  • check_extra – Option to check optional parameters as well as required ones. Default is True. Ignored if read_data is False.

  • run_check_acceptability – Option to check acceptable range of the values of parameters after reading in the file. Default is True. Ignored if read_data is False.

  • keep_all_metadata – Option to keep all the metadata associated with antennas, even those that do not remain after the select option. Default is True.

read_uvfits_metadata(filename, run_check_acceptability=True)[source]

Read in metadata (random parameter info) but not data from a uvfits file.

This is useful when an object already has the associated header info and full visibility data isn’t needed.

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

  • run_check_acceptability (bool) – Option to check acceptable range of the values of parameters after reading in the file. Default is True.

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

Read in data but not header info from a uvfits file (useful for an object that already has the associated header info).

Parameters
  • filename – The uvfits file to read from.

  • antenna_nums – The antennas numbers to include when reading 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 – The antennas names to include when reading 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 – 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, the polarizations argument below must be None.

  • ant_str – 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 the above antenna args or the polarizations arg.

  • frequencies – The frequencies to include when reading data into the object.

  • freq_chans – The frequency channel numbers to include when reading data into the object.

  • times – The times to include when reading data into the object.

  • polarizations – The polarizations to include when reading data into the object.

  • blt_inds – The baseline-time indices to include when reading data into the object. This is not commonly used.

  • read_metadata – Option to read metadata even if it already exists (to ensure data and metadata match). Default is True.

  • run_check – Option to check for the existence and proper shapes of parameters after reading in the file. Default is True.

  • check_extra – Option to check optional parameters as well as required ones. Default is True.

  • run_check_acceptability – Option to check acceptable range of the values of parameters after reading in the file. Default is True.

  • keep_all_metadata – Option to keep all the metadata associated with antennas, even those that do not remain after the select option. Default is True.

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.

class pyuvdata.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_miriad 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)[source]

Read in data from a miriad file.

Parameters
  • filepath – The miriad file directory to read from.

  • antenna_nums – The antennas numbers to read into the object.

  • bls – 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, the polarizations argument below must be None.

  • ant_str – A string containing information about what kinds of visibility data to read-in. Can be ‘auto’, ‘cross’, ‘all’. Cannot provide ant_str if antenna_nums and/or bls is not None.

  • polarizations – List of polarization integers or strings to read-in. Ex: [‘xx’, ‘yy’, …]

  • time_range – len-2 list containing min and max range of times (Julian Date) to read-in. Ex: [2458115.20, 2458115.40]

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

  • phase_type – Either ‘drift’ meaning zenith drift, ‘phased’ meaning the data are phased to a single RA/Dec or None and it will be guessed at based on the file. Default None.

  • correct_lat_lon – flag – that only matters if altitude is missing – to update the latitude and longitude from the known_telescopes list

  • run_check – Option to check for the existence and proper shapes of parameters after reading in the file. Default is True.

  • check_extra – Option to check optional parameters as well as required ones. Default is True.

  • run_check_acceptability – Option to check acceptable range of the values of parameters after reading in the file. Default is True.

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 – The miriad file directory to write to.

  • run_check – Option to check for the existence and proper shapes of parameters before writing the file. Default is True.

  • check_extra – Option to check optional parameters as well as required ones. Default is True.

  • run_check_acceptability – Option to check acceptable range of the values of parameters before writing the file. Default is True.

  • clobber – Option to overwrite the filename if the file already exists. Default is False. If False and file exists, raises an IOError.

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

read_miriad_metadata(filename, correct_lat_lon=True)[source]

Read in metadata (parameter info) but not data from a miriad file.

Parameters
  • filename – The miriad file to read

  • correct_lat_lon – flag – that only matters if altitude is missing – to update the latitude and longitude from the known_telescopes list

Returns

default_miriad_variables – list of default miriad variables other_miriad_variables: list of other miriad variables extra_miriad_variables: list of extra, non-standard variables check_variables: dict of extra miriad variables

class pyuvdata.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, run_check=True, check_extra=True, run_check_acceptability=True)[source]

Read in data from a list of FHD files.

Parameters
  • filelist – The list of FHD save files to read from. Must include at least one polarization file, a params file and a flag file.

  • use_model – Option to read in the model visibilities rather than the dirty visibilities. Default is False.

  • run_check – Option to check for the existence and proper shapes of parameters after reading in the file. Default is True.

  • check_extra – Option to check optional parameters as well as required ones. Default is True.

  • run_check_acceptability – Option to check acceptable range of the values of parameters after reading in the file. Default is True.

class pyuvdata.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 – The cal.sav file to read from.

  • obs_file – The obs.sav file to read from.

  • settings_file – The settings_file to read from. Optional, but very useful for provenance.

  • raw – 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 – Optional string or list of strings to add to the object’s history parameter. Default is None.

  • run_check – Option to check for the existence and proper shapes of parameters after reading in the file. Default is True.

  • check_extra – Option to check optional parameters as well as required ones. Default is True.

  • run_check_acceptability – Option to check acceptable range of the values of parameters after reading in the file. Default is True.

class pyuvdata.calfits.CALFITS[source]

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

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 – The calfits file to write to.

  • run_check – Option to check for the existence and proper shapes of parameters before writing the file. Default is True.

  • check_extra – Option to check optional parameters as well as required ones. Default is True.

  • run_check_acceptability – Option to check acceptable range of the values of parameters before writing the file. Default is True.

  • clobber – Option to overwrite the filename if the file already exists. Default is False.

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

Read data from a calfits file.

Parameters
  • filename – The calfits file to read to.

  • run_check – Option to check for the existence and proper shapes of parameters after reading in the file. Default is True.

  • check_extra – Option to check optional parameters as well as required ones. Default is True.

  • run_check_acceptability – Option to check acceptable range of the values of parameters after reading in the file. Default is True.

strict_fits: boolean

If True, require that the data axes have cooresponding NAXIS, CRVAL, CDELT and CRPIX keywords. If False, allow CRPIX to be missing and set it equal to zero and allow the CRVAL for the spw directions to be missing and set it to zero. This keyword exists to support old calfits files that were missing many CRPIX and CRVAL keywords. Default is False.

class pyuvdata.beamfits.BeamFITS[source]

Defines a fits-specific subclass of UVBeam for reading and writing regularly gridded or healpix beam fits files. This class should not be interacted with directly, instead use the read_beamfits and write_beamfits methods on the UVBeam class.

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 – The beamfits file to write to.

  • run_check – Option to check for the existence and proper shapes of required parameters after reading in the file. Default is True.

  • check_extra – Option to check optional parameters as well as required ones. Default is True.

  • run_check_acceptability – Option to check acceptability of the values of required parameters after reading in the file. Default is True.

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 – The beamfits file to write to.

  • run_check – Option to check for the existence and proper shapes of required parameters before writing the file. Default is True.

  • check_extra – Option to check optional parameters as well as required ones. Default is True.

  • run_check_acceptability – Option to check acceptability of the values of required parameters before writing the file. Default is True.

class pyuvdata.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]

Method to extract the frequency from the file name, assuming 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 – filename (string)

Returns

extracted frequency

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 – The cst file to read from.

  • beam_type – what beam_type to read in (‘power’ or ‘efield’). Defaults to ‘power’.

  • feed_pol – what feed or polarization the files correspond to. Defaults to ‘x’ (meaning x for efield or xx for power beams).

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

  • frequency – the frequency corresponding to the filename. If not passed, the code attempts to parse it from the filename.

  • telescope_name – the name of the telescope corresponding to the filename.

  • feed_name – the name of the feed corresponding to the filename.

  • feed_version – the version of the feed corresponding to the filename.

  • model_name – the name of the model corresponding to the filename.

  • model_version – the version of the model corresponding to the filename.

  • history – A string detailing the history of the filename.

  • x_orientation – 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) – The reference impedance of the model(s).

  • extra_keywords (dict) – a dictionary containing any extra_keywords.

  • run_check – Option to check for the existence and proper shapes of required parameters after reading in the file. Default is True.

  • check_extra – Option to check optional parameters as well as required ones. Default is True.

  • run_check_acceptability – Option to check acceptable range of the values of required parameters after reading in the file. Default is True.

Functions

pyuvdata.version.construct_version_info()[source]

Get full version information, including git details

Returns

dict – dictionary giving full version information

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

aipy extracts

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.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.aipy_extracts.UV(filename, status='old', corrmode='r')[source]

Top-level interface to a Miriad UV data set.

vars()[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 vars 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(raw=False)[source]

Provide an iterator over preamble, data.

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

Parameters

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

Yields
  • 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, type)[source]

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

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

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