Skip to content

Commit 029378e

Browse files
authored
Merge pull request #225 from discsim/uv_unit_check
Add sanity check of (u,v) units
2 parents db88a3b + 7a88578 commit 029378e

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

frank/fit.py

+4
Original file line numberDiff line numberDiff line change
@@ -818,6 +818,10 @@ def main(*args):
818818
u, v, vis, weights = alter_data(
819819
u, v, vis, weights, geom, model)
820820

821+
# check units of (u,v)
822+
# (after conversion if model['modify_data']['norm_wle'] is True)
823+
utilities.check_uv(u, v)
824+
821825
if model['analysis']['bootstrap_ntrials']:
822826
boot_fig, boot_axes = perform_bootstrap(
823827
u, v, vis, weights, geom, model)

frank/utilities.py

+28
Original file line numberDiff line numberDiff line change
@@ -401,6 +401,34 @@ def bin_edges(self):
401401
return [self._uv_left, self._uv_right]
402402

403403

404+
def check_uv(u, v, min_q=1e3, max_q=1e8):
405+
r"""
406+
Check if u,v distances are sensible for expected code unit of
407+
[lambda], or if instead they're being supplied in [m].
408+
409+
Parameters
410+
----------
411+
u, v : array, unit = :math:`\lambda`
412+
u and v coordinates of observations
413+
min_q : float, unit = :math:`\lambda`, default=1e3
414+
Minimum baseline in code units expected for a dataset. The default
415+
value of 1e3 is a conservative value for ALMA, assuming a minimum
416+
antenna separation of ~12 m and maximum observing wavelength of 3.6 mm.
417+
max_q : float, unit = :math:`\lambda`, default=1e5
418+
Maximum baseline in code units expected for a dataset. The default
419+
value of 1e8 is a conservative value for ALMA, assuming a maximum
420+
antenna separation of ~16 km and minimum observing wavelength of 0.3 mm.
421+
"""
422+
q = np.hypot(u, v)
423+
424+
if min(q) < min_q:
425+
logging.warning("WARNING: "
426+
f"Minimum baseline {min(q):.1e} < expected minimum {min_q:.1e} [lambda]. "
427+
"'u' and 'v' distances must be in units of [lambda], "
428+
"but it looks like they're in [m]."
429+
)
430+
431+
404432
def normalize_uv(u, v, wle):
405433
r"""
406434
Normalize data u and v coordinates by the observing wavelength

0 commit comments

Comments
 (0)