Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
Returns
-------
lst_array: array of float
lst_array corresponding to time_array and at telescope location.
Units are radian.
"""
if not isinstance(uv, (UVCal, UVData)):
raise ValueError(
"Function lst_from_uv can only operate on " "UVCal or UVData object."
)
tel = uvtel.get_telescope(uv.telescope_name)
lat, lon, alt = tel.telescope_location_lat_lon_alt_degrees
lst_array = uvutils.get_lst_for_time(uv.time_array, lat, lon, alt)
return lst_array
# get time information
self.time_array = header["time_array"][:]
integration_time = header["integration_time"]
self.integration_time = integration_time[:]
proc = None
if "lst_array" in header:
self.lst_array = header["lst_array"][:]
# check that lst_array in file is self-consistent
if run_check_acceptability:
(
latitude,
longitude,
altitude,
) = self.telescope_location_lat_lon_alt_degrees
lst_array = uvutils.get_lst_for_time(
self.time_array, latitude, longitude, altitude
)
if not np.all(
np.isclose(
self.lst_array,
lst_array,
rtol=self._lst_array.tols[0],
atol=self._lst_array.tols[1],
)
):
warnings.warn(
"LST values stored in {file} are not self-consistent "
"with time_array and telescope location. Consider "
"recomputing with utils.get_lst_for_time.".format(file=filename)
)
else:
self.Ntimes = len(np.unique(self.time_array))
# check if lst array is saved. It's not a standard metadata item in uvfits,
# but if the file was written with pyuvdata it may be present
# (depending on pyuvdata version)
proc = None
if "LST" in vis_hdu.data.parnames:
# angles in uvfits files are stored in degrees, so convert to radians
self.lst_array = np.deg2rad(vis_hdu.data.par("lst"))
if run_check_acceptability:
(
latitude,
longitude,
altitude,
) = self.telescope_location_lat_lon_alt_degrees
lst_array = uvutils.get_lst_for_time(
self.time_array, latitude, longitude, altitude
)
if not np.all(
np.isclose(
self.lst_array,
lst_array,
rtol=self._lst_array.tols[0],
atol=self._lst_array.tols[1],
)
):
warnings.warn(
"LST values stored in this file are not "
"self-consistent with time_array and telescope "
"location. Consider recomputing with "
"utils.get_lst_for_time."
)
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.
"""
from . import aipy_extracts
# change time_array and lst_array to mark beginning of integration,
# per Miriad format
miriad_time_array = self.time_array - self.integration_time / (24 * 3600.0) / 2
if self.telescope_location is not None:
latitude, longitude, altitude = self.telescope_location_lat_lon_alt_degrees
miriad_lsts = uvutils.get_lst_for_time(
miriad_time_array, latitude, longitude, altitude
)
# Miriad requires j>i which we call ant1 1: