Developer Docs

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

Classes

class parameter.UVParameter(name, required=True, value=None, spoof_val=None, form=(), description='', expected_type=<type '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.

check_acceptability()[source]

Check that values are acceptable.

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.
class parameter.AntPositionParameter(name, required=True, value=None, spoof_val=None, form=(), description='', expected_type=<type '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 parameter.AngleParameter(name, required=True, value=None, spoof_val=None, form=(), description='', expected_type=<type '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 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).

check_acceptability()[source]

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

lat_lon_alt()[source]

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

lat_lon_alt_degrees()[source]

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

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.
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.
class 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’

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.
degree_prop_fget(param_name)[source]

Degree getter method for AngleParameter properties.

degree_prop_fset(param_name)[source]

Degree setter method for AngleParameter properties.

extra()[source]

Iterator for all non-required UVParameter attributes.

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.

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.

prop_fget(param_name)[source]

Getter method for UVParameter properties.

prop_fset(param_name)[source]

Setter method for UVParameter properties.

required()[source]

Iterator for all required UVParameter attributes.

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

Read in data from a uvfits file.

Parameters:
  • filename – The uvfits file to read from.
  • 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_uvfits(filename, spoof_nonessential=False, force_phase=False, run_check=True, check_extra=True, run_check_acceptability=True)[source]

Write the data to a uvfits file.

Parameters:
  • filename – The uvfits file to write to.
  • spoof_nonessential – Option to spoof the values of optional UVParameters that are not set but are required for uvfits files. Default is False.
  • force_phase – Option to automatically phase drift scan data to zenith of the first timestamp. Default is False.
  • 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.
class 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, correct_lat_lon=True, run_check=True, check_extra=True, run_check_acceptability=True, phase_type=None)[source]

Read in data from a miriad file.

Parameters:
  • filepath – The miriad file directory to read from.
  • 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.
  • no_antnums – Option to not write the antnums variable to the file. Should only be used for testing purposes.
class 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 calfits.CALFITS[source]

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

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.
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.
class 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, 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.
  • 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, 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.
  • run_check_acceptability – Option to check acceptability of the values of required parameters before writing the file. Default is True.
class telescopes.Telescope[source]

A class for defining a telescope for use with UVData objects.

citation

str – text giving source of telescope information

telescope_name

string, UVParameter – name of the telescope

telescope_location

array_like, UVParameter – telescope location xyz coordinates in ITRF (earth-centered frame).

Functions

telescopes.known_telescopes()[source]

Get list of known telescopes.

telescopes.get_telescope(telescope_name)[source]

Get Telescope object for a telescope in known_telescopes().

Parameters:telescope_name – string name of a telescope, must be in known_telescopes().
Returns:The Telescope object associated with telescope_name.

Utility Functions

Commonly used utility functions.

utils.ECEF_from_ENU(enu, latitude, longitude, altitude)[source]

Calculate ECEF coordinates from local ENU (east, north, up) coordinates.

Parameters:
  • enu – numpy array, shape (3, Npts), with local ENU coordinates
  • latitude – latitude of center of ENU coordinates in radians
  • longitude – longitude of center of ENU coordinates in radians
Returns:

numpy array, shape (3, Npts), with ECEF x,y,z coordinates

utils.ECEF_from_rotECEF(xyz, longitude)[source]

Calculate ECEF from a rotated ECEF such that the x-axis goes through the specified longitude. (Inverse of rotECEF_from_ECEF)

Parameters:
  • xyz – numpy array, shape (Npts, 3), with rotated ECEF x,y,z coordinates
  • longitude – longitude in radians to rotate coordinates to (usually the array center/telescope location)
Returns:

numpy array, shape (Npts, 3), with ECEF coordinates

utils.ENU_from_ECEF(xyz, latitude, longitude, altitude)[source]

Calculate local ENU (east, north, up) coordinates from ECEF coordinates.

Parameters:
  • xyz – numpy array, shape (3, Npts), with ECEF x,y,z coordinates
  • latitude – latitude of center of ENU coordinates in radians
  • longitude – longitude of center of ENU coordinates in radians
  • altitude – altitude of center of ENU coordinates in radians
Returns:

numpy array, shape (3, Npts), with local ENU coordinates

utils.LatLonAlt_from_XYZ(xyz)[source]

Calculate lat/lon/alt from ECEF x,y,z.

Parameters:xyz – numpy array, shape (3, Npts), with ECEF x,y,z coordinates
Returns:tuple of latitude, longitude, altitude numpy arrays (if Npts > 1) or values (if Npts = 1) in radians & meters
utils.XYZ_from_LatLonAlt(latitude, longitude, altitude)[source]

Calculate ECEF x,y,z from lat/lon/alt values.

Parameters:
  • latitude – latitude in radians, can be a single value or a vector of length Npts
  • longitude – longitude in radians, can be a single value or a vector of length Npts
  • altitude – altitude in meters, can be a single value or a vector of length Npts
Returns:

numpy array, shape (3, Npts) (if Npts > 1) or (3,) (if Npts = 1), with ECEF x,y,z coordinates

utils.eq2top_m(ha, dec)[source]

Return the 3x3 matrix converting equatorial coordinates to topocentric at the given hour angle (ha) and declination (dec). Borrowed from aipy.

utils.fits_gethduaxis(HDU, axis, strict_fits=True)[source]

Helper function for making axis arrays for fits files.

Parameters:
  • HDU – a fits HDU
  • axis – the axis number of interest
  • strict_fits – boolean If True, require that the axis has cooresponding NAXIS, CRVAL, CDELT and CRPIX keywords. If False, allow CRPIX to be missing and set it equal to zero (as a way of supporting old calfits files). Default is False.
Returns:

numpy array of values for that axis

utils.fits_indexhdus(hdulist)[source]

Helper function for fits I/O.

Parameters:hdulist – a list of hdus
Returns:dictionary of table names
utils.get_iterable(x)[source]

Helper function to ensure iterability.

utils.polnum2str(num)[source]

Convert polarization number to str according to AIPS Memo 117.

Parameters:num – polarization number
Returns:String corresponding to string
utils.polstr2num(pol)[source]

Convert polarization str to number according to AIPS Memo 117.

Parameters:pol – polarization string
Returns:Number corresponding to string
utils.rotECEF_from_ECEF(xyz, longitude)[source]

Calculate a rotated ECEF from ECEF such that the x-axis goes through the specified longitude.

Miriad (and maybe uvfits) expect antenna positions in this frame (with longitude of the array center/telescope location)

Parameters:
  • xyz – numpy array, shape (Npts, 3), with ECEF x,y,z coordinates
  • longitude – longitude in radians to rotate coordinates to (usually the array center/telescope location)
Returns:

numpy array, shape (Npts, 3), with rotated ECEF coordinates

utils.top2eq_m(ha, dec)[source]

Return the 3x3 matrix converting topocentric coordinates to equatorial at the given hour angle (ha) and declination (dec). Slightly changed from aipy to simply write the matrix instead of inverting.