diff --git a/src/pyuvdata/uvdata/uvdata.py b/src/pyuvdata/uvdata/uvdata.py index 05b985d698..65b0dc44d3 100644 --- a/src/pyuvdata/uvdata/uvdata.py +++ b/src/pyuvdata/uvdata/uvdata.py @@ -4537,6 +4537,8 @@ def _phase_dict_helper( cat_vrad = vrad cat_dist_units = dist_units cat_near_field = near_field + cat_dist_units = dist_units + cat_near_field = near_field else: temp_dict = self.phase_center_catalog[cat_id] cat_type = temp_dict["cat_type"] @@ -4553,6 +4555,8 @@ def _phase_dict_helper( cat_vrad = temp_dict.get("cat_vrad") cat_dist_units = temp_dict.get("cat_dist_units") cat_near_field = temp_dict.get("cat_near_field") + cat_dist_units = temp_dict.get("cat_dist_units") + cat_near_field = temp_dict.get("cat_near_field") else: # The name of the source is unique! cat_type = "sidereal" if cat_type is None else cat_type @@ -4567,6 +4571,8 @@ def _phase_dict_helper( cat_vrad = vrad cat_dist_units = dist_units cat_near_field = near_field + cat_dist_units = dist_units + cat_near_field = near_field if (cat_epoch is None) and (cat_type != "unprojected"): cat_epoch = 1950.0 if (cat_frame in ["fk4", "fk4noeterms"]) else 2000.0 @@ -4781,6 +4787,13 @@ def phase( (for ephem phase centers), will be interpreted in units of parsec. Alternatively, an astropy.units.Quantity object may be passed instead, in which case the units will be infered automatically. + dist : float or ndarray of float or astropy.units.Quantity object + Distance to the source. Used for sidereal and ephem phase centers, + and for applying near-field corrections. If passed either as a float + (for sidereal phase centers) or as an ndarray of floats of shape (Npts,) + (for ephem phase centers), will be interpreted in units of parsec. + Alternatively, an astropy.units.Quantity object may be passed instead, + in which case the units will be infered automatically. vrad : float or ndarray of float Radial velocity of the source, in units of km/s. Only used for sidereal and ephem phase centers. Expected to be a float for sidereal phase @@ -4802,6 +4815,10 @@ def phase( Option to apply near-field corrections to the provided ra, dec, and distance. Defaults to False (apply far-field corrections only). + near_field : bool + Option to apply near-field corrections to the provided + ra, dec, and distance. Defaults to False + (apply far-field corrections only). Raises ------ @@ -4849,6 +4866,23 @@ def phase( UserWarning, ) + dist_units = "pc" + if dist is not None: + if isinstance(dist, units.Quantity): + dist_units = dist.unit + dist_qt = copy.deepcopy(dist) + dist = dist.value + else: + dist_qt = dist * units.parsec + + if near_field: + warnings.warn( + "near_field is set to True, but dist is not an " + "astropy.units.Quantity object. " + "Distance will be interpreted in units of parsec.", + UserWarning, + ) + phase_dict = self._phase_dict_helper( lon=lon, lat=lat, @@ -5011,6 +5045,12 @@ def phase( focus=dist_qt, ra=phase_dict["cat_lon"], dec=phase_dict["cat_lat"] ) + # Lastly, apply near-field corrections if specified + if near_field: + self._apply_near_field_corrections( + focus=dist_qt, ra=phase_dict["cat_lon"], dec=phase_dict["cat_lat"] + ) + def phase_to_time( self, time, *, phase_frame="icrs", use_ant_pos=True, select_mask=None ):