Skip to content

Commit

Permalink
fixed merge error with remote near-field branch
Browse files Browse the repository at this point in the history
  • Loading branch information
[email protected] committed Oct 8, 2024
2 parents 5d07fec + 7c6fd4e commit f89c9cc
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions src/pyuvdata/uvdata/uvdata.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
------
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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
):
Expand Down

0 comments on commit f89c9cc

Please sign in to comment.